mirror of
https://git.checksum.fail/alec/erythros
synced 2025-12-10 21:19:55 +02:00
System/Libraries/Graphics2D: Update @get_truetype_text_width() to include advance
This commit is contained in:
@@ -1180,7 +1180,7 @@ I64 Y2Pos(CDC* src)
|
|||||||
return -1;
|
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);
|
stbtt_fontinfo* font = Fonts->@(font_name);
|
||||||
if (!font) {
|
if (!font) {
|
||||||
@@ -1189,7 +1189,7 @@ I64 @get_truetype_text_width(U8* font_name, I64 size, U8* text)
|
|||||||
I64 res = 0;
|
I64 res = 0;
|
||||||
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, advance);
|
||||||
dc->width -= 16;
|
dc->width -= 16;
|
||||||
res = X2Pos(dc) - X1Pos(dc);
|
res = X2Pos(dc) - X1Pos(dc);
|
||||||
DCDel(dc);
|
DCDel(dc);
|
||||||
|
|||||||
Reference in New Issue
Block a user