Make fontconfig default font locale aware
Application default font should be locale aware in fontconfig db as in other font databases. We use a hack to obtain the system default language parsed by fontconfig and use that to find out the preferred font for a given language (such font list is edited by fontconfig from fonts.conf in FcConfigSubstitute() process). Change-Id: I99bb8dd29d2dde2c8019ed8e77f5bfc09ddf3ca5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
This commit is contained in:
parent
94492d88a7
commit
47462ffd68
@ -751,7 +751,30 @@ QString QFontconfigDatabase::resolveFontFamilyAlias(const QString &family) const
|
|||||||
|
|
||||||
QFont QFontconfigDatabase::defaultFont() const
|
QFont QFontconfigDatabase::defaultFont() const
|
||||||
{
|
{
|
||||||
return QFont(resolveFontFamilyAlias(QString()));
|
// Hack to get system default language until FcGetDefaultLangs()
|
||||||
|
// is exported (https://bugs.freedesktop.org/show_bug.cgi?id=32853)
|
||||||
|
// or https://bugs.freedesktop.org/show_bug.cgi?id=35482 is fixed
|
||||||
|
FcPattern *dummy = FcPatternCreate();
|
||||||
|
FcDefaultSubstitute(dummy);
|
||||||
|
FcChar8 *lang = 0;
|
||||||
|
FcResult res = FcPatternGetString(dummy, FC_LANG, 0, &lang);
|
||||||
|
|
||||||
|
FcPattern *pattern = FcPatternCreate();
|
||||||
|
if (res == FcResultMatch) {
|
||||||
|
// Make defaultFont pattern matching locale language aware, because
|
||||||
|
// certain FC_LANG based custom rules may happen in FcConfigSubstitute()
|
||||||
|
FcPatternAddString(pattern, FC_LANG, lang);
|
||||||
|
}
|
||||||
|
FcConfigSubstitute(0, pattern, FcMatchPattern);
|
||||||
|
FcDefaultSubstitute(pattern);
|
||||||
|
|
||||||
|
FcChar8 *familyAfterSubstitution = 0;
|
||||||
|
FcPatternGetString(pattern, FC_FAMILY, 0, &familyAfterSubstitution);
|
||||||
|
QString resolved = QString::fromUtf8((const char *) familyAfterSubstitution);
|
||||||
|
FcPatternDestroy(pattern);
|
||||||
|
FcPatternDestroy(dummy);
|
||||||
|
|
||||||
|
return QFont(resolved);
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user