font: remove fudge factors in ul and st position calculations

These were present because of an incorrect calculation in the underline
sprite renderer, and are no longer necessary.
This commit is contained in:
Qwerasd
2024-09-25 12:01:24 -06:00
parent 9a87001fa6
commit 003b100707
2 changed files with 7 additions and 8 deletions

View File

@ -612,9 +612,8 @@ pub const Face = struct {
// we subtract half of the ex height to go back up to the
// correct height that should evenly split lowercase text.
const pos = layout_metrics.ascent -
ex_height * 0.5 +
strikethrough_thickness * 0.5 +
1;
ex_height * 0.5 -
strikethrough_thickness * 0.5;
break :strikethrough_position @ceil(pos);
};
@ -625,7 +624,7 @@ pub const Face = struct {
// The final underline position is +y from the TOP (confusing)
// so we have to subtract from the cell height.
const underline_position = @ceil(layout_metrics.ascent -
@as(f32, @floatCast(ct_font.getUnderlinePosition())) + 1);
@as(f32, @floatCast(ct_font.getUnderlinePosition())));
// Note: is this useful?
// const units_per_em = ct_font.getUnitsPerEm();

View File

@ -678,8 +678,8 @@ pub const Face = struct {
@intCast(face.handle.*.size.*.metrics.y_scale),
))) / 64;
// We use the declared underline position if its available
const declared = @ceil(cell_height - cell_baseline - declared_px - underline_thickness * 0.5 + 1);
// We use the declared underline position if its available.
const declared = @ceil(cell_height - cell_baseline - declared_px - underline_thickness * 0.5);
if (declared > 0)
break :underline_pos declared;
@ -702,13 +702,13 @@ pub const Face = struct {
))) / 64;
break :st .{
.pos = @ceil(cell_height - cell_baseline - pos + thickness + 1),
.pos = @ceil(cell_height - cell_baseline - pos),
.thickness = thickness,
};
} else .{
// Exactly 50% of the ex height so that our strikethrough is
// centered through lowercase text. This is a common choice.
.pos = @ceil(cell_height - cell_baseline - ex_height * 0.5 + underline_thickness),
.pos = @ceil(cell_height - cell_baseline - ex_height * 0.5 - underline_thickness * 0.5),
.thickness = underline_thickness,
};