summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2018-09-26 08:47:10 +0200
committerDyami Caliri <dyami@dragonframe.com>2018-10-02 16:00:58 +0000
commit976b43a7acf72897d506500910b38bd4b96585c1 (patch)
tree76865d36eaa4d944ee04bcaa5afd48a2e7c8f893 /src
parentf12d5b1d6108b4d285a6079655c58129451452fd (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> (cherry picked from commit 9601ad4e27d0e0a846ff13a1e7dbadd7afd260f5) Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm6
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;