1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-01 05:15:20 +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 CFLAGS = -g -Wall
OBJS = font.o OBJS = edit.o font.o
.PHONY: all clean spotless .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 ----------------------------------------------------------- */ /* ----- Testing ----------------------------------------------------------- */

View File

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