1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-12-23 03:14:36 +02:00

tools/libtxt/: add rendering of (compiled) edits (untested, WIP)

This commit is contained in:
Werner Almesberger 2012-06-29 22:52:25 -03:00
parent d05c6a9558
commit 67a3ecc798
3 changed files with 23 additions and 2 deletions

View File

@ -15,7 +15,7 @@ MAIN = libtxt.a
CFLAGS = -g -Wall
OBJS = font.o
OBJS = edit.o font.o
.PHONY: all clean spotless

View File

@ -277,6 +277,19 @@ int draw_char(void *canvas, int width, int height,
}
int char_height(const struct font *font, char c)
{
const char *cp;
const struct sym *sym;
cp = strchr(charset, c);
if (!cp)
return 0;
sym = font->sym+(cp-charset);
return sym->h;
}
/* ----- Testing ----------------------------------------------------------- */

View File

@ -13,15 +13,20 @@
#ifndef LIBTXT_H
#define LIBTXT_H
struct image;
struct font;
struct edit {
enum edit_type {
edit_string,
edit_font,
edit_spc,
edit_xoff,
edit_xpos,
edit_yoff,
edit_ypos,
edit_nl,
} type;
union {
const char *s;
@ -35,6 +40,7 @@ struct edit {
*
* <FONT fontname>
* <IMG imagefile>
* <SPC offset>
* <X+offset> <X-offset> <X=pos>
* <Y+offset> ...
*
@ -52,10 +58,12 @@ void free_font(struct font *font);
int draw_char(void *canvas, int width, int height,
const struct font *font, char c, int x, int y);
int char_height(const struct font *font, char c);
struct edit *text2edit(const char *s);
char *edit2text(const struct edit *e);
void *apply_edits(int width, int height, const struct edit *e);
void *apply_edits(int width, int height, const struct edit *e,
const char **error);
#endif /* !LIBTXT_H */