mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
Merge pull request #2609 from ghostty-org/push-uuprylpzkqsn
coretext: variable font fixes
This commit is contained in:
@ -235,21 +235,7 @@ pub const Descriptor = struct {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build our descriptor from attrs
|
return try macos.text.FontDescriptor.createWithAttributes(@ptrCast(attrs));
|
||||||
var desc = try macos.text.FontDescriptor.createWithAttributes(@ptrCast(attrs));
|
|
||||||
errdefer desc.release();
|
|
||||||
|
|
||||||
// Variations are built by copying the descriptor. I don't know a way
|
|
||||||
// to set it on attrs directly.
|
|
||||||
for (self.variations) |v| {
|
|
||||||
const id = try macos.foundation.Number.create(.int, @ptrCast(&v.id));
|
|
||||||
defer id.release();
|
|
||||||
const next = try desc.createCopyWithVariation(id, v.value);
|
|
||||||
desc.release();
|
|
||||||
desc = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
return desc;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -685,30 +671,29 @@ pub const CoreText = struct {
|
|||||||
break :style .unmatched;
|
break :style .unmatched;
|
||||||
defer style.release();
|
defer style.release();
|
||||||
|
|
||||||
|
// Get our style string
|
||||||
|
var buf: [128]u8 = undefined;
|
||||||
|
const style_str = style.cstring(&buf, .utf8) orelse break :style .unmatched;
|
||||||
|
|
||||||
// If we have a specific desired style, attempt to search for that.
|
// If we have a specific desired style, attempt to search for that.
|
||||||
if (desc.style) |desired_style| {
|
if (desc.style) |desired_style| {
|
||||||
var buf: [128]u8 = undefined;
|
|
||||||
const style_str = style.cstring(&buf, .utf8) orelse break :style .unmatched;
|
|
||||||
|
|
||||||
// Matching style string gets highest score
|
// Matching style string gets highest score
|
||||||
if (std.mem.eql(u8, desired_style, style_str)) break :style .match;
|
if (std.mem.eql(u8, desired_style, style_str)) break :style .match;
|
||||||
|
} else if (!desc.bold and !desc.italic) {
|
||||||
// Otherwise the score is based on the length of the style string.
|
// If we do not, and we have no symbolic traits, then we try
|
||||||
// Shorter styles are scored higher.
|
// to find "regular" (or no style). If we have symbolic traits
|
||||||
break :style @enumFromInt(100 -| style_str.len);
|
// we do nothing but we can improve scoring by taking that into
|
||||||
|
// account, too.
|
||||||
|
if (std.mem.eql(u8, "Regular", style_str)) {
|
||||||
|
break :style .match;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we do not, and we have no symbolic traits, then we try
|
// Otherwise the score is based on the length of the style string.
|
||||||
// to find "regular" (or no style). If we have symbolic traits
|
// Shorter styles are scored higher. This is a heuristic that
|
||||||
// we do nothing but we can improve scoring by taking that into
|
// if we don't have a desired style then shorter tends to be
|
||||||
// account, too.
|
// more often the "regular" style.
|
||||||
if (!desc.bold and !desc.italic) {
|
break :style @enumFromInt(100 -| style_str.len);
|
||||||
var buf: [128]u8 = undefined;
|
|
||||||
const style_str = style.cstring(&buf, .utf8) orelse break :style .unmatched;
|
|
||||||
if (std.mem.eql(u8, "Regular", style_str)) break :style .match;
|
|
||||||
}
|
|
||||||
|
|
||||||
break :style .unmatched;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
score_acc.traits = traits: {
|
score_acc.traits = traits: {
|
||||||
|
Reference in New Issue
Block a user