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>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2018-09-26 08:47:10 +02:00
parent f6ce2d42b3
commit 9601ad4e27

View File

@ -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;