fix(D.2b): pixel-snap dat-font glyphs so vitals numbers stay sharp on resize

DrawStringDat placed each glyph quad at the raw (often fractional) pen/origin.
When a bar resizes to a fractional width, the centered cur/max number lands on a
sub-pixel x and the glyph atlas (linear-filtered) smears — the 'unsharp at certain
sizes' artifact. Round each glyph's destination to whole pixels (the pen keeps its
true fractional advance, so spacing is unaffected) — matches retail blitting glyphs
to integer dest. User-confirmed sharp across resize widths.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-15 18:31:58 +02:00
parent 43064bab09
commit 34243f2c26

View file

@ -97,8 +97,13 @@ public sealed class UiRenderContext
if (!font.TryGetGlyph(text[i], out var g)) if (!font.TryGetGlyph(text[i], out var g))
continue; continue;
float gx = pen + g.HorizontalOffsetBefore; // Pixel-snap each glyph's destination to whole pixels so the atlas samples
float gy = originY + g.VerticalOffsetBefore; // texel-aligned. Without this, a fractional bar width after resize puts the
// centered number on a sub-pixel x and linear filtering smears the glyphs
// (the "unsharp at certain sizes" artifact). The pen keeps its true
// fractional advance, so only the per-glyph dest is snapped.
float gx = System.MathF.Round(pen + g.HorizontalOffsetBefore);
float gy = System.MathF.Round(originY + g.VerticalOffsetBefore);
float gw = g.Width; float gw = g.Width;
float gh = g.Height; float gh = g.Height;