From 9601ad4e27d0e0a846ff13a1e7dbadd7afd260f5 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 26 Sep 2018 08:47:10 +0200 Subject: [PATCH] Fix font weights on macOS 10.14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø Reviewed-by: Jason Haslam --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 6 +++--- 1 file 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;