macos: handle missing CoreText display names (#13642)

Fixes https://github.com/ghostty-org/ghostty/discussions/13262

CTFontCopyDisplayName can return null.
This commit is contained in:
Mitchell Hashimoto
2026-08-05 14:38:31 -07:00
committed by GitHub
2 changed files with 3 additions and 2 deletions

View File

@@ -156,7 +156,7 @@ pub const Font = opaque {
return @ptrFromInt(@intFromPtr(c.CTFontCopyFamilyName(@ptrCast(self))));
}
pub fn copyDisplayName(self: *Font) *foundation.String {
pub fn copyDisplayName(self: *Font) ?*foundation.String {
return @ptrFromInt(@intFromPtr(c.CTFontCopyDisplayName(@ptrCast(self))));
}

View File

@@ -184,7 +184,8 @@ pub fn name(self: DeferredFace, buf: []u8) ![]const u8 {
.coretext_harfbuzz,
.coretext_noshape,
=> if (self.ct) |ct| {
const display_name = ct.font.copyDisplayName();
const display_name = ct.font.copyDisplayName() orelse
return self.familyName(buf);
return display_name.cstringPtr(.utf8) orelse unsupported: {
// "NULL if the internal storage of theString does not allow
// this to be returned efficiently." In this case, we need