chiark / gitweb /
Add a 'salt' feature for the characters that vary between chips, though
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 10 Oct 2009 22:11:53 +0000 (23:11 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 10 Oct 2009 22:11:53 +0000 (23:11 +0100)
I wonder if it really ought to be 'locl'.

ttxt.c

diff --git a/ttxt.c b/ttxt.c
index 3b49f6d7b9a92ee73082e2c360a1b3ff7a619ef6..0db0143d80b077128f4cf5af484714c93c0fbb96 100644 (file)
--- a/ttxt.c
+++ b/ttxt.c
@@ -123,6 +123,7 @@ struct glyph {
        char const *name;
        unsigned int flags;
 #define SC  0x01 /* Character has a small-caps variant. */
+#define SA  0x02 /* Character has a stylistic alternate (%s.alt) */
 /* Arabic classes */
 #define ARX 0x100 /* Arabic glyph joins to the right */
 #define ALX 0x200 /* Arabic glyph joins to the left */
@@ -150,9 +151,9 @@ struct glyph {
  {{010,004,002,002,002,004,010,000,000}, 0x0029, "parenright" },
  {{004,025,016,004,016,025,004,000,000}, 0x002a, "asterisk" },
  {{000,004,004,037,004,004,000,000,000}, 0x002b, "plus" },
- {{000,000,000,000,000,004,004,010,000}, 0x002c, "comma" },
+ {{000,000,000,000,000,004,004,010,000}, 0x002c, "comma", SA },
  {{000,000,000,016,000,000,000,000,000}, 0x002d, "hyphen" },
- {{000,000,000,000,000,000,004,000,000}, 0x002e, "period" },
+ {{000,000,000,000,000,000,004,000,000}, 0x002e, "period", SA },
  {{000,001,002,004,010,020,000,000,000}, 0x002f, "slash" },
  {{004,012,021,021,021,012,004,000,000}, 0x0030, "zero" },
  {{004,014,004,004,004,004,016,000,000}, 0x0031, "one" },
@@ -164,8 +165,8 @@ struct glyph {
  {{037,001,002,004,010,010,010,000,000}, 0x0037, "seven" },
  {{016,021,021,016,021,021,016,000,000}, 0x0038, "eight" },
  {{016,021,021,017,001,002,014,000,000}, 0x0039, "nine" },
- {{000,000,004,000,000,000,004,000,000}, 0x003a, "colon" },
- {{000,000,004,000,000,004,004,010,000}, 0x003b, "semicolon" },
+ {{000,000,004,000,000,000,004,000,000}, 0x003a, "colon", SA },
+ {{000,000,004,000,000,004,004,010,000}, 0x003b, "semicolon", SA },
  {{002,004,010,020,010,004,002,000,000}, 0x003c, "less" },
  {{000,000,037,000,037,000,000,000,000}, 0x003d, "equal" },
  {{010,004,002,001,002,004,010,000,000}, 0x003e, "greater" },
@@ -174,7 +175,7 @@ struct glyph {
  {{004,012,021,021,037,021,021,000,000}, 0x0041, "A", SC },
  {{036,021,021,036,021,021,036,000,000}, 0x0042, "B", SC },
  {{016,021,020,020,020,021,016,000,000}, 0x0043, "C", SC },
- {{036,021,021,021,021,021,036,000,000}, 0x0044, "D", SC },
+ {{036,021,021,021,021,021,036,000,000}, 0x0044, "D", SC|SA },
  {{037,020,020,036,020,020,037,000,000}, 0x0045, "E", SC },
  {{037,020,020,036,020,020,020,000,000}, 0x0046, "F", SC },
  {{016,021,020,020,023,021,017,000,000}, 0x0047, "G", SC },
@@ -182,7 +183,7 @@ struct glyph {
  {{016,004,004,004,004,004,016,000,000}, 0x0049, "I", SC },
  {{001,001,001,001,001,021,016,000,000}, 0x004a, "J", SC },
  {{021,022,024,030,024,022,021,000,000}, 0x004b, "K", SC },
- {{020,020,020,020,020,020,037,000,000}, 0x004c, "L", SC },
+ {{020,020,020,020,020,020,037,000,000}, 0x004c, "L", SC|SA },
  {{021,033,025,025,021,021,021,000,000}, 0x004d, "M", SC },
  {{021,021,031,025,023,021,021,000,000}, 0x004e, "N", SC },
  {{016,021,021,021,021,021,016,000,000}, 0x004f, "O", SC },
@@ -238,10 +239,10 @@ struct glyph {
  /* Extra characters found in the English (SAA5050) character set */
  {{006,011,010,034,010,010,037,000,000}, 0x00a3, "sterling" },
  {{004,004,004,000,000,000,000,000,000}, 0x0027, "quotesingle" },
- {{000,004,010,037,010,004,000,000,000}, 0x2190, "arrowleft" },
+ {{000,004,010,037,010,004,000,000,000}, 0x2190, "arrowleft", SA },
  {{020,020,020,020,026,001,002,004,007}, 0x00bd, "onehalf" },
- {{000,004,002,037,002,004,000,000,000}, 0x2192, "arrowright" },
- {{000,004,016,025,004,004,000,000,000}, 0x2191, "arrowup" },
+ {{000,004,002,037,002,004,000,000,000}, 0x2192, "arrowright", SA },
+ {{000,004,016,025,004,004,000,000,000}, 0x2191, "arrowup", SA },
  {{000,000,000,037,000,000,000,000,000}, 0x2013, "endash" },
  {{010,010,010,010,011,003,005,007,001}, 0x00bc, "onequarter" },
  {{012,012,012,012,012,012,012,000,000}, 0x2016, "dblverticalbar" },
@@ -266,15 +267,15 @@ struct glyph {
  /* Extra characters found in the Swedish (SAA5052) character set */
  {{000,000,021,016,012,016,021,000,000}, 0x00a4, "currency" },
  {{002,004,037,020,036,020,037,000,000}, 0x00c9, "Eacute" },
- {{016,011,011,011,011,011,016,000,000}, -1, "D.alt" },
- {{010,010,010,010,010,010,017,000,000}, -1, "L.alt" },
+ {{016,011,011,011,011,011,016,000,000}, -1, "D.alt", SC },
+ {{010,010,010,010,010,010,017,000,000}, -1, "L.alt", SC },
  {{004,000,016,021,037,021,021,000,000}, 0x00c5, "Aring" },
  {{002,004,016,021,037,020,016,000,000}, 0x00e9, "eacute" },
  {{004,000,016,001,017,021,017,000,000}, 0x00e5, "aring" },
 
  /* Extra characters found in the Italian (SAA5053) character set */
- {{000,000,017,020,020,020,017,002,004}, 0x00e7, "ccedilla" },
- {{010,004,021,021,021,021,017,000,000}, 0x00f9, "ugrave" },
+ {{000,000,017,020,020,020,017,002,004}, 0x00e7, "ccedilla", SA },
+ {{010,004,021,021,021,021,017,000,000}, 0x00f9, "ugrave", SA },
  {{010,004,016,001,017,021,017,000,000}, 0x00e0, "agrave" },
  {{010,004,000,016,021,021,016,000,000}, 0x00f2, "ograve" },
  {{010,004,016,021,037,020,016,000,000}, 0x00e8, "egrave" },
@@ -302,18 +303,18 @@ struct glyph {
  {{000,037,021,021,021,021,021,000,000}, 0x05d7 }, /* het */
  {{000,021,023,025,021,021,037,000,000}, 0x05d8 }, /* tet */
  {{000,014,004,000,000,000,000,000,000}, 0x05d9 }, /* yod */
- {{000,037,001,001,001,001,001,001,000}, 0x05da }, /*kaffinal*/
+ {{000,037,001,001,001,001,001,001,000}, 0x05da }, /* kaffinal */
  {{000,037,001,001,001,001,037,000,000}, 0x05db }, /* kaf */
  {{020,037,001,001,001,002,014,000,000}, 0x05dc }, /* lamed */
- {{000,037,021,021,021,021,037,000,000}, 0x05dd }, /*memfinal*/
+ {{000,037,021,021,021,021,037,000,000}, 0x05dd }, /* memfinal */
  {{000,026,011,021,021,021,027,000,000}, 0x05de }, /* mem */
- {{000,014,004,004,004,004,004,004,004}, 0x05df }, /*nunfinal*/
+ {{000,014,004,004,004,004,004,004,004}, 0x05df }, /* nunfinal */
  {{000,006,002,002,002,002,016,000,000}, 0x05e0 }, /* nun */
  {{000,037,011,021,021,021,016,000,000}, 0x05e1 }, /* samekh */
  {{000,011,011,011,011,012,034,000,000}, 0x05e2 }, /* ayin */
- {{000,037,011,015,001,001,001,001,000}, 0x05e3 }, /* pefinal*/
+ {{000,037,011,015,001,001,001,001,000}, 0x05e3 }, /* pefinal */
  {{000,037,011,015,001,001,037,000,000}, 0x05e4 }, /* pe */
- {{000,031,012,014,010,010,010,010,000}, 0x05e5 }, /*tsadifin*/
+ {{000,031,012,014,010,010,010,010,000}, 0x05e5 }, /* tsadifinal */
  {{000,021,021,012,004,002,037,000,000}, 0x05e6 }, /* tsadi */
  {{000,037,001,011,011,012,010,010,000}, 0x05e7 }, /* qof */
  {{000,037,001,001,001,001,001,000,000}, 0x05e8 }, /* resh */
@@ -504,7 +505,7 @@ struct glyph {
  {{011,011,022,000,000,000,000,000,000}, 0x201d, "quotedblright" },
  {{000,000,000,000,000,011,011,022,000}, 0x201e, "quotedblbase" },
  {{022,022,011,000,000,000,000,000,000}, 0x201f }, /* quotedblreversed */
- {{000,004,004,025,016,004,000,000,000}, 0x2193, "arrowdown" },
+ {{000,004,004,025,016,004,000,000,000}, 0x2193, "arrowdown", SA },
  {{000,004,010,023,010,004,000,000,000}, -1, "arrowleft.alt" },
  {{000,004,002,031,002,004,000,000,000}, -1, "arrowright.alt" },
  {{000,004,012,021,004,004,000,000,000}, -1, "arrowup.alt" },
@@ -597,6 +598,10 @@ main(int argc, char **argv)
        printf("EndPrivate\n");
        /* Force monochrome at 10 and 20 pixels, and greyscale elsewhere. */
        printf("GaspTable: 5 9 2 10 0 19 3 20 0 65535 3\n");
+       printf("Lookup: 1 0 0 \"salt: stylistic alternates\" {\"salt\"} "
+           "['salt' ('DFLT' <'dflt'>)]\n");
+       printf("Lookup: 3 0 0 \"aalt: all alternates\" {\"aalt\"} "
+           "['aalt' ('DFLT' <'dflt'>)]\n");
        printf("Lookup: 1 0 0 \"smcp: lower-case to small caps\" {\"smcp\"} "
            "['smcp' ('latn' <'dflt'>)]\n");
        printf("Lookup: 1 0 0 \"c2sc: upper-case to small caps\" {\"c2sc\"} "
@@ -639,26 +644,31 @@ dolookups(struct glyph *g)
        else
                sprintf(glyphname, "uni%04X", g->unicode);
 
+       if ((g->flags & SA))
+               printf("Substitution2: \"salt\" %s.alt\n", glyphname);
        if ((g->flags & SC))
                printf("Substitution2: \"%s\" %c%s.sc\n",
-                   isupper((unsigned char)g->name[0]) ?
-                   "c2sc" : "smcp",
-                   tolower((unsigned char)g->name[0]),
-                   g->name + 1);
+                   isupper((unsigned char)glyphname[0]) ? "c2sc" : "smcp",
+                   tolower((unsigned char)glyphname[0]), g->name + 1);
+       if ((g->flags & (SA))) {
+               printf("AlternateSubs2: \"aalt\"");
+               if ((g->flags & SA)) printf(" %s.alt", glyphname);
+               printf("\n");
+       }
        switch (g->flags & Amask) {
-       case A1:
+       case A1 & Amask:
                printf("MultipleSubs2: \"tails\" %s tail1\n",
                        glyphname);
                break;
-       case A2:
+       case A2 & Amask:
                printf("MultipleSubs2: \"tails\" %s tail2\n",
                        glyphname);
                break;
-       case A3:
+       case A3 & Amask:
                printf("MultipleSubs2: \"tails\" %s tail3\n",
                        glyphname);
                break;
-       case AFI:
+       case AFI & Amask:
                printf("Substitution2: \"finaisol\" %s.fina\n",
                        glyphname);
                        break;