mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-26 05:03:09 +02:00
libtxt/font.c: draw_char returns maximum character width for space
This commit is contained in:
parent
52142fe66b
commit
69db2f62c4
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user