diff options
author | James Turner <james.turner@kdab.com> | 2018-09-26 08:47:10 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2018-10-12 15:11:35 +0000 |
commit | b64ea4a3ab5fab596c7f0720f06116a592b27018 (patch) | |
tree | 07cffdf2cce2c1d1e496b79c56bd6d9bd9b8cfc3 | |
parent | 0b6765353ad16023e433627291f33491b35bc907 (diff) |
Fix font weights on macOS 10.14
On later versions of macOS, the font weight trait of fonts is a 64 bit
double, not a 32 bit float, and on macOS 10.14, CFNumberGetValue()
started returning false for values when the type conversion is lossy,
like it is documented to. Therefore, we would end up without weight
information in 10.14.
The fix is to ask for a double instead, which works regardless of
whether the CFNumber represents a 32-bit or 64-bit value.
[ChangeLog][macOS][Text] Fixed font weights on macOS 10.14
Task-number: QTBUG-69955
Change-Id: Ia0577236ddc6b96f9231e6de7b1c49f7f8a837a6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Jason Haslam <jason@scitools.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 9601ad4e27d0e0a846ff13a1e7dbadd7afd260f5)
-rw-r--r-- | src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index e3e93df8a0..f8fe160e0b 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -331,9 +331,9 @@ static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd) if (styles) { if (CFNumberRef weightValue = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontWeightTrait)) { - float normalizedWeight; - if (CFNumberGetValue(weightValue, kCFNumberFloatType, &normalizedWeight)) - fd->weight = QCoreTextFontEngine::qtWeightFromCFWeight(normalizedWeight); + double normalizedWeight; + if (CFNumberGetValue(weightValue, kCFNumberFloat64Type, &normalizedWeight)) + fd->weight = QCoreTextFontEngine::qtWeightFromCFWeight(float(normalizedWeight)); } if (CFNumberRef italic = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontSlantTrait)) { double d; |