altos/draw: Only cover ASCII
authorKeith Packard <keithp@keithp.com>
Sun, 26 Feb 2023 06:38:33 +0000 (22:38 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 26 Feb 2023 06:47:51 +0000 (22:47 -0800)
Skip the rest of latin-1

Signed-off-by: Keith Packard <keithp@keithp.com>
src/draw/font-convert

index c7d9c780edcf92960b14e4ee578e884b4764f4c7..f47ccc9caeab074272dd3dc8f60ef007cba44fac 100755 (executable)
@@ -103,7 +103,7 @@ void print_font(font_t font, string font_name) {
        int     height = font.glyphs[0].height;
        int     max_width = width;
        int     max_height = height;
-       int[256] pos = { -1 ... };
+       int[128] pos = { -1 ... };
        int[...] bytes;
        bool fixed_size = true;
 
@@ -122,9 +122,12 @@ void print_font(font_t font, string font_name) {
 
        /* build byte array */
        for (int i = 0; i < dim(font.glyphs); i++) {
-               pos[font.glyphs[i].encoding] = dim(bytes);
-               for (int b = 0; b < dim(font.glyphs[i].bytes); b++)
-                       bytes[dim(bytes)] = font.glyphs[i].bytes[b];
+               if (font.glyphs[i].encoding < dim(pos))
+               {
+                       pos[font.glyphs[i].encoding] = dim(bytes);
+                       for (int b = 0; b < dim(font.glyphs[i].bytes); b++)
+                               bytes[dim(bytes)] = font.glyphs[i].bytes[b];
+               }
        }
 
        /* Fill in default glyph */