Jjgod Jiang
2010-Dec-17 12:06 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
Hi, We hit a locale sensitivity issue of font family name matching in Qt. We use fontconfig like this: * For system fonts, we query the list of fonts with FcFontList() and store the first family name of each result in a list, these family names are always locale aware because the results returned by FcFontList() are always locale aware. * For application fonts, we construct a FTFace from the data and use FcFreeTypeQueryFace to get a FcPattern from it, then get the first family name in the pattern returned, store it in a list. However, the family names returned in this pattern are *NOT* locale aware. The problem of above methods is the family names from the application font list cannot be used to query a font in the first family name list. For instance, if I have the font "SimSun.ttc", my locale is zh_CN.UTF-8, then the first list will have "??" while the application font list will have "SimSun". Possible solutions will be make the family names in the pattern returned by FcFreeTypeQueryFace locale aware, or at least let us to get id of family name in locale aware manner, currently all the locale related functions in fontconfig are private, thus we cannot reproduce the entire locale matching process without duplicate fontconfig code in Qt. Any suggestions? - Jiang
Jjgod Jiang
2010-Dec-28 10:56 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
On Fri, Dec 17, 2010 at 1:06 PM, Jjgod Jiang <gzjjgod at gmail.com> wrote:> We hit a locale sensitivity issue of font family name matching > in Qt. We use fontconfig like this: > > * For system fonts, we query the list of fonts with FcFontList() > ?and store the first family name of each result in a list, > ?these family names are always locale aware because the results > ?returned by FcFontList() are always locale aware. > > * For application fonts, we construct a FTFace from the data and > ?use FcFreeTypeQueryFace to get a FcPattern from it, then get > ?the first family name in the pattern returned, store it in a > ?list. However, the family names returned in this pattern are > ?*NOT* locale aware. > > The problem of above methods is the family names from the > application font list cannot be used to query a font in the > first family name list. > > For instance, if I have the font "SimSun.ttc", my locale is > zh_CN.UTF-8, then the first list will have "??" while the > application font list will have "SimSun". > > Possible solutions will be make the family names in the pattern > returned by FcFreeTypeQueryFace locale aware, or at least let > us to get id of family name in locale aware manner, currently > all the locale related functions in fontconfig are private, > thus we cannot reproduce the entire locale matching process > without duplicate fontconfig code in Qt. > > Any suggestions?Anyone have any opinion about this question? If there is no objection, I can provide a patch for it, but I just need to make sure the maintainer is willing to integrate such a change. - Jiang
suzuki toshiya
2010-Dec-28 11:00 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
Although I''m not a fontconfig maintainer, I''m interested in this issue, but no time to review in detail, sorry. Regards, mpsuzuki Jjgod Jiang wrote:> On Fri, Dec 17, 2010 at 1:06 PM, Jjgod Jiang <gzjjgod at gmail.com> wrote: >> We hit a locale sensitivity issue of font family name matching >> in Qt. We use fontconfig like this: >> >> * For system fonts, we query the list of fonts with FcFontList() >> and store the first family name of each result in a list, >> these family names are always locale aware because the results >> returned by FcFontList() are always locale aware. >> >> * For application fonts, we construct a FTFace from the data and >> use FcFreeTypeQueryFace to get a FcPattern from it, then get >> the first family name in the pattern returned, store it in a >> list. However, the family names returned in this pattern are >> *NOT* locale aware. >> >> The problem of above methods is the family names from the >> application font list cannot be used to query a font in the >> first family name list. >> >> For instance, if I have the font "SimSun.ttc", my locale is >> zh_CN.UTF-8, then the first list will have "??" while the >> application font list will have "SimSun". >> >> Possible solutions will be make the family names in the pattern >> returned by FcFreeTypeQueryFace locale aware, or at least let >> us to get id of family name in locale aware manner, currently >> all the locale related functions in fontconfig are private, >> thus we cannot reproduce the entire locale matching process >> without duplicate fontconfig code in Qt. >> >> Any suggestions? > > Anyone have any opinion about this question? > > If there is no objection, I can provide a patch for it, but I > just need to make sure the maintainer is willing to integrate > such a change. > > - Jiang > _______________________________________________ > Fontconfig mailing list > Fontconfig at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/fontconfig
Nicolas Mailhot
2010-Dec-28 12:17 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
Le Mar 28 d?cembre 2010 11:56, Jjgod Jiang a ?crit : ny suggestions?> > Anyone have any opinion about this question?For font name resolution to work, fontconfig needs to compute a master id for internal use for each font and accept all the (localized, postscript, etc) aliases from apps (not require the master id however it is computed) It is not possible to require apps to pass a specific font name (if only because al lot of stuff nowadays is CSS, and CSS can contain any of the various names associated with a font). I doubt trying to make a localized name the master id will work, if only because on a modern system, different apps can be launched with different locale parameters (on multiuser systems, and even on single-user systems when the user is multilingual) -- Nicolas Mailhot
Jjgod Jiang
2010-Dec-28 14:56 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
Hi, Sorry, I should have CCed to the list. On Tue, Dec 28, 2010 at 1:17 PM, Nicolas Mailhot <nicolas.mailhot at laposte.net> wrote:> For font name resolution to work, fontconfig needs to compute a master id for > internal use for each font and accept all the (localized, postscript, etc) > aliases from apps (not require the master id however it is computed)I have no problem with this, all I''m asking is the *order* of family names returned by fontconfig to be consistent in all occasions. If in one case (FcFontList) it''s sorted with locale while in another case (FcFreeTypeQueryFace) it''s not, then third party libraries like Qt will have difficulty implementing its own font matching mechanism based on fontconfig. - Jiang
Behdad Esfahbod
2011-Jan-05 16:12 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
On 12/28/10 09:56, Jjgod Jiang wrote:> I have no problem with this, all I''m asking is the *order* of family > names returned by fontconfig to be consistent in all occasions. If in > one case (FcFontList) it''s sorted with locale while in another case > (FcFreeTypeQueryFace) it''s not, then third party libraries like Qt will > have difficulty implementing its own font matching mechanism based on > fontconfig.You can check familylang. behdad
Jjgod Jiang
2011-Jan-05 16:44 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
On Wed, Jan 5, 2011 at 5:12 PM, Behdad Esfahbod <behdad at behdad.org> wrote:> On 12/28/10 09:56, Jjgod Jiang wrote: >> I have no problem with this, all I''m asking is the *order* of family >> names returned by fontconfig to be consistent in all occasions. If in >> one case (FcFontList) it''s sorted with locale while in another case >> (FcFreeTypeQueryFace) it''s not, then third party libraries like Qt will >> have difficulty implementing its own font matching mechanism based on >> fontconfig. > > You can check familylang.Can you explain a bit more about how that''s going to work (for the patterns returned by FcFreeTypeQueryFace)? - Jiang
Behdad Esfahbod
2011-Jan-05 17:10 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
On 01/05/11 11:44, Jjgod Jiang wrote:> On Wed, Jan 5, 2011 at 5:12 PM, Behdad Esfahbod <behdad at behdad.org> wrote: >> On 12/28/10 09:56, Jjgod Jiang wrote: >>> I have no problem with this, all I''m asking is the *order* of family >>> names returned by fontconfig to be consistent in all occasions. If in >>> one case (FcFontList) it''s sorted with locale while in another case >>> (FcFreeTypeQueryFace) it''s not, then third party libraries like Qt will >>> have difficulty implementing its own font matching mechanism based on >>> fontconfig. >> >> You can check familylang. > > Can you explain a bit more about how that''s going to work (for the patterns > returned by FcFreeTypeQueryFace)?As far as I understand, you want to be able to know what language a given family name belongs to? familylang tells you that. From there on it''s up to your matching algorithm to do whatever it wants. Begs the question: why do you not use fontconfig''s matching facility? behdad> - Jiang >
Jjgod Jiang
2011-Jan-05 18:18 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
On Wed, Jan 5, 2011 at 6:10 PM, Behdad Esfahbod <behdad at behdad.org> wrote:> As far as I understand, you want to be able to know what language a given > family name belongs to? ?familylang tells you that. ?From there on it''s up to > your matching algorithm to do whatever it wants.As I said in my first email, when adding application fonts, the family names returned by FcFreeTypeQueryFace is *NOT* sorted by locale, thus, I need to find out which name is for the current locale myself. I can test each one with their familylang, but how do I know the system familylang? To be specific, what I need is FcGetDefaultLang() to be exported.> Begs the question: why do you not use fontconfig''s matching facility?Because Qt has to build its own cross-platform font database, it''s not just about matching, it''s also about providing the users an unified font list. - Jiang
Jjgod Jiang
2011-Jan-05 18:32 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
Hi, Never mind, I managed to get that with FcDefaultSubstitute(). Thanks for the tip! On Wed, Jan 5, 2011 at 7:18 PM, Jjgod Jiang <gzjjgod at gmail.com> wrote:> On Wed, Jan 5, 2011 at 6:10 PM, Behdad Esfahbod <behdad at behdad.org> wrote: >> As far as I understand, you want to be able to know what language a given >> family name belongs to? ?familylang tells you that. ?From there on it''s up to >> your matching algorithm to do whatever it wants. > > As I said in my first email, when adding application fonts, the family names > returned by FcFreeTypeQueryFace is *NOT* sorted by locale, thus, I need to > find out which name is for the current locale myself. I can test each one > with their familylang, but how do I know the system familylang? > > To be specific, what I need is FcGetDefaultLang() to be exported. > >> Begs the question: why do you not use fontconfig''s matching facility? > > Because Qt has to build its own cross-platform font database, it''s not > just about matching, it''s also about providing the users an unified > font list. > > - Jiang >
Behdad Esfahbod
2011-Jan-05 18:59 UTC
[Fontconfig] Making family names returned by FcFreeTypeQueryFace locale aware?
On 01/05/11 13:32, Jjgod Jiang wrote:> Hi, > > Never mind, I managed to get that with FcDefaultSubstitute(). Thanks > for the tip!Nice trick.>> To be specific, what I need is FcGetDefaultLang() to be exported.I''ll file a bug to add this. behdad