diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-08-13 14:17:33 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-08-14 14:39:20 +0200 |
commit | a0b021d1366c772cd9c2cefcb1c47b47c35b5517 (patch) | |
tree | f5d685be7eab2c68f66c9c943e93e62b39e04fda /src/gui | |
parent | b3431a9553ec11b85b5e91c67b1ebaa6e1bfd59b (diff) |
Fix selection of fonts based on styleName
By carrying the styleName through from QFontDef to
bestFoundry and giving it to bestStyle that can use it
we can accurately match fonts based on styleName. This
makes it possible to match styles such as DejaVu Sans
Condensed and Ubuntu Medium.
The example fontsampler is updated so it can actually
sample all the different styles it lists.
Change-Id: I381effc74130311f98794cd07d30be10dee4fe45
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 86a0bf1066..7aa5af8a98 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -931,7 +931,7 @@ static unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, const QtFontFamily *family, const QString &foundry_name, QtFontStyle::Key styleKey, int pixelSize, char pitch, - QtFontDesc *desc, int force_encoding_id) + QtFontDesc *desc, int force_encoding_id, QString styleName = QString()) { Q_UNUSED(force_encoding_id); Q_UNUSED(script); @@ -953,7 +953,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, FM_DEBUG(" looking for matching style in foundry '%s' %d", foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count); - QtFontStyle *style = bestStyle(foundry, styleKey); + QtFontStyle *style = bestStyle(foundry, styleKey, styleName); if (!style->smoothScalable && (styleStrategy & QFont::ForceOutline)) { FM_DEBUG(" ForceOutline set, but not smoothly scalable"); @@ -1140,13 +1140,13 @@ static int match(int script, const QFontDef &request, unsigned int newscore = bestFoundry(script, score, request.styleStrategy, test.family, foundry_name, styleKey, request.pixelSize, pitch, - &test, force_encoding_id); + &test, force_encoding_id, request.styleName); if (test.foundry == 0) { // the specific foundry was not found, so look for // any foundry matching our requirements newscore = bestFoundry(script, score, request.styleStrategy, test.family, QString(), styleKey, request.pixelSize, - pitch, &test, force_encoding_id); + pitch, &test, force_encoding_id, request.styleName); } if (newscore < score) { |