fc-query complains "Can't query face 0 of font file" when try to fc-query with the PCF fonts and the BDF fonts, such as http://download.fedora.redhat.com/pub/fedora/linux/development/i386/os/Packages/knm_new-fonts-1.1-5.fc11.noarch.rpm contains.
Created attachment 30582 [details] [review]
That looks like a typo:
In FcFreeTypeQueryFace at src/fcfreetype.c:
1681: if (FcCharSetCount (cs) == 0)
1684: if(FT_Get_BDF_Property(face, "PIXEL_SIZE", &prop) == 0)
1685: goto bail2;
in freetype, the return code 0 means "no error". so it should be "!=".
After applying the patch:
% fc-query knm12p.pcf.gz
Pattern has 17 elts (size 32)
Reading the comment before that block of code suggests that the code is correct in its current form:
* Skip over PCF fonts that have no encoded characters; they're
* usually just Unicode fonts transcoded to some legacy encoding
* FT forces us to approximate whether a font is a PCF font
* or not by whether it has any BDF properties. Try PIXEL_SIZE;
* I don't know how to get a list of BDF properties on the font. -PL
if (FcCharSetCount (cs) == 0)
if(FT_Get_BDF_Property(face, "PIXEL_SIZE", &prop) == 0)
Indeed, in the pattern you got after modifying that line, you see that charset is empty, that is, fontconfig could not recognize any character in the font and hence the face is useless. That's why fontconfig skips it. Sounds like NOTABUG to me. What kind of font is this?
(In reply to comment #3)
> Indeed, in the pattern you got after modifying that line, you see that charset
> is empty, that is, fontconfig could not recognize any character in the font and
> hence the face is useless. That's why fontconfig skips it. Sounds like
> NOTABUG to me. What kind of font is this?
It's a Japanese bitmap font. so fontconfig is just checking to skip the broken BDF/PCF fonts highly likely not having any charset detected? I see - I don't still see there are any useful cases not skipping non-BDF/PCF fonts that has no charsets though.
However the assumption as described at that comment isn't necessarily true. Since it was available before we are moving to Unicode, most BDF/PCF fonts available in the world should be encoded by "none". but just put glyphs with the glyph IDs for the charset. in fact, it does in this case.
FreeType is (internally) capable to add any CMaps that is used to look up the glyph ID from the character code though, no exported FT_CMap structure. if adding the own CMap to transcode Unicode to the charset, it may works as expected without modifying the application code. but I guess fontconfig won't support such fonts so far, because fontconfig and other rendering library focuses on Unicode only and using the internal APIs doesn't make sense?
The correct solution is probably to write a filter that adds the freetype info to the font files, so they become normal unicody fonts any font libe can use.
Then the fc-query error can be modified to just point people to this filter.
I don't think Fedora should ship fonts that can not be used in fontconfig at this stage. If they can't be fixed easily, I'd say just drop them.
Behdad, since we have a feature to update charset from the config file, can you reconsider this issue to keep open and patch out to reject the charset-empty fonts but not simply reject the bdf fonts not having PIXEL_SIZE property?
Not really. That's too broken a font to support. Plus, mapping chars to glyphs wouldn't work anyway. Either fix the font, or fix freetype/fontconfig to work. No bandaids.
just tried to write a demonstration code to be able to recognize non-Unicode encoded PCF/BDF fonts. I didn't write up the core function to convert "encoding-registry" to Unicode, because.. well, just wonder if we should really support in fontconfig. probably we should rather get rid of it completely from the world.
just a note for those who is interested in it.
on Mar 24, 2017 at 19:58:49.
(provided by the Example extension).