System/Libraries/Graphics2D: Update @get_truetype_text_width() to include advance

This commit is contained in:
Alec Murphy 2025-04-19 10:42:26 -04:00
parent 78ba717732
commit 546fd54a62

View file

@ -1180,7 +1180,7 @@ I64 Y2Pos(CDC* src)
return -1;
}
I64 @get_truetype_text_width(U8* font_name, I64 size, U8* text)
I64 @get_truetype_text_width(U8* font_name, I64 size, I32* text, I32* advance = NULL)
{
stbtt_fontinfo* font = Fonts->@(font_name);
if (!font) {
@ -1189,7 +1189,7 @@ I64 @get_truetype_text_width(U8* font_name, I64 size, U8* text)
I64 res = 0;
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->body = @stbtt_RenderText(font, dc->width_internal, dc->height, ToI64(size * 1.2), text, advance);
dc->width -= 16;
res = X2Pos(dc) - X1Pos(dc);
DCDel(dc);