diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2018-09-26 08:47:10 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2018-09-27 06:50:46 +0000 |
commit | 9601ad4e27d0e0a846ff13a1e7dbadd7afd260f5 (patch) | |
tree | 1a476ff9ed0f1796d6a33ed2b7d5080e7671535a /src/platformsupport/fontdatabases/mac | |
parent | f6ce2d42b3cbe049ebcf1a2349a5cd4dde2c6d24 (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>
Diffstat (limited to 'src/platformsupport/fontdatabases/mac')
-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 5faeca0618..5ac28ce798 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -317,9 +317,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; |