chiark / gitweb /
Correct TTF names for bold faces
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 16 Oct 2021 15:04:47 +0000 (16:04 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 16 Oct 2021 19:06:33 +0000 (20:06 +0100)
Unlike other weights, "Bold" can be represented in the normal TTF
Family/Subfamily structure, so it should be put there.  To avoid making
the single printf call for LangName unbearably complex, I've split it
into two, one for the case where the typographic family/subfamily names
(16/17) differ from the basic ones, and one for when they don't.

bedstead.c

index c2b89d400e3fa1ae5ca0669860c3b31197169934..4079ca3a18d24d57d27bb629c62e7985b251de41 100644 (file)
@@ -2196,14 +2196,25 @@ main(int argc, char **argv)
        printf("FontName: %s\n", fullname_to_fontname(get_fullname()));
        printf("FullName: %s\n", get_fullname());
        printf("FamilyName: Bedstead\n");
-       printf("LangName: 1033 \"\" \"Bedstead%s%s\" \"%s\" \"\" \"\" \"\" "
-              "\"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" "
-              "\"%s\" \"%s%s\"\n\n", weight->suffix, width->suffix,
-              "Regular",
-              weight->suffix[0] || width->suffix[0] ? "Bedstead" : "",
-              weight->suffix[0] ? weight->suffix+1 : "",
-              weight->suffix[0] ? width->suffix :
-              width->suffix[0] ? width->suffix+1 : "");
+       if ((weight->ttfweight == 500 || weight->ttfweight == 700) &&
+           width->suffix[0] == '\0')
+               /* Normal width; regular or bold */
+               printf("LangName: 1033 \"\" \"Bedstead\" \"%s\"\n",
+                      weight->suffix[0] ? weight->suffix + 1 : "Regular");
+       else
+               /*
+                * Slightly unusual face, so we need to set the
+                * "Preferred" family and style.
+                */
+               printf("LangName: 1033 \"\" \"Bedstead%s%s\" \"%s\" \"\" \"\" "
+                      "\"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" "
+                      "\"\" \"Bedstead\" \"%s%s\"\n",
+                      weight->ttfweight == 700 ? "" : weight->suffix,
+                      width->suffix,
+                      weight->ttfweight == 700 ? weight->suffix+1 : "Regular",
+                      weight->suffix[0] ? weight->suffix+1 : "",
+                      weight->suffix[0] ? width->suffix :
+                      width->suffix[0] ? width->suffix+1 : "");
        printf("Weight:%s\n", weight->suffix[0] ? weight->suffix : " Medium");
        printf("OS2_WeightWidthSlopeOnly: 1\n");
        printf("Copyright: Dedicated to the public domain\n");