summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBernd Weimer <bweimer@rim.com>2013-02-21 08:58:56 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-21 10:27:27 (GMT)
commitb9b3acf39e9e3b5b7288b4f4f8c7246606e16d0d (patch)
tree9dbcc45ec5d8fae7c1ea30636ec35a0bc6d3238d /src
parent5a58067a8ed92553182467a3522aff7747a22cad (diff)
downloadQt-b9b3acf39e9e3b5b7288b4f4f8c7246606e16d0d.zip
Qt-b9b3acf39e9e3b5b7288b4f4f8c7246606e16d0d.tar.gz
Qt-b9b3acf39e9e3b5b7288b4f4f8c7246606e16d0d.tar.bz2
Take fontconfig font width into account
For fonts provided by fontconfig the FC_WIDTH will be mapped to QFont::Stretch to achieve a more accurate font matching. In Qt5 the font style is considered instead. This cannot be used without breaking binary compatibility. Change-Id: Ia519c2b70eb9f03ba0971fd6e8dd575169c7b72a Reviewed-by: Jiang Jiang <gzjjgod@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 656a247..d1e7abb 100644
--- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -314,7 +314,7 @@ void QFontconfigDatabase::populateFontDatabase()
const char *properties [] = {
FC_FAMILY, FC_WEIGHT, FC_SLANT,
FC_SPACING, FC_FILE, FC_INDEX,
- FC_LANG, FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, FC_WEIGHT,
+ FC_LANG, FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE,
FC_WIDTH,
#if FC_VERSION >= 20297
FC_CAPABILITY,
@@ -417,13 +417,26 @@ void QFontconfigDatabase::populateFontDatabase()
QFont::Weight weight = QFont::Weight(getFCWeight(weight_value));
double pixel_size = 0;
- if (!scalable) {
- int width = 100;
- FcPatternGetInteger (fonts->fonts[i], FC_WIDTH, 0, &width);
+ if (!scalable)
FcPatternGetDouble (fonts->fonts[i], FC_PIXEL_SIZE, 0, &pixel_size);
+
+ int width = FC_WIDTH_NORMAL;
+ FcPatternGetInteger(fonts->fonts[i], FC_WIDTH, 0, &width);
+
+ QFont::Stretch stretch;
+ switch (width) {
+ case FC_WIDTH_ULTRACONDENSED: stretch = QFont::UltraCondensed; break;
+ case FC_WIDTH_EXTRACONDENSED: stretch = QFont::ExtraCondensed; break;
+ case FC_WIDTH_CONDENSED: stretch = QFont::Condensed; break;
+ case FC_WIDTH_SEMICONDENSED: stretch = QFont::SemiCondensed; break;
+ case FC_WIDTH_NORMAL: stretch = QFont::Unstretched; break;
+ case FC_WIDTH_SEMIEXPANDED: stretch = QFont::SemiExpanded; break;
+ case FC_WIDTH_EXPANDED: stretch = QFont::Expanded; break;
+ case FC_WIDTH_EXTRAEXPANDED: stretch = QFont::ExtraExpanded; break;
+ case FC_WIDTH_ULTRAEXPANDED: stretch = QFont::UltraExpanded; break;
+ default: stretch = QFont::Unstretched; break;
}
- QFont::Stretch stretch = QFont::Unstretched;
QPlatformFontDatabase::registerFont(familyName,QLatin1String((const char *)foundry_value),weight,style,stretch,antialias,scalable,pixel_size,writingSystems,fontFile);
// qDebug() << familyName << (const char *)foundry_value << weight << style << &writingSystems << scalable << true << pixel_size;
}