chiark / gitweb /
Add cvXX (character variant) lookups
authorBen Harris <bjh21@bjh21.me.uk>
Wed, 8 Jan 2025 21:15:53 +0000 (21:15 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Wed, 8 Jan 2025 21:15:53 +0000 (21:15 +0000)
The idea of these is that each one allows for choosing between different
variants of a single character (or set of closely-related characters).
This allows for deciding that you want (for instance) the angular
SAA5054 "ccedilla", but not its weird conjoined "ugrave".

This seems like a good way to handle chips like the SN74S262 where some
samples seem to vary in a single character from others, as well as more
generally for making the variant glyphs easily accessible for purposes
other than precise emulation.

At the moment, each feature only provides alternatives for a single
character, but now that we have a mechanism for it, that might change.

bedstead.c

index 31f46e61daf7398af6608852be4639a83c639935..52cb01643b4d90386d23681fe00c1ef1f053d2f7 100644 (file)
@@ -2760,6 +2760,31 @@ static struct gsub_feature {
          .xml = "<SingleSubst>\n" SUFFIXSUB("ugrave", ".roundjoined")
          SUFFIXSUB("ocircumflex", ".large") SUFFIXSUB("ccedilla", ".angular")
          "</SingleSubst>\n" },
+#define ALT1(g) "<Alternate glyph='" g "'/>"
+#define ALT2(a, b) ALT1(a) ALT1(b)
+#define ALT3(a, b, c) ALT1(a) ALT2(b, c)
+#define ALTSET(g, a) "<AlternateSet glyph='" g "'>" a "</AlternateSet>\n"
+#define ALTSUB(x) "<AlternateSubst>\n" x "</AlternateSubst>\n"
+#define CROSSALT2(a, b) ALTSUB(ALTSET(a, ALT2(a, b)) ALTSET(b, ALT2(a, b)))
+#define CROSSALT3(a, b, c)                     \
+       ALTSUB(ALTSET(a, ALT3(a, b, c))         \
+              ALTSET(b, ALT3(a, b, c))         \
+              ALTSET(c, ALT3(a, b, c)))
+#define CV2(base, a) CROSSALT2(base, base a)
+#define CV3(base, a, b) CROSSALT3(base, base a, base b)
+       { "cv12", SCRIPT_ALL, .xml = CV2("comma", ".left") },
+       { "cv14", SCRIPT_ALL, .xml = CV2("period", ".large") },
+       { "cv26", SCRIPT_ALL, .xml = CV2("colon", ".leftsmall") },
+       { "cv27", SCRIPT_ALL, .xml = CV2("semicolon", ".left") },
+       { "cv31", SCRIPT_ALL, .xml = CV2("question", ".open") },
+       { "cv38", SCRIPT_ALL, .xml = CV3("D", ".serif", ".narrow") },
+       { "cv42", SCRIPT_ALL, .xml = CV2("J", ".narrow") },
+       { "cv44", SCRIPT_ALL, .xml = CV2("L", ".narrow") },
+       { "cv61", SCRIPT_ALL, .xml = CV2("ugrave",".roundjoined") },
+       { "cv74", SCRIPT_ALL, .xml = CV2("j", ".serif") },
+       { "cv84", SCRIPT_ALL, .xml = CV2("t", ".small") },
+       { "cv92", SCRIPT_ALL, .xml = CV2("ocircumflex", ".large") },
+       { "cv94", SCRIPT_ALL, .xml = CV2("ccedilla", ".angular") },
        { "ss14", SCRIPT_ALL,  ".sep4", .name = "4-cell separated graphics" },
        { "ss16", SCRIPT_ALL,  ".sep6", .name = "6-cell separated graphics" },
 };