1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-01 05:38:06 +02:00

libtxt/font.c: draw_char returns maximum character width for space

This commit is contained in:
Werner Almesberger 2012-09-13 15:10:38 -03:00
parent 52142fe66b
commit 69db2f62c4

View File

@ -40,6 +40,7 @@ struct image {
struct font { struct font {
struct image *img; struct image *img;
struct sym sym[CHARS]; struct sym sym[CHARS];
int max_width;
}; };
@ -148,9 +149,13 @@ void free_image(struct image *img)
static void set_block(struct font *font, int *n, static void set_block(struct font *font, int *n,
int xlast, int x, int y0, int y1) int xlast, int x, int y0, int y1)
{ {
int width = x-xlast-1;
if (width > font->max_width)
font->max_width = width;
font->sym[*n].x = xlast+1; font->sym[*n].x = xlast+1;
font->sym[*n].y = y0; font->sym[*n].y = y0;
font->sym[*n].w = x-xlast-1; font->sym[*n].w = width;
font->sym[*n].h = y1-y0+1; font->sym[*n].h = y1-y0+1;
(*n)++; (*n)++;
} }
@ -269,6 +274,8 @@ int draw_char(void *canvas, int width, int height,
const char *cp; const char *cp;
const struct sym *sym; const struct sym *sym;
if (c == ' ')
return font->max_width;
cp = strchr(charset, c); cp = strchr(charset, c);
if (!cp) if (!cp)
return 0; return 0;