mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-22 06:33:08 +02:00
tools/libtxt/: add rendering of (compiled) edits (untested, WIP)
This commit is contained in:
parent
d05c6a9558
commit
67a3ecc798
@ -15,7 +15,7 @@ MAIN = libtxt.a
|
||||
|
||||
CFLAGS = -g -Wall
|
||||
|
||||
OBJS = font.o
|
||||
OBJS = edit.o font.o
|
||||
|
||||
.PHONY: all clean spotless
|
||||
|
||||
|
@ -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 ----------------------------------------------------------- */
|
||||
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user