This thing got under my skin, and I wanted to find it. I did.
In an init routine gs pulls in all the fonts into an array; it then iteratively calls a routine to process through the array one font at a time, returning 1 when a font has been processed. When it is through it returns 0, and once that happens the iterator will not be called again.
Significantly, the iterator also return 0 on errors, and it finds two, both because the font weight did not match what was expected. Once it finds a font with an error processing stops, and everything unprocessed in the list is abandoned. That is why some fonts were not being found; they just happened to fall after the first error.
I rebuilt gs from its source package and made a few debug changes to find all this. After commenting the 0 returns on errors, the process runs to completion and the desired font is found.
The FC routine called from gs to get the weight is this:
result = FcPatternGetInteger (font, FC_WEIGHT, 0, &weight_fc);
My debug messages, slightly modified from the gs debug messages:
FC_WEIGHT failed to match on Bahnschrift (and Skia)
FC_WEIGHT failed to match on 32764
weight_fc is an int where the result is stored; that is what is showing 32764 upon return.
I don’t know the significance of the weight reported as 32764 (0x7FFC), or where it might be found in the font file. fc-match reports different weight numbers, 80 for Bahnschrift and 0.5 for Skia. These two fonts errored with the weight = 0x7ffc; I will post the output of fc-match for one below, for what it may be worth.
From the fontconfig source, it looks like the weight must be between 1 and 1000; that would explain the error, but not why these two fonts have such a strange number.
I quickly become tangled in FC’s fc_pat.c, which is where most of this seems to happen. I am not sure what an ELT is (element?) is; I found where it is retrieved by indexing into some data structure, but I don’t know what that is.
So my question is, what might be happening with these two fonts? Does anyone knowledgeable about FC recognize why the weight would be reported wrongly for these two fonts?
Thanks much in advance for any help you can offer.
# fc-match -v Bahnschrift
Pattern has 36 elts (size 48)
foundry: "MS "(w)
0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffffff ffffffff ffffffff
0001: cfcffcff 7ec3cccf cfff3dfe 7f0ffc3f 0317c642 009d8003 20000000 00000000
0002: 0f000000 00000000 0ad80000 00000000 00000000 18000000 3b0002c0 00000000
0003: 08001fdf 002001c8 00000020 fcff0000 ffffd7f0 fffffffb ffffffff ffffffff
0004: ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
0005: 00000000 00000030 00000000 00000000 00000000 00000000 00000000 00000000
001e: 00000000 00000000 00000000 0000000c 00000000 03000003 00003c00 00000030
0020: 77380000 06010047 00000000 00110000 00000000 7fffffff 00000000 00000000
0021: 00400000 00080004 00000000 00000000 00000000 00000000 00000000 00000000
capability: "otlayout:DFLT otlayout:latn"(w)