chiark / gitweb /
Put single substitutions in the GSUB table
authorBen Harris <bjh21@bjh21.me.uk>
Wed, 6 Nov 2024 20:47:20 +0000 (20:47 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Thu, 14 Nov 2024 22:27:18 +0000 (22:27 +0000)
bedstead.c

index b82753bdbe4c489cd84057deaf2f00551346dc52..f1d073c3504d3c372b6ebc0b180a27bec0946ee8 100644 (file)
@@ -2661,9 +2661,9 @@ static void dopanose(void);
 static void docmap(int pid, int eid, int format);
 static void dogsub(void);
 static void doaltsubs(void);
+static void dosinglesubs(char const *suffix);
 static void glyph_complement(void);
 static void bdf_gen(int size);
-static void dolookups(struct glyph *);
 static void doglyph(struct glyph *);
 
 static bool
@@ -3084,32 +3084,6 @@ main(int argc, char **argv)
        /*      printf("StrokedFont: 1\n"); */
        /*      printf("StrokeWidth: 50\n"); */
        /* } */
-       /* printf("Lookup: 1 0 0 \"smcp: lower-case to small caps\" " */
-       /*     "{\"smcp\" (\"sc\")} " */
-       /*     "['smcp' ('latn' <'dflt'>)]\n"); */
-       /* printf("Lookup: 1 0 0 \"c2sc: upper-case to small caps\" " */
-       /*     "{\"c2sc\" (\"c2sc\")} " */
-       /*     "['c2sc' ('latn' <'dflt'>)]\n"); */
-       /* printf("Lookup: 1 0 0 \"rtlm: right-to-left mirrored forms\" " */
-       /*     "{\"rtlm\" (\"rtlm\")} " */
-       /*     "['rtlm' ('DFLT' <'dflt'> 'latn' <'dflt'>)]\n"); */
-       /* printf("Lookup: 1 0 0 \"ss01: SAA5051 forms\" {\"ss01\" (\"saa5051\")} " */
-       /*     "['ss01' ('DFLT' <'dflt'> 'latn' <'dflt'>)]\n"); */
-       /* printf("OtfFeatName: 'ss01' 1033 \"SAA5051\"\n"); */
-       /* printf("Lookup: 1 0 0 \"ss02: SAA5052 forms\" {\"ss02\" (\"saa5052\")} " */
-       /*     "['ss02' ('DFLT' <'dflt'> 'latn' <'dflt'>)]\n"); */
-       /* printf("OtfFeatName: 'ss02' 1033 \"SAA5052\"\n"); */
-       /* printf("Lookup: 1 0 0 \"ss04: SAA5054 forms\" {\"ss04\" (\"saa5054\")} " */
-       /*     "['ss04' ('DFLT' <'dflt'> 'latn' <'dflt'>)]\n"); */
-       /* printf("OtfFeatName: 'ss04' 1033 \"SAA5054\"\n"); */
-       /* printf("Lookup: 1 0 0 \"ss14: 4-cell separated graphics\" " */
-       /*        "{\"ss14\" (\"sep4\")} " */
-       /*     "['ss14' ('DFLT' <'dflt'> 'latn' <'dflt'>)]\n"); */
-       /* printf("OtfFeatName: 'ss14' 1033 \"4-cell separated graphics\"\n"); */
-       /* printf("Lookup: 1 0 0 \"ss16: 6-cell separated graphics\" " */
-       /*        "{\"ss16\" (\"sep6\")} " */
-       /*     "['ss16' ('DFLT' <'dflt'> 'latn' <'dflt'>)]\n"); */
-       /* printf("OtfFeatName: 'ss16' 1033 \"6-cell separated graphics\"\n"); */
        /* printf("Lookup: 257 0 0 \"palt: proportional metrics\" {\"palt\"} " */
        /*     "['palt' ('DFLT' <'dflt'> 'latn' <'dflt'>)]\n"); */
        for (i = 0; i < nglyphs; i++)
@@ -3380,6 +3354,7 @@ dogsub(void)
                        TTXI(LookupType, 1);
                        TTXI(LookupFlag, 0);
                        printf("     <SingleSubst>\n");
+                       dosinglesubs(gsub_features[i].suffix);
                        printf("     </SingleSubst>\n");
                }
                printf("    </Lookup>\n");
@@ -3416,6 +3391,21 @@ doaltsubs(void)
        }
 }
 
+/* Find all mappings for a single feature. */
+static void
+dosinglesubs(char const *suffix)
+{
+       int i;
+       char *dot;
+
+       for (i = 0; i < nglyphs; i++)
+               if ((dot = strchr(glyphs[i].name, '.')) != NULL &&
+                   strcmp(dot, suffix) == 0)
+                       printf("      <Substitution in='%.*s' out='%s'/>\n",
+                              (int)(dot - glyphs[i].name),
+                              glyphs[i].name, glyphs[i].name);
+}
+
 /* Emit a charstring for a glyph. */
 static void
 doglyph(struct glyph *g)
@@ -3469,44 +3459,6 @@ dopalt(struct glyph *g)
 }
 
 
-static void
-dolookups(struct glyph *g)
-{
-       char prefix[32];
-       struct glyph const **found, **gp;
-       size_t plen;
-       bool any_alt = false;
-
-       plen = sprintf(prefix, "%s.", g->name);
-       assert(plen < 32);
-
-       /* Look for related glyphs */
-       found = bsearch(&g, glyphs_by_name, nglyphs, sizeof(glyphs_by_name[0]),
-               &compare_glyphs_by_name);
-       assert(found != NULL);
-       for (gp = found + 1; gp < glyphs_by_name + nglyphs; gp++) {
-               if (strncmp(prefix, (*gp)->name, plen) != 0) break;
-               any_alt = true;
-               if (strcmp((*gp)->name + plen, "saa5051") == 0)
-                       printf("Substitution2: \"ss01\" %s\n", (*gp)->name);
-               if (strcmp((*gp)->name + plen, "saa5052") == 0)
-                       printf("Substitution2: \"ss02\" %s\n", (*gp)->name);
-               if (strcmp((*gp)->name + plen, "saa5054") == 0)
-                       printf("Substitution2: \"ss04\" %s\n", (*gp)->name);
-               if (strcmp((*gp)->name + plen, "sep4") == 0)
-                       printf("Substitution2: \"ss14\" %s\n", (*gp)->name);
-               if (strcmp((*gp)->name + plen, "sep6") == 0)
-                       printf("Substitution2: \"ss16\" %s\n", (*gp)->name);
-               if (strcmp((*gp)->name + plen, "sc") == 0)
-                       printf("Substitution2: \"smcp\" %s\n", (*gp)->name);
-               if (strcmp((*gp)->name + plen, "c2sc") == 0)
-                       printf("Substitution2: \"c2sc\" %s\n", (*gp)->name);
-               if (strcmp((*gp)->name + plen, "rtlm") == 0)
-                       printf("Substitution2: \"rtlm\" %s\n", (*gp)->name);
-       }
-       dopalt(g);
-}
-
 typedef struct vec {
        int x, y;
 } vec;