From 34243f2c2619d1bd528a51a38b63e387365cad41 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 15 Jun 2026 18:31:58 +0200 Subject: [PATCH] fix(D.2b): pixel-snap dat-font glyphs so vitals numbers stay sharp on resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/AcDream.App/UI/UiRenderContext.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/AcDream.App/UI/UiRenderContext.cs b/src/AcDream.App/UI/UiRenderContext.cs index 39727a0d..db23174d 100644 --- a/src/AcDream.App/UI/UiRenderContext.cs +++ b/src/AcDream.App/UI/UiRenderContext.cs @@ -97,8 +97,13 @@ public sealed class UiRenderContext if (!font.TryGetGlyph(text[i], out var g)) continue; - float gx = pen + g.HorizontalOffsetBefore; - float gy = originY + g.VerticalOffsetBefore; + // Pixel-snap each glyph's destination to whole pixels so the atlas samples + // 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 gh = g.Height;