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.
This commit is contained in:
Alec Murphy 2025-04-15 11:45:47 -04:00
parent 0d303b0134
commit d60fc53798

View file

@ -1172,6 +1172,7 @@ I64 @get_truetype_text_width(U8* font_name, I64 size, U8* text)
CDC* dc = DCNew(Display.Width(), (size * 2)); CDC* dc = DCNew(Display.Width(), (size * 2));
Free(dc->body); Free(dc->body);
dc->body = @stbtt_RenderText(font, dc->width_internal, dc->height, ToI64(size * 1.2), text); dc->body = @stbtt_RenderText(font, dc->width_internal, dc->height, ToI64(size * 1.2), text);
dc->width -= 16;
res = X2Pos(dc) - X1Pos(dc); res = X2Pos(dc) - X1Pos(dc);
DCDel(dc); DCDel(dc);
return res; return res;