From f182a600e460c8bb2994259eddd4cfbc0a49c897 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Wed, 18 Nov 2020 09:32:56 -0800 Subject: [PATCH] fix: use public APIs in place of private CTFontDescriptorIsSystemUIFont in ui/gfx (#26548) --- patches/chromium/.patches | 1 + ...a_font_is_a_system_font_in_mas_build.patch | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 patches/chromium/use_public_apis_to_determine_if_a_font_is_a_system_font_in_mas_build.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 581d1b5adf15..f13b242c28df 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -102,3 +102,4 @@ fix_properly_honor_printing_page_ranges.patch fix_use_electron_generated_resources.patch chore_expose_v8_initialization_isolate_callbacks.patch export_gin_v8platform_pageallocator_for_usage_outside_of_the_gin.patch +use_public_apis_to_determine_if_a_font_is_a_system_font_in_mas_build.patch diff --git a/patches/chromium/use_public_apis_to_determine_if_a_font_is_a_system_font_in_mas_build.patch b/patches/chromium/use_public_apis_to_determine_if_a_font_is_a_system_font_in_mas_build.patch new file mode 100644 index 000000000000..e3970e83db6c --- /dev/null +++ b/patches/chromium/use_public_apis_to_determine_if_a_font_is_a_system_font_in_mas_build.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samuel Attard +Date: Tue, 17 Nov 2020 16:59:28 -0800 +Subject: use public APIs to determine if a font is a system font in MAS build + +CTFontDescriptorIsSystemUIFont is a private API, we're using an _interesting_ technique in the MAS build to determine if the font is a system font by checking if it's kCTFontPriorityAttribute is set to system priority. + +diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm +index fc6047806e3511f60b58a669fdf628e1a48eb05b..bcc29ac87cfc965eb4c3f06d959605d2cb259770 100644 +--- a/ui/gfx/platform_font_mac.mm ++++ b/ui/gfx/platform_font_mac.mm +@@ -25,9 +25,11 @@ + + using Weight = Font::Weight; + ++#if !defined(MAS_BUILD) + extern "C" { + bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef); + } ++#endif + + namespace { + +@@ -269,7 +271,13 @@ NSInteger ToNSFontManagerWeight(Weight weight) { + // TODO(avi, etienneb): Figure out this font stuff. + base::ScopedCFTypeRef descriptor( + CTFontCopyFontDescriptor(font)); ++#if defined(MAS_BUILD) ++ CFNumberRef priority = (CFNumberRef)CTFontDescriptorCopyAttribute(descriptor.get(), (CFStringRef)kCTFontPriorityAttribute); ++ SInt64 v; ++ if (CFNumberGetValue(priority, kCFNumberSInt64Type, &v) && v == kCTFontPrioritySystem) { ++#else + if (CTFontDescriptorIsSystemUIFont(descriptor.get())) { ++#endif + // Assume it's the standard system font. The fact that this much is known is + // enough. + return PlatformFontMac::SystemFontType::kGeneral;