freetype: fix underline position calculation

This commit is contained in:
Qwerasd
2024-09-23 22:30:59 -06:00
parent 7a1d304fa9
commit ac68686036

View File

@ -668,13 +668,18 @@ pub const Face = struct {
// The underline position. This is a value from the top where the
// underline should go.
const underline_position: f32 = underline_pos: {
// From the FreeType docs:
// > `underline_position`
// > The position, in font units, of the underline line for
// > this face. It is the center of the underlining stem.
const declared_px = @as(f32, @floatFromInt(freetype.mulFix(
face.handle.*.underline_position,
@intCast(face.handle.*.size.*.metrics.y_scale),
))) / 64;
// We use the declared underline position if its available
const declared = cell_height - cell_baseline - declared_px;
const declared = @ceil(cell_height - cell_baseline - declared_px - underline_thickness * 0.5 + 1);
if (declared > 0)
break :underline_pos declared;