Don't set kCTFontSymbolicTrait.
authorBen Wagner <bungeman@google.com>
Mon, 1 Oct 2018 20:04:09 +0000 (16:04 -0400)
committerMatthew Leibowitz <mattleibow@live.com>
Mon, 29 Oct 2018 16:42:29 +0000 (18:42 +0200)
This allows for requesting 'bold' and 'italic' but these requests are
redundant with the 'weight' and 'slant' requests also being made. It
appears that on macOS 14 and iOS 12 that setting kCTFontSymbolicTrait,
particularly without setting any bits, leads to strange behavior. Since
the information in kCTFontSymbolicTrait is better provided by other
traits, simply remove the code which sets it and add a comment explaining
why.

Bug: skia:8432
Change-Id: I795c9adf4a52d828d3e92bc4af0966102f9b6cc1
Reviewed-on: https://skia-review.googlesource.com/158443
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>

src/ports/SkFontHost_mac.cpp

index 3cc51d43f60fdc1b24096015d2ca1b8ae1fbf943..0bcccb177509a9696265d0d04e5312b47849c0aa 100644 (file)
@@ -793,18 +793,8 @@ static UniqueCFRef<CTFontDescriptorRef> create_descriptor(const char familyName[
     }
 
     // CTFontTraits (symbolic)
-    CTFontSymbolicTraits ctFontTraits = 0;
-    if (style.weight() >= SkFontStyle::kBold_Weight) {
-        ctFontTraits |= kCTFontBoldTrait;
-    }
-    if (style.slant() != SkFontStyle::kUpright_Slant) {
-        ctFontTraits |= kCTFontItalicTrait;
-    }
-    UniqueCFRef<CFNumberRef> cfFontTraits(
-            CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &ctFontTraits));
-    if (cfFontTraits) {
-        CFDictionaryAddValue(cfTraits.get(), kCTFontSymbolicTrait, cfFontTraits.get());
-    }
+    // macOS 14 and iOS 12 seem to behave badly when kCTFontSymbolicTrait is set.
+
     // CTFontTraits (weight)
     CGFloat ctWeight = fontstyle_to_ct_weight(style.weight());
     UniqueCFRef<CFNumberRef> cfFontWeight(