chiark / gitweb /
Make the 'aalt' lookup work properly
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 28 Mar 2020 22:47:57 +0000 (22:47 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 28 Mar 2020 22:47:57 +0000 (22:47 +0000)
Emitting a separate "AlternateSubs2" line for each target doesn't work
properly, so we make a second pass over the alternates for the current
glyph, constructing a single "AlternateSubs2" line afer doing all the
"Substitution2"s.

bedstead.c

index 68c456eb32924995a95edf3e614a7101c816ceec..9811adb815c90fcfff00eec7aff8d17d7ec49ee4 100644 (file)
@@ -2130,8 +2130,9 @@ static void
 dolookups(struct glyph const *g)
 {
        char prefix[32];
-       struct glyph const **found;
+       struct glyph const **found, **gp;
        size_t plen;
+       bool any_alt = false;
 
        plen = sprintf(prefix, "%s.", g->name);
        assert(plen < 32);
@@ -2140,30 +2141,29 @@ dolookups(struct glyph const *g)
        found = bsearch(&g, glyphs_by_name, nglyphs, sizeof(glyphs_by_name[0]),
                &compare_glyphs_by_name);
        assert(found != NULL);
-       for (found++; found < glyphs_by_name + nglyphs; found++) {
-               if ((*found)->name &&
-                   strncmp(prefix, (*found)->name, plen) == 0) {
-                       if (strcmp((*found)->name + plen, "saa5051") == 0)
-                               printf("Substitution2: \"ss01\" %s\n",
-                                      (*found)->name);
-                       if (strcmp((*found)->name + plen, "saa5052") == 0)
-                               printf("Substitution2: \"ss02\" %s\n",
-                                      (*found)->name);
-                       if (strcmp((*found)->name + plen, "saa5054") == 0)
-                               printf("Substitution2: \"ss04\" %s\n",
-                                      (*found)->name);
-                       if (strcmp((*found)->name + plen, "sep6") == 0)
-                               printf("Substitution2: \"ss16\" %s\n",
-                                      (*found)->name);
-                       if (strcmp((*found)->name + plen, "sc") == 0)
-                               printf("Substitution2: \"smcp\" %s\n",
-                                      (*found)->name);
-                       if (strcmp((*found)->name + plen, "c2sc") == 0)
-                               printf("Substitution2: \"c2sc\" %s\n",
-                                      (*found)->name);
-                       printf("AlternateSubs2: \"aalt\" %s\n",
-                              (*found)->name);
-               } else break;
+       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, "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 (any_alt) {
+               printf("AlternateSubs2: \"aalt\"");
+               for (gp = found + 1; gp < glyphs_by_name + nglyphs; gp++) {
+                       if (strncmp(prefix, (*gp)->name, plen) != 0) break;
+                       printf(" %s", (*gp)->name);
+               }
+               printf("\n");
        }
        dopalt(g);
 }