Add parameter labels for 'cvXX' features

This means that now each possible variant of a character covered by a
'cvXX' feature has a human-readable name.  I don't know of anything
that uses these, so they're somewhat untested.
This commit is contained in:
Ben Harris 2025-01-28 23:06:05 +00:00
parent 2e0b22b86f
commit 72fb39b706

View File

@ -2936,6 +2936,7 @@ static struct alt_sub_override {
V("uni1E28", ".angular") V("uni1E28.c2sc", ".angular") \
V("uni1E29", ".angular") V("uni1E29.sc", ".angular")
#define MAXSUBNAME 3
static struct gsub_feature {
char const *tag;
#define SCRIPT_DFLT 0x01
@ -2945,6 +2946,7 @@ static struct gsub_feature {
char const *suffix; /* NULL for all alternative glyphs. */
char const *xml; /* Individual character substitutions. */
char const *name;
char const *subnames[MAXSUBNAME];
struct alt_sub_override const *overrides;
int noverrides;
} const gsub_features[] = {
@ -2994,36 +2996,52 @@ static struct gsub_feature {
* that are 32 less than the ASCII code of the base character.
*/
{ "cv07", SCRIPT_ALL, .name = "apostrophe variants",
.subnames = { "straight", "curly" },
.xml = ALTSUB(CV07(CV)) },
{ "cv12", SCRIPT_ALL, .name = "comma variants",
.subnames = { "centred", "left" },
.xml = ALTSUB(CV12(CV)) },
{ "cv14", SCRIPT_ALL, .name = "full-stop variants",
.subnames = { "small", "large" },
.xml = ALTSUB(CV14(CV)) },
{ "cv26", SCRIPT_ALL, .name = "colon variants",
.subnames = { "centred/large", "left/small" },
.xml = ALTSUB(CV26(CV)) },
{ "cv27", SCRIPT_ALL, .name = "semicolon variants",
.subnames = { "centred", "left" },
.xml = ALTSUB(CV27(CV)) },
{ "cv31", SCRIPT_ALL, .name = "question-mark variants",
.subnames = { "standard", "open" },
.xml = ALTSUB(CV31(CV)) },
{ "cv38", SCRIPT_ALL, .name = "capital-D variants",
.subnames = { "standard", "with serifs", "narrow" },
.xml = ALTSUB(CV38(CV)) },
{ "cv42", SCRIPT_ALL, .name = "capital-J variants",
.subnames = { "wide", "narrow" },
.xml = ALTSUB(CV42(CV)) },
{ "cv44", SCRIPT_ALL, .name = "capital-L variants",
.subnames = { "wide", "narrow" },
.xml = ALTSUB(CV44(CV)) },
{ "cv61", SCRIPT_ALL, .name = "small-u-grave variants",
.subnames = { "standard", "SAA5054" },
.xml = ALTSUB(CV61(CV)) },
{ "cv64", SCRIPT_ALL, .name = "grave variants",
.subnames = { "diagonal", "curly" },
.xml = ALTSUB(CV64(CV)) },
{ "cv74", SCRIPT_ALL, .name = "small-j variants",
.subnames = { "sans-serif", "with serif" },
.xml = ALTSUB(CV74(CV)) },
{ "cv79", SCRIPT_ALL, .name = "small-o variants",
{ "cv79", SCRIPT_ALL, .name = "accented small-o variants",
.subnames = { "small", "large" },
.xml = ALTSUB(CV79(CV)) },
{ "cv84", SCRIPT_ALL, .name = "small-t variants",
.subnames = { "large", "small" },
.xml = ALTSUB(CV84(CV)) },
{ "cv92", SCRIPT_ALL, .name = "vertical-bar variants",
.subnames = { "solid", "broken" },
.xml = ALTSUB(CV92(CV)) },
{ "cv96", SCRIPT_ALL, .name = "cedilla variants",
.subnames = { "standard", "angular" },
.xml = ALTSUB(CV96(CV)) },
{ "ss14", SCRIPT_ALL, ".sep4", .name = "4-cell separated graphics" },
{ "ss16", SCRIPT_ALL, ".sep6", .name = "6-cell separated graphics" },
@ -3583,9 +3601,15 @@ main(int argc, char **argv)
NAME(6, fullname_to_fontname(get_fullname()));
/* Stylistic set names. */
#define NAMEBASE_GSUB 0x100
for (i = 0; i < ngsub_features; i++)
#define NAMEBASE_GSUB_SUB 0x200
for (i = 0; i < ngsub_features; i++) {
if (gsub_features[i].name != NULL)
NAME(NAMEBASE_GSUB + i, gsub_features[i].name);
for (int j = 0; j < MAXSUBNAME; j++)
if (gsub_features[i].subnames[j] != NULL)
NAME(NAMEBASE_GSUB_SUB + MAXSUBNAME * i + j,
gsub_features[i].subnames[j]);
}
printf("</name>\n");
printf("<post>\n");
@ -3890,13 +3914,18 @@ dogsub(void)
TTXI("UINameID", NAMEBASE_GSUB + i);
printf("</FeatureParamsStylisticSet>\n");
} else {
int nparam = 0;
while (nparam < MAXSUBNAME &&
gsub_features[i].subnames[nparam])
nparam++;
printf("<FeatureParamsCharacterVariants>\n");
TTXI("Format", 0);
TTXI("FeatUILabelNameID", NAMEBASE_GSUB + i);
TTXI("FeatUITooltipTextNameID", 0);
TTXI("SampleTextNameID", 0);
TTXI("NumNamedParameters", 0);
TTXI("FirstParamUILabelNameID", 0);
TTXI("NumNamedParameters", nparam);
TTXI("FirstParamUILabelNameID",
NAMEBASE_GSUB_SUB + MAXSUBNAME * i);
printf("</FeatureParamsCharacterVariants>\n");
}
}