summaryrefslogtreecommitdiff
path: root/src/draw/font-convert
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-20 21:02:59 -0800
committerKeith Packard <keithp@keithp.com>2016-11-20 21:02:59 -0800
commitc5734e9e38bc583aff305e3c534cfb8b9088bc71 (patch)
treef02f3dafea7e704a7164011700c56289ab9fed0a /src/draw/font-convert
parent83cfc271e37f568cb1d821cf6a96750f3ca3854c (diff)
altos/draw: Add a reasonable API for drawing, add lines.lisp
Also, move the demo drawing into the stm-vga app and out of the vga driver. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/draw/font-convert')
-rwxr-xr-xsrc/draw/font-convert20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/draw/font-convert b/src/draw/font-convert
index 2446592b..80297cf9 100755
--- a/src/draw/font-convert
+++ b/src/draw/font-convert
@@ -11,6 +11,7 @@ typedef struct {
typedef struct {
glyph_t[...] glyphs;
int default_char;
+ int ascent;
} font_t;
glyph_t
@@ -29,8 +30,10 @@ read_glyph(file f)
case "ENCODING":
glyph.encoding = atoi(tokens[1]);
break;
- case "BBX":
+ case "DWIDTH":
glyph.width = atoi(tokens[1]);
+ break;
+ case "BBX":
glyph.height = atoi(tokens[2]);
break;
case "ENDCHAR":
@@ -50,15 +53,23 @@ read_glyph(file f)
font_t read_font(file f) {
font_t font = { .glyphs = {}, .default_char = -1 };
+ bool in_head = true;
- while (!File::end(f)) {
+ while (in_head && !File::end(f)) {
string l = File::fgets(f);
string[*] tokens = String::split(l, " ");
- if (tokens[0] == "DEFAULT_CHAR")
+ switch (tokens[0]) {
+ case "DEFAULT_CHAR":
font.default_char = atoi(tokens[1]);
- if (tokens[0] == "CHARS")
break;
+ case "FONT_ASCENT":
+ font.ascent = atoi(tokens[1]);
+ break;
+ case "CHARS":
+ in_head = false;
+ break;
+ }
}
while (!File::end(f)) {
glyph_t glyph = read_glyph(f);
@@ -130,6 +141,7 @@ void print_font(font_t font) {
printf("#define GLYPH_WIDTH %d\n", width);
printf("#define GLYPH_HEIGHT %d\n", height);
+ printf("#define GLYPH_ASCENT %d\n", font.ascent);
}
twixt (file f = File::open(argv[1], "r"); File::close(f)) {