From d60fc53798e6f03d32e1c22562c77fc8d8277112 Mon Sep 17 00:00:00 2001 From: Alec Murphy Date: Tue, 15 Apr 2025 11:45:47 -0400 Subject: [PATCH] System/Libraries/Graphics2D: Chop 16px off X2 max pos in @get_truetype_text_width() This is a quick and dirty hack to compensate for artifacts at the far right edge of the font rasterization buffer. Chopping off 16px allows us to get the proper width of the rasterized text. --- System/Libraries/Graphics2D.HC | 1 + 1 file changed, 1 insertion(+) diff --git a/System/Libraries/Graphics2D.HC b/System/Libraries/Graphics2D.HC index 7433216..9681345 100644 --- a/System/Libraries/Graphics2D.HC +++ b/System/Libraries/Graphics2D.HC @@ -1172,6 +1172,7 @@ I64 @get_truetype_text_width(U8* font_name, I64 size, U8* text) CDC* dc = DCNew(Display.Width(), (size * 2)); Free(dc->body); dc->body = @stbtt_RenderText(font, dc->width_internal, dc->height, ToI64(size * 1.2), text); + dc->width -= 16; res = X2Pos(dc) - X1Pos(dc); DCDel(dc); return res;