summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorMitchell Hashimoto <m@mitchellh.com>2024-10-25 21:25:15 -0700
committerMitchell Hashimoto <m@mitchellh.com>2024-10-25 21:29:45 -0700
commit1aa932f810a11617e9c9751c72b87aff8e55e281 (patch)
tree552c2b56210acd68b12fe2620fa16e4ce4b4d261 /pkg
parent734c8cec5521a7867a8c07ee26777fe8df0b22ef (diff)
font/coretext: use CTFontCreateForString for final codepoint fallback
Fixes #2499 We rely on CoreText's font discovery to find the best font for a fallback by using the character set attribute. It appears that for some codepoints, the character set attribute is not enough to find a font that supports the codepoint. In this case, we use CTFontCreateForString to find the font that CoreText would use. The one subtlety here is we need to ignore the last resort font, which just has replacement glyphs for all codepoints. We already had a function to do this for CJK characters (#1637) thankfully so we can just reuse that! This also fixes a bug where CTFontCreateForString range param expects the range length to be utf16 code units, not utf32.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/macos/text/font.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/macos/text/font.zig b/pkg/macos/text/font.zig
index 85f7de47e..67a303018 100644
--- a/pkg/macos/text/font.zig
+++ b/pkg/macos/text/font.zig
@@ -160,6 +160,10 @@ pub const Font = opaque {
return @ptrFromInt(@intFromPtr(c.CTFontCopyDisplayName(@ptrCast(self))));
}
+ pub fn copyPostScriptName(self: *Font) *foundation.String {
+ return @ptrFromInt(@intFromPtr(c.CTFontCopyPostScriptName(@ptrCast(self))));
+ }
+
pub fn getSymbolicTraits(self: *Font) text.FontSymbolicTraits {
return @bitCast(c.CTFontGetSymbolicTraits(@ptrCast(self)));
}