Bug 24613 - fc-query can't query face 0
Summary: fc-query can't query face 0
Status: RESOLVED NOTOURBUG
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: 2.7
Hardware: All All
: medium normal
Assignee: Behdad Esfahbod
QA Contact: Keith Packard
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-19 01:33 UTC by Akira TAGOH
Modified: 2012-05-09 01:15 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
proposed patch (521 bytes, patch)
2009-10-20 01:39 UTC, Akira TAGOH
Details | Splinter Review

Description Akira TAGOH 2009-10-19 01:33:45 UTC
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.
Comment 1 Akira TAGOH 2009-10-20 01:39:36 UTC
Created attachment 30582 [details] [review]
proposed patch

That looks like a typo:

In FcFreeTypeQueryFace at src/fcfreetype.c:
---------------------------------------
 1681:    if (FcCharSetCount (cs) == 0)
 1682:    {
 1683:#if HAVE_FT_GET_BDF_PROPERTY
 1684:        if(FT_Get_BDF_Property(face, "PIXEL_SIZE", &prop) == 0)
 1685:            goto bail2;
 1686:#endif
 1687:    }
---------------------------------------

in freetype, the return code 0 means "no error". so it should be "!=".
Comment 2 Akira TAGOH 2009-10-20 01:41:55 UTC
After applying the patch:

% fc-query knm12p.pcf.gz
Pattern has 17 elts (size 32)
        family: "Fixed"(s)
        style: "Regular"(s)
        slant: 0(i)(s)
        weight: 80(i)(s)
        width: 100(i)(s)
        pixelsize: 12(f)(s)
        foundry: "MNKANAME"(s)
        antialias: FcFalse(s)
        file: "knm12p.pcf.gz"(s)
        index: 0(i)(s)
        outline: FcFalse(s)
        scalable: FcFalse(s)
        charset: (s)
        lang: (s)
        fontversion: 0(i)(s)
        fontformat: "PCF"(s)
        decorative: FcFalse(s)
Comment 3 Behdad Esfahbod 2009-10-21 15:53:40 UTC
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 HAVE_FT_GET_BDF_PROPERTY
        if(FT_Get_BDF_Property(face, "PIXEL_SIZE", &prop) == 0)
            goto bail2;
#endif
    }


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?
Comment 4 Akira TAGOH 2009-10-21 23:37:27 UTC
(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?
Comment 5 Nicolas Mailhot 2009-10-22 00:31:46 UTC
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.
Comment 6 Akira TAGOH 2011-05-19 04:31:32 UTC
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?
Comment 7 Behdad Esfahbod 2011-05-19 11:12:47 UTC
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.
Comment 8 Akira TAGOH 2012-05-09 01:15:14 UTC
http://cgit.freedesktop.org/~tagoh/fontconfig/commit/?h=bz24613

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.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.