mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
font(freetype): actually take max ascii width instead of first
This commit is contained in:
@ -676,18 +676,25 @@ pub const Face = struct {
|
|||||||
// If we fail to load any visible ASCII we just use max_advance from
|
// If we fail to load any visible ASCII we just use max_advance from
|
||||||
// the metrics provided by FreeType.
|
// the metrics provided by FreeType.
|
||||||
const cell_width: f64 = cell_width: {
|
const cell_width: f64 = cell_width: {
|
||||||
|
var max: f64 = 0.0;
|
||||||
var c: u8 = ' ';
|
var c: u8 = ' ';
|
||||||
while (c < 127) : (c += 1) {
|
while (c < 127) : (c += 1) {
|
||||||
if (face.getCharIndex(c)) |glyph_index| {
|
if (face.getCharIndex(c)) |glyph_index| {
|
||||||
if (face.loadGlyph(glyph_index, .{ .render = true })) {
|
if (face.loadGlyph(glyph_index, .{ .render = true })) {
|
||||||
break :cell_width f26dot6ToF64(face.handle.*.glyph.*.advance.x);
|
max = @max(
|
||||||
} else |_| {
|
f26dot6ToF64(face.handle.*.glyph.*.advance.x),
|
||||||
// Ignore the error since we just fall back to max_advance below
|
max,
|
||||||
}
|
);
|
||||||
|
} else |_| {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break :cell_width f26dot6ToF64(size_metrics.max_advance);
|
// If we couldn't get any widths, just use FreeType's max_advance.
|
||||||
|
if (max == 0.0) {
|
||||||
|
break :cell_width f26dot6ToF64(size_metrics.max_advance);
|
||||||
|
}
|
||||||
|
|
||||||
|
break :cell_width max;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The OS/2 table does not include sCapHeight or sxHeight in version 1.
|
// The OS/2 table does not include sCapHeight or sxHeight in version 1.
|
||||||
|
Reference in New Issue
Block a user