font: fix sign of usWinDescent interpretation (#2960)

comment explains

In the future we should probably find or craft example fonts that have
weird metrics in their tables and make unit tests for them.
This commit is contained in:
Mitchell Hashimoto
2024-12-13 10:50:37 -08:00
committed by GitHub
2 changed files with 6 additions and 2 deletions

View File

@ -647,7 +647,9 @@ pub const Face = struct {
const win_descent: f64 = @floatFromInt(os2.usWinDescent);
break :vertical_metrics .{
win_ascent * px_per_unit,
win_descent * px_per_unit,
// usWinDescent is *positive* -> down unlike sTypoDescender
// and hhea.Descender, so we flip its sign to fix this.
-win_descent * px_per_unit,
0.0,
};
};

View File

@ -689,7 +689,9 @@ pub const Face = struct {
const win_descent: f64 = @floatFromInt(os2.usWinDescent);
break :vertical_metrics .{
win_ascent * px_per_unit,
win_descent * px_per_unit,
// usWinDescent is *positive* -> down unlike sTypoDescender
// and hhea.Descender, so we flip its sign to fix this.
-win_descent * px_per_unit,
0.0,
};
};