summaryrefslogtreecommitdiff
path: root/render/font.c
blob: 01f3cde09919c5b31bb5e0d3b9fc67f814666906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
 * $Id: font.c,v 1.3 2002/06/18 21:24:21 bursa Exp $
 */

#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "css.h"
#include "font.h"

/**
 * internal structures
 */

struct font_set {
	/* a set of font handles */
};

/**
 * functions
 */

struct font_set * font_set_create(void)
{
	return 0;
}
	
font_id font_add(struct font_set * font_set, const char * name, unsigned int weight,
		unsigned int size)
{
	return 0;
}

void font_set_free(struct font_set * font_set)
{
}

/**
 * find where to split some text to fit it in width
 */

struct font_split font_split(struct font_set * font_set, font_id id, const char * text,
		unsigned long width, int force)
{
	size_t len = strlen(text);
	unsigned int i;
	struct font_split split;

	split.height = 30;
	
	if (len * 20 <= width) {
		split.width = len * 20;
		split.end = text + len;
	} else {
		for (i = width / 20; i != 0 && text[i] != ' '; i--)
			;
		if (force && i == 0) {
			i = width / 20;
			if (i == 0) i = 1;
		}
		split.width = i * 20;
		if (text[i] == ' ') i++;
		split.end = text + i;
	}

	return split;
}

unsigned long font_width(struct css_style * style, const char * text, unsigned int length)
{
	return length * 7;
}