Skip to content

Commit f182a60

Browse files
fix: use public APIs in place of private CTFontDescriptorIsSystemUIFont in ui/gfx (electron#26548)
1 parent dcc6196 commit f182a60

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

patches/chromium/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,4 @@ fix_properly_honor_printing_page_ranges.patch
102102
fix_use_electron_generated_resources.patch
103103
chore_expose_v8_initialization_isolate_callbacks.patch
104104
export_gin_v8platform_pageallocator_for_usage_outside_of_the_gin.patch
105+
use_public_apis_to_determine_if_a_font_is_a_system_font_in_mas_build.patch
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Samuel Attard <samuel.r.attard@gmail.com>
3+
Date: Tue, 17 Nov 2020 16:59:28 -0800
4+
Subject: use public APIs to determine if a font is a system font in MAS build
5+
6+
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.
7+
8+
diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm
9+
index fc6047806e3511f60b58a669fdf628e1a48eb05b..bcc29ac87cfc965eb4c3f06d959605d2cb259770 100644
10+
--- a/ui/gfx/platform_font_mac.mm
11+
+++ b/ui/gfx/platform_font_mac.mm
12+
@@ -25,9 +25,11 @@
13+
14+
using Weight = Font::Weight;
15+
16+
+#if !defined(MAS_BUILD)
17+
extern "C" {
18+
bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
19+
}
20+
+#endif
21+
22+
namespace {
23+
24+
@@ -269,7 +271,13 @@ NSInteger ToNSFontManagerWeight(Weight weight) {
25+
// TODO(avi, etienneb): Figure out this font stuff.
26+
base::ScopedCFTypeRef<CTFontDescriptorRef> descriptor(
27+
CTFontCopyFontDescriptor(font));
28+
+#if defined(MAS_BUILD)
29+
+ CFNumberRef priority = (CFNumberRef)CTFontDescriptorCopyAttribute(descriptor.get(), (CFStringRef)kCTFontPriorityAttribute);
30+
+ SInt64 v;
31+
+ if (CFNumberGetValue(priority, kCFNumberSInt64Type, &v) && v == kCTFontPrioritySystem) {
32+
+#else
33+
if (CTFontDescriptorIsSystemUIFont(descriptor.get())) {
34+
+#endif
35+
// Assume it's the standard system font. The fact that this much is known is
36+
// enough.
37+
return PlatformFontMac::SystemFontType::kGeneral;

0 commit comments

Comments
 (0)