From: Ben Harris Date: Sat, 2 Nov 2024 22:07:23 +0000 (+0000) Subject: Make aliases work again, inefficiently X-Git-Tag: bedstead-3.246~63 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=36a99e6005d79db2a7d6bd3c6c47560141534b77;p=bedstead.git Make aliases work again, inefficiently 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. --- diff --git a/bedstead.c b/bedstead.c index 75bb335..605e2e2 100644 --- a/bedstead.c +++ b/bedstead.c @@ -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(" \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(" \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(" \n"); + printf(" \n"); for (i = 0; i < nglyphs; i++) { printf(" \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(" \n"); } printf(" \n"); @@ -3293,6 +3279,23 @@ docmap(int pid, int eid, int format) printf(" \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) {