Allow CoreText axis hidden value to be CFNumber.
Parts of CoreText use 'structured' CFDictionaries to pass information. Because of the lack of explicit structure and very dynamic types, this requires that every entry be checked for existence and type before use. If the existence or type does not match expectations the code generally returns a failure or default value. In this case kCTFontVariationAxisHiddenKey is documented to be a CFBooleanRef, but on macOS 11 Big Sur Beta 4 it can be a CFNumberRef instead. Handle this case when it happens. Bug: chromium:1113444 Change-Id: Id1ae31104e674d65eaa67166d2442ab4f63989cd Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308764 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
375721d7bb
commit
fc11fd4d0b
@ -1298,11 +1298,17 @@ int SkTypeface_Mac::onGetVariationDesignParameters(SkFontParameters::Variation::
|
||||
if (kCTFontVariationAxisHiddenKeyPtr) {
|
||||
CFTypeRef hidden = CFDictionaryGetValue(axisInfoDict,*kCTFontVariationAxisHiddenKeyPtr);
|
||||
if (hidden) {
|
||||
// At least macOS 11 Big Sur Beta 4 uses CFNumberRef instead of CFBooleanRef.
|
||||
// https://crbug.com/1113444
|
||||
CFBooleanRef hiddenBoolean;
|
||||
if (!SkCFDynamicCast(hidden, &hiddenBoolean, "Variation hidden")) {
|
||||
int hiddenInt;
|
||||
if (SkCFDynamicCast(hidden, &hiddenBoolean, nullptr)) {
|
||||
skAxis.setHidden(CFBooleanGetValue(hiddenBoolean));
|
||||
} else if (SkCFNumberDynamicCast(hidden, &hiddenInt, nullptr, "Axis hidden")) {
|
||||
skAxis.setHidden(hiddenInt);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
skAxis.setHidden(CFBooleanGetValue(hiddenBoolean));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user