font: look up Apple Color Emoji by exact name on macOS

The Apple Color Emoji fallback font was discovered with the generic
discovery path, which builds a CTFontCollection and runs system-wide
font matching. Since we know the exact font we want, we can look it
up directly with CTFontCreateWithName instead.
This commit is contained in:
Mitchell Hashimoto
2026-08-09 15:40:44 -07:00
parent 3225e9ebb1
commit afc79b8ccf
3 changed files with 77 additions and 0 deletions

View File

@@ -18,6 +18,17 @@ pub const Font = opaque {
) orelse Allocator.Error.OutOfMemory;
}
pub fn createWithName(name: *foundation.String, size: f32) Allocator.Error!*Font {
return @as(
?*Font,
@ptrFromInt(@intFromPtr(c.CTFontCreateWithName(
@ptrCast(name),
size,
null,
))),
) orelse Allocator.Error.OutOfMemory;
}
pub fn createForString(
self: *Font,
str: *foundation.String,