summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-10-22 17:14:29 +0200
committerKonstantin Ritt <ritt.ks@gmail.com>2014-12-12 06:59:46 +0100
commit517da68893be9e6d97c7993922c573de9560604d (patch)
tree9da6027604c97023fd6cacc3114c2f2fd43dd26f /src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
parent0478bc15bd3b4c616b4860e460600ba8877ee216 (diff)
Add QFont::Weight enum values
And try to make good use of them in order to match the QFont request more closely. Task-number: QTBUG-38482 Change-Id: I768dfa8828e370d77a1c17ecf4796d750b3edd9b Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm')
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index b5df38734d..ac73cd04ad 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -286,25 +286,9 @@ static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd)
if (styles) {
if (CFNumberRef weightValue = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontWeightTrait)) {
- double normalizedWeight;
- if (CFNumberGetValue(weightValue, kCFNumberDoubleType, &normalizedWeight)) {
- if (normalizedWeight >= 0.62)
- fd->weight = QFont::Black;
- else if (normalizedWeight >= 0.4)
- fd->weight = QFont::Bold;
- else if (normalizedWeight >= 0.3)
- fd->weight = QFont::DemiBold;
- else if (normalizedWeight >= 0.2)
- fd->weight = qt_mediumFontWeight;
- else if (normalizedWeight == 0.0)
- fd->weight = QFont::Normal;
- else if (normalizedWeight <= -0.4)
- fd->weight = QFont::Light;
- else if (normalizedWeight <= -0.6)
- fd->weight = qt_extralightFontWeight;
- else if (normalizedWeight <= -0.8)
- fd->weight = qt_thinFontWeight;
- }
+ float normalizedWeight;
+ if (CFNumberGetValue(weightValue, kCFNumberFloatType, &normalizedWeight))
+ fd->weight = QCoreTextFontEngine::qtWeightFromCFWeight(normalizedWeight);
}
if (CFNumberRef italic = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontSlantTrait)) {
double d;