chiark / gitweb /
Emit OpenType tables in a more logical order
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 16 Nov 2024 11:22:21 +0000 (11:22 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 16 Nov 2024 11:53:04 +0000 (11:53 +0000)
TTX doesn't actually care what order we emit tables in: it will always
put them into the recommended order.  So I've made the order something
that works correctly and that doesn't look too silly in TTX's console
output.

bedstead.c

index e7f0aaab40c5dc4f998407076955aeb2f8393c96..13e6ca5c2adf44df5ec43f799e1233694636f502 100644 (file)
@@ -3101,13 +3101,6 @@ main(int argc, char **argv)
                        NAME(NAMEBASE_GSUB + i, gsub_features[i].name);
        printf(" </name>\n");
 
-       printf(" <cmap><tableVersion version='0'/>\n");
-       docmap(0, 3, 4);   /* Unicode 2.0+, BMP only */
-       docmap(0, 4, 12);  /* Unicode 2.0+, full repertoire */
-       docmap(3, 1, 4);   /* Windows Unicode, BMP only */
-       docmap(3, 10, 12); /* Windows Unicode, full repertoire */
-       printf(" </cmap>\n");
-
        printf(" <post>\n");
        TTXS("formatType", "3.0");
        TTXS("italicAngle", "0.0");
@@ -3123,7 +3116,20 @@ main(int argc, char **argv)
        qsort(glyphs_by_name, nglyphs, sizeof(glyphs_by_name[0]),
              &compare_glyphs_by_name);
 
+       printf(" <GlyphOrder>\n");
+       for (i = 0; i < nglyphs; i++)
+               printf("  <GlyphID name='%s'/>\n", glyphs[i].name);
+       printf(" </GlyphOrder>\n");
+
+       printf(" <cmap><tableVersion version='0'/>\n");
+       docmap(0, 3, 4);   /* Unicode 2.0+, BMP only */
+       docmap(0, 4, 12);  /* Unicode 2.0+, full repertoire */
+       docmap(3, 1, 4);   /* Windows Unicode, BMP only */
+       docmap(3, 10, 12); /* Windows Unicode, full repertoire */
+       printf(" </cmap>\n");
+
        dogpos(); /* Must be before 'CFF ' because it uses glyph bitmaps. */
+       dogsub();
 
        printf(" <CFF>\n");
        TTXI("major", 1); TTXI("minor", 0);
@@ -3182,17 +3188,12 @@ main(int argc, char **argv)
        printf("   </CharStrings>\n");
        printf("  </CFFFont>\n");
        printf(" </CFF>\n");
-       printf(" <GlyphOrder>\n");
-       for (i = 0; i < nglyphs; i++)
-               printf("  <GlyphID name='%s'/>\n", glyphs[i].name);
-       printf(" </GlyphOrder>\n");
        printf(" <hmtx>\n");
        for (i = 0; i < nglyphs; i++)
                printf("  <mtx name='%s' width='%d' lsb='%d'/>\n",
                       glyphs[i].name, (int)(XSIZE * XPIX),
                       (int)realglyph(&glyphs[i])->left_sidebearing);
        printf(" </hmtx>\n");
-       dogsub();
        printf("</ttFont>\n");
        return EXIT_SUCCESS;
 }