mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
font: CoreText discovery searches monospace only by default
This commit is contained in:
@ -101,6 +101,28 @@ pub fn deinit(self: *DeferredFace) void {
|
||||
self.* = undefined;
|
||||
}
|
||||
|
||||
/// Returns the family name of the font.
|
||||
pub fn familyName(self: DeferredFace, buf: []u8) ![]const u8 {
|
||||
switch (options.backend) {
|
||||
.freetype => {},
|
||||
|
||||
.fontconfig_freetype => if (self.fc) |fc|
|
||||
return (try fc.pattern.get(.family, 0)).string,
|
||||
|
||||
.coretext, .coretext_freetype => if (self.ct) |ct| {
|
||||
const family_name = ct.font.copyAttribute(.family_name);
|
||||
return family_name.cstringPtr(.utf8) orelse unsupported: {
|
||||
break :unsupported family_name.cstring(buf, .utf8) orelse
|
||||
return error.OutOfMemory;
|
||||
};
|
||||
},
|
||||
|
||||
.web_canvas => if (self.wc) |wc| return wc.font_str,
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/// Returns the name of this face. The memory is always owned by the
|
||||
/// face so it doesn't have to be freed.
|
||||
pub fn name(self: DeferredFace, buf: []u8) ![]const u8 {
|
||||
|
@ -40,9 +40,10 @@ pub const Descriptor = struct {
|
||||
size: u16 = 0,
|
||||
|
||||
/// True if we want to search specifically for a font that supports
|
||||
/// bold, italic, or both.
|
||||
/// specific styles.
|
||||
bold: bool = false,
|
||||
italic: bool = false,
|
||||
monospace: bool = true,
|
||||
|
||||
/// Variation axes to apply to the font. This also impacts searching
|
||||
/// for fonts since fonts with the ability to set these variations
|
||||
@ -131,6 +132,7 @@ pub const Descriptor = struct {
|
||||
const traits: macos.text.FontSymbolicTraits = .{
|
||||
.bold = self.bold,
|
||||
.italic = self.italic,
|
||||
.monospace = self.monospace,
|
||||
};
|
||||
const traits_cval: u32 = @bitCast(traits);
|
||||
if (traits_cval > 0) {
|
||||
|
Reference in New Issue
Block a user