From: Ben Harris Date: Tue, 7 Jan 2025 22:37:19 +0000 (+0000) Subject: Generate ss0X substitutions less cleverly X-Git-Tag: bedstead-3.251~44 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=7658a55c8622beb8ab579a26f5447e5d6b3e8520;p=bedstead.git Generate ss0X substitutions less cleverly These substitutions are not generated from the glyphs table, but are specified statically. Rather than taking a table and transforming it into XML with C, we could just put the static XML in a string, which is much simpler. To avoid excessive simplicity, the string is generated by a pile of preprocessor macros. This causes no change to the output OTFs. --- diff --git a/bedstead.c b/bedstead.c index a3144f0..8632cae 100644 --- a/bedstead.c +++ b/bedstead.c @@ -2723,7 +2723,6 @@ static struct alt_sub_override { { "ugrave", { "ugrave.roundjoined", "ugrave.sc" } }, }; -#define MAXSUBS 10 static struct gsub_feature { char const *tag; #define SCRIPT_DFLT 0x01 @@ -2731,7 +2730,7 @@ static struct gsub_feature { #define SCRIPT_ALL 0x03 unsigned int scripts; char const *suffix; /* NULL for all alternative glyphs. */ - char const *subs[MAXSUBS]; /* Individual character substitutions. */ + char const *xml; /* Individual character substitutions. */ char const *name; struct alt_sub_override const *overrides; int noverrides; @@ -2741,19 +2740,26 @@ static struct gsub_feature { { "smcp", SCRIPT_LATN, .suffix = ".sc" }, { "c2sc", SCRIPT_LATN, .suffix = ".c2sc" }, { "rtlm", SCRIPT_ALL, .suffix = ".rtlm" }, +#define SINGLESUB(in, out) "\n" +#define SUFFIXSUB(base, suffix) SINGLESUB(base, base suffix) { "ss01", SCRIPT_ALL, .name = "SAA5051", - .subs = { "comma.left", "period.large", "colon.leftsmall", - "semicolon.left", "question.open", - "D.serif", "J.narrow", "L.narrow", - "j.serif", "t.small" } }, + .xml = "\n" SUFFIXSUB("comma", ".left") + SUFFIXSUB("period", ".large") SUFFIXSUB("colon", ".leftsmall") + SUFFIXSUB("semicolon", ".left") SUFFIXSUB("question", ".open") + SUFFIXSUB("D", ".serif") SUFFIXSUB("J", ".narrow") + SUFFIXSUB("L", ".narrow") SUFFIXSUB("j", ".serif") + SUFFIXSUB("t", ".small") "\n" }, { "ss02", SCRIPT_ALL, .name = "SAA5052", - .subs = { "comma.left", "period.large", "colon.leftsmall", - "semicolon.left", "question.open", - "D.narrow", "J.narrow", "L.narrow", - "j.serif", "t.small" } }, + .xml = "\n" SUFFIXSUB("comma", ".left") + SUFFIXSUB("period", ".large") SUFFIXSUB("colon", ".leftsmall") + SUFFIXSUB("semicolon", ".left") SUFFIXSUB("question", ".open") + SUFFIXSUB("D", ".narrow") SUFFIXSUB("J", ".narrow") + SUFFIXSUB("L", ".narrow") SUFFIXSUB("j", ".serif") + SUFFIXSUB("t", ".small") "\n" }, { "ss04", SCRIPT_ALL, .name = "SAA5054", - .subs = { "ugrave.roundjoined", "ocircumflex.large", - "ccedilla.angular" } }, + .xml = "\n" SUFFIXSUB("ugrave", ".roundjoined") + SUFFIXSUB("ocircumflex", ".large") SUFFIXSUB("ccedilla", ".angular") + "\n" }, { "ss14", SCRIPT_ALL, ".sep4", .name = "4-cell separated graphics" }, { "ss16", SCRIPT_ALL, ".sep6", .name = "6-cell separated graphics" }, }; @@ -3634,21 +3640,11 @@ dogsub(void) printf(" \n"); dosinglesubs(gsub_features[i].suffix); printf(" \n"); - } else if (gsub_features[i].subs[0] != NULL) { - /* Stylistic set of pick and mix glyphs. */ + } else if (gsub_features[i].xml != NULL) { + /* Raw XML for a substitution. */ TTXI("LookupType", 1); TTXI("LookupFlag", 0); - printf(" \n"); - for (int j = 0; j < MAXSUBS; j++) { - char const *sub = gsub_features[i].subs[j]; - if (sub == NULL) break; - char *dot = strchr(sub, '.'); - assert(dot != NULL); - printf(" " - "\n", - (int)(dot - sub), sub, sub); - } - printf(" \n"); + printf("%s", gsub_features[i].xml); } else { /* All possible alternative glyphs. */ TTXI("LookupType", 3);