chiark / gitweb /
Make aliases work again, inefficiently
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 2 Nov 2024 22:07:23 +0000 (22:07 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Thu, 14 Nov 2024 22:27:18 +0000 (22:27 +0000)
This pulls the conditional that works out how to render a glyph into
it's own function, doglyph(), that also handles indirecting through
aliases.  Later maybe we'll properly use subroutines to share the
charstrings for aliased glyphs.

bedstead.c

index 75bb3351808c7ecce4781d8af1f836b543684567..605e2e26655d22d6ce50cad15b2fe73c427dfb8b 100644 (file)
@@ -196,7 +196,6 @@ static void dochar(char const data[YSIZE], unsigned flags);
 static void dochar_plotter(char const data[YSIZE], unsigned flags);
 static void domosaic(unsigned code, bool sep);
 static void domosaic4(unsigned code, bool sep);
-static void doalias(char const *alias_of);
 static void dopanose(void);
 static void docmap(int pid, int eid, int format);
 static void glyph_complement(void);
@@ -2628,6 +2627,7 @@ static int const nglyphs = NGLYPHS;
 static struct glyph const *glyphs_by_name[NGLYPHS];
 
 static void dolookups(struct glyph const *);
+static void doglyph(struct glyph const *);
 
 static bool
 getpix(char const data[YSIZE - 1], int x, int y, unsigned flags)
@@ -3045,7 +3045,6 @@ main(int argc, char **argv)
        TTXF(StdHW, "%4g", (double)YPIX);
        TTXF(StdVW, "%4g", (double)(XPIX * (100 + weight->weight) / 100));
        TTXI(defaultWidthX, XSIZE * XPIX);
-       printf("  </Private>\n");
        /* if (plottermode) { */
        /*      printf("StrokedFont: 1\n"); */
        /*      printf("StrokeWidth: 50\n"); */
@@ -3080,29 +3079,16 @@ main(int argc, char **argv)
        /* printf("OtfFeatName: 'ss16' 1033 \"6-cell separated graphics\"\n"); */
        /* printf("Lookup: 257 0 0 \"palt: proportional metrics\" {\"palt\"} " */
        /*     "['palt' ('DFLT' <'dflt'> 'latn' <'dflt'>)]\n"); */
-       printf("  <CharStrings>\n");
        extraglyphs = 0;
        for (i = 0; i < nglyphs; i++)
                glyphs_by_name[i] = glyphs + i;
        qsort(glyphs_by_name, nglyphs, sizeof(glyphs_by_name[0]),
              &compare_glyphs_by_name);
+       printf("  </Private>\n");
+       printf("  <CharStrings>\n");
        for (i = 0; i < nglyphs; i++) {
                printf("  <CharString name='%s'>\n", glyphs[i].name);
-               /* dolookups(&glyphs[i]); */
-               if (glyphs[i].flags & IS_ALIAS)
-                       doalias(glyphs[i].alias_of);
-               else if (glyphs[i].flags & MOS6)
-                       domosaic(glyphs[i].data[0],
-                                (glyphs[i].flags & SEP) != 0);
-               else if (glyphs[i].flags & MOS4)
-                       domosaic4(glyphs[i].data[0],
-                                 (glyphs[i].flags & SEP) != 0);
-               else {
-                       if (plottermode)
-                               dochar_plotter(glyphs[i].data, glyphs[i].flags);
-                       else
-                               dochar(glyphs[i].data, glyphs[i].flags);
-               }
+               doglyph(&glyphs[i]);
                printf("  </CharString>\n");
        }
        printf("  </CharStrings>\n");
@@ -3293,6 +3279,23 @@ docmap(int pid, int eid, int format)
        printf("  </cmap_format_%d>\n", format);
 }
 
+/* Emit a charstring for a glyph. */
+static void
+doglyph(struct glyph const *g)
+{
+
+       while (g->flags & IS_ALIAS)
+               g = get_glyph_by_name(g->alias_of);
+       if (g->flags & MOS6)
+               domosaic(g->data[0], (g->flags & SEP) != 0);
+       else if (g->flags & MOS4)
+               domosaic4(g->data[0], (g->flags & SEP) != 0);
+       else if (plottermode)
+               dochar_plotter(g->data, g->flags);
+       else
+               dochar(g->data, g->flags);
+}
+
 static void
 dopalt(struct glyph const *g)
 {
@@ -3933,17 +3936,6 @@ domosaic4(unsigned code, bool sep)
        emit_path();
 }
 
-static void
-doalias(char const *alias_of)
-{
-       struct glyph const *g;
-
-       /* g = get_glyph_by_name(alias_of); */
-       /* printf("Refer: %td %d N 1 0 0 1 0 0 1\n", g - glyphs, g->unicode); */
-       /* XXX */
-       printf("endchar\n");
-}
-       
 static int
 byunicode(const void *va, const void *vb)
 {