diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-12-06 15:05:55 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-01-04 14:20:11 (GMT) |
commit | 06568ff89c48dee8aab278b8b0538c331aa84595 (patch) | |
tree | a46fd8406e0661ec5e5b4ddbf1ef3e2562175a36 /src/plugins/platforms | |
parent | 0ceed999bbf25d19b3ded8a1b300cf0c6129f775 (diff) | |
download | Qt-06568ff89c48dee8aab278b8b0538c331aa84595.zip Qt-06568ff89c48dee8aab278b8b0538c331aa84595.tar.gz Qt-06568ff89c48dee8aab278b8b0538c331aa84595.tar.bz2 |
Add styleHint to fallback api for fontdatabases in Lighthouse
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp | 27 | ||||
-rw-r--r-- | src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h | 2 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 92f30fc..9b9be07 100644 --- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -274,6 +274,25 @@ static const char *openType[] = { "nko " // N'Ko }; +static const char *getFcFamilyForStyleHint(const QFont::StyleHint style) +{ + const char *stylehint = 0; + switch (style) { + case QFont::SansSerif: + stylehint = "sans-serif"; + break; + case QFont::Serif: + stylehint = "serif"; + break; + case QFont::TypeWriter: + stylehint = "monospace"; + break; + default: + break; + } + return stylehint; +} + void QFontconfigDatabase::populateFontDatabase() { FcFontSet *fonts; @@ -522,7 +541,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables:: return engine; } -QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const +QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const { QStringList fallbackFamilies; FcPattern *pattern = FcPatternCreate(); @@ -550,6 +569,12 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const FcLangSetDestroy(ls); } + const char *stylehint = getFcFamilyForStyleHint(styleHint); + if (stylehint) { + value.u.s = (const FcChar8 *)stylehint; + FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue); + } + FcConfigSubstitute(0, pattern, FcMatchPattern); FcConfigSubstitute(0, pattern, FcMatchFont); diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h index 33382dc..cf62b88 100644 --- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h +++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h @@ -50,7 +50,7 @@ class QFontconfigDatabase : public QBasicUnixFontDatabase public: void populateFontDatabase(); QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); - QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const; + QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const; }; #endif // QFONTCONFIGDATABASE_H |