Bug 63922 - FcFreeTypeQueryFace fails on postscripts fonts loaded from memory
Summary: FcFreeTypeQueryFace fails on postscripts fonts loaded from memory
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: unspecified
Hardware: Other All
: medium major
Assignee: Akira TAGOH
QA Contact: Behdad Esfahbod
Depends on:
Reported: 2013-04-25 14:21 UTC by nfxjfg
Modified: 2013-05-20 08:07 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Description nfxjfg 2013-04-25 14:21:24 UTC
Trying to use a PostScript Type 1 font with FcFreeTypeQueryFace() fails. The function returns NULL.

It appears the reason is that FcFreeTypeQueryFace uses FT_Load_Sfnt_Table to hash the font data, which works for TrueType and OpenType fonts, but not for other fonts. (It then proceeds trying to open the name as a file, which makes absolute no sense for memory fonts.)

I fail to understand why not being able to hash the font would make fontconfig try to open (essentially) random files and fail to provide the font to the application.

Tested with git 03216ccf4ca0 and the latest release.
Comment 1 Behdad Esfahbod 2013-04-25 19:30:22 UTC
Ok, I think best way to handle this is to use the FT_Stream API to get the font file data.
Comment 2 nfxjfg 2013-05-02 19:23:35 UTC
(In reply to comment #1)
> Ok, I think best way to handle this is to use the FT_Stream API to get the
> font file data.

Why not revert the hash feature entirely? I can't even think of a valid use of this feature, and it's obscure at best.
Comment 3 Behdad Esfahbod 2013-05-02 19:32:09 UTC
Akira, do you think you can take a look at this quickly?  If not, I'll try to make it at least not return NULL for now.
Comment 4 Akira TAGOH 2013-05-06 17:25:25 UTC
Sorry, I was on long vacation and will take a look tomorrow.
Comment 5 Akira TAGOH 2013-05-13 02:41:19 UTC
Sorry for late action. please try http://cgit.freedesktop.org/~tagoh/fontconfig/commit/?h=bz63922

This my repo contains a workaround to skip adding a hash value into the cache and take care of the matching in that case. that wouldn't affects the ordering of fonts though, please let me know if something still goes wrong for you.
Comment 6 nfxjfg 2013-05-19 18:04:44 UTC
Unfortunately I can not test, because I took this opportunity to convert the only postscript font file I used to open type.
Comment 7 Akira TAGOH 2013-05-20 08:07:15 UTC
me neither. anyway, after patching out, FcFreeTypeQueryFace() works fine with even a Type42 font, I guess it should works for Type1 too. I've merged the change to master.

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.