From: Ben Harris Date: Sat, 28 Mar 2020 22:47:57 +0000 (+0000) Subject: Make the 'aalt' lookup work properly X-Git-Tag: bedstead-002.001~5 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=54d595b850a6a3fbd347ff08a8582a26734edce1;p=bedstead-debian.git Make the 'aalt' lookup work properly 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. --- diff --git a/bedstead.c b/bedstead.c index 68c456e..9811adb 100644 --- a/bedstead.c +++ b/bedstead.c @@ -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); }