2002-04-25 19:52:26 +04:00
|
|
|
/**
|
2002-06-26 16:19:24 +04:00
|
|
|
* $Id: font.c,v 1.4 2002/06/26 12:19:24 bursa Exp $
|
2002-04-25 19:52:26 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2002-06-19 01:24:21 +04:00
|
|
|
#include "css.h"
|
2002-04-25 19:52:26 +04:00
|
|
|
#include "font.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* internal structures
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct font_set {
|
|
|
|
/* a set of font handles */
|
2002-06-26 16:19:24 +04:00
|
|
|
int stop_lcc_complaining;
|
2002-04-25 19:52:26 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct font_set * font_set_create(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2002-06-26 16:19:24 +04:00
|
|
|
|
2002-04-25 19:52:26 +04:00
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
2002-05-11 19:22:24 +04:00
|
|
|
struct font_split font_split(struct font_set * font_set, font_id id, const char * text,
|
|
|
|
unsigned long width, int force)
|
2002-04-25 19:52:26 +04:00
|
|
|
{
|
|
|
|
size_t len = strlen(text);
|
|
|
|
unsigned int i;
|
2002-05-11 19:22:24 +04:00
|
|
|
struct font_split split;
|
|
|
|
|
|
|
|
split.height = 30;
|
2002-06-26 16:19:24 +04:00
|
|
|
|
2002-05-11 19:22:24 +04:00
|
|
|
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;
|
2002-04-25 19:52:26 +04:00
|
|
|
}
|
2002-05-11 19:22:24 +04:00
|
|
|
|
|
|
|
return split;
|
2002-04-25 19:52:26 +04:00
|
|
|
}
|
|
|
|
|
2002-06-19 01:24:21 +04:00
|
|
|
unsigned long font_width(struct css_style * style, const char * text, unsigned int length)
|
|
|
|
{
|
|
|
|
return length * 7;
|
|
|
|
}
|
2002-04-25 19:52:26 +04:00
|
|
|
|