From c53eb280d4beaca035212a1e6b80206bf4bae225 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Tue, 16 Jun 2026 20:27:38 +0200 Subject: [PATCH] Fix DrawCharHeight ceiling division to prevent missing pixels on thin strokes at small sizes --- Utils/CanvasExtensions.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Utils/CanvasExtensions.cs b/Utils/CanvasExtensions.cs index 5a2b23e..560f67d 100644 --- a/Utils/CanvasExtensions.cs +++ b/Utils/CanvasExtensions.cs @@ -91,32 +91,28 @@ public static class CanvasExtensions byte[] data = font.Data; int targetWidth = width * targetHeight / height; - int bytesPerRow = (width + 7) / 8; int p = height * bytesPerRow * (byte)c; for (int cy = 0; cy < height; cy++) { int startY = cy * targetHeight / height; - int endY = (cy + 1) * targetHeight / height; + int endY = ((cy + 1) * targetHeight + height - 1) / height; - for (byte cx = 0; cx < width; cx++) + for (int cx = 0; cx < width; cx++) { byte byteValue = data[p + (cy * bytesPerRow) + (cx / 8)]; if (font.ConvertByteToBitAddress(byteValue, (cx % 8) + 1)) { int startX = cx * targetWidth / width; - int endX = (cx + 1) * targetWidth / width; + int endX = ((cx + 1) * targetWidth + width - 1) / width; for (int sy = startY; sy < endY; sy++) { for (int sx = startX; sx < endX; sx++) { - canvas.DrawPoint( - color, - (ushort)(x + sx), - (ushort)(y + sy)); + canvas.DrawPoint(color, (ushort)(x + sx), (ushort)(y + sy)); } } }