font: log warning when rejecting ic_width

pull/8491/head
Qwerasd 2025-09-02 13:47:59 -06:00
parent a72995590b
commit 9aa1698e5a
2 changed files with 20 additions and 0 deletions

View File

@ -827,6 +827,16 @@ pub const Face = struct {
// patched with the nerd fonts patcher and it butchers the advance
// values so the advance ends up half the width of the actual glyph.
if (bounds.size.width > advance) {
var buf: [1024]u8 = undefined;
const font_name = self.name(&buf) catch "<Error getting font name>";
log.warn(
"(getMetrics) Width of glyph '水' for font \"{s}\" is greater than its advance ({d} > {d}), discarding ic_width metric.",
.{
font_name,
bounds.size.width,
advance,
},
);
break :ic_width null;
}

View File

@ -1018,6 +1018,16 @@ pub const Face = struct {
// patched with the nerd fonts patcher and it butchers the advance
// values so the advance ends up half the width of the actual glyph.
if (ft_glyph.*.metrics.width > ft_glyph.*.advance.x) {
var buf: [1024]u8 = undefined;
const font_name = self.name(&buf) catch "<Error getting font name>";
log.warn(
"(getMetrics) Width of glyph '水' for font \"{s}\" is greater than its advance ({d} > {d}), discarding ic_width metric.",
.{
font_name,
f26dot6ToF64(ft_glyph.*.metrics.width),
f26dot6ToF64(ft_glyph.*.advance.x),
},
);
break :ic_width null;
}