Please do not reply directly to this email. All additional comments should be made in the comments box of this bug.
https://bugzilla.redhat.com/show_bug.cgi?id=705348
--- Comment #21 from Behdad Esfahbod behdad@fedoraproject.org 2011-06-06 12:18:24 EDT --- The way Pango is using fontconfig is completely correct and the way fontconfig is designed to be used. In short, this is how to use fontconfig:
- Create a pattern specifying the characteristics you are looking for (ie. "sans bold 18"). Call this pat.
- Call FcConfigSubstitute (NULL, pat, FcMatchPattern). That's where target="pattern" configuration is applied.
- Call FcDefaultSubstitute (pat)
- Then either: {
- Call FcFontSort (NULL, pat, ...). This will return a fontset, lets call it fs.
- For any item in fs that you want to use (call that 'font'), you should:
- Call FcRenderPrepare (NULL, pat, font). This will implicitly call FcConfigSubstituteWithPat (NULL, res, pat, FcMatchFont) on the pattern that it returns. That's where target="font" configuration is applied.
- Use the resulting pattern to open the font and render it.
} or {
- Call FcFontMatch (NULL, pat, &result). This will return what we call a "font" pattern. It already has FcFontRenderPrepare (NULL, pat, font) called on it by FcFontMatch.
}
Now! The way Qt is abusing fontconfig is:
- qt_fontSetForPattern calls FcFontSort (NULL, pat, ...) and gets the resulting fontset 'fs' and saves it.
*** Note that it should have called FcConfigSubstitute (pattern, FcMatchPattern) and FcDefaultSubstitute (pattern) first, but it didn't.
- In QFontEngineMultiFT::loadEngine(), it gets font patterns out of fs, and calls it pattern. Note that this is a target="font" kind of pattern.
- Then it calls:
FcConfigSubstitute(0, pattern, FcMatchPattern); FcDefaultSubstitute(pattern);
*** This is completely wrong, since pattern is a font pattern, not a query pattern!
So, that's it. It's completely b0rked. Those two calls should be made before FcFontSort(), and FcRenderPrepare called in place of those two.
i18n-bugs@lists.fedoraproject.org