macOS: Reject styled fallback from CoreText if its family name is not the same as the original

On some systems, for the good Lord alone knows what reason, CoreText is
giving us Zapf Dingbats as a font for some symbols, which doesnt
actually work.

Fixes #7249 (I hope)
This commit is contained in:
Kovid Goyal 2024-03-22 14:38:08 +05:30
parent 12e9db4ccc
commit 98d32e50e0
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 0 deletions

View file

@ -60,6 +60,8 @@ Detailed list of changes
- Mouse reporting: Fix drag release event outside the window not being reported in legacy mouse reporting modes (:iss:`7244`)
- macOS: Fix a regression in the previous release that broke rendering of some symbols on some systems (:iss:`7249`)
0.33.1 [2024-03-21]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -302,6 +302,11 @@ static CTFontRef nerd_font(CGFloat sz) {
if (descriptor) {
ans = CTFontCreateWithFontDescriptor(descriptor, CTFontGetSize(original_fallback_font), NULL);
CFRelease(descriptor);
CFStringRef new_name = CTFontCopyFamilyName(ans);
CFStringRef old_name = CTFontCopyFamilyName(original_fallback_font);
bool same_family = cf_string_equals(new_name, old_name);
CFRelease(new_name); CFRelease(old_name);
if (!same_family) { CFRelease(ans); return original_fallback_font; }
}
if (ans) { CFRelease(original_fallback_font); return ans; }
return original_fallback_font;