diff --git a/System/Utilities/TrueType.HC b/System/Utilities/TrueType.HC index 75de182..9185ae9 100644 --- a/System/Utilities/TrueType.HC +++ b/System/Utilities/TrueType.HC @@ -35,14 +35,15 @@ I32 @stbtt_InitFont(stbtt_fontinfo* info, U8* data, I32 offset) } } -U8* @stbtt_RenderText(stbtt_fontinfo* info, I32 b_w, I32 b_h, I32 l_h, I32* word) +U8* @stbtt_RenderText(stbtt_fontinfo* info, I32 b_w, I32 b_h, I32 l_h, I32* word, I32* advance = NULL) { U64 reg RDI rdi = info; U64 reg RSI rsi = b_w; U64 reg RDX rdx = b_h; U64 reg RCX rcx = l_h; U64 reg R8 r8 = word; - no_warn rdi, rsi, rdx, rcx, r8; + U64 reg R9 r9 = advance; + no_warn rdi, rsi, rdx, rcx, r8, r9; asm { MOV RAX, STBTT_RENDERTEXT CALL RAX diff --git a/src/truetype/truetype.c b/src/truetype/truetype.c index 32f1a00..964c118 100644 --- a/src/truetype/truetype.c +++ b/src/truetype/truetype.c @@ -1,7 +1,7 @@ #define STB_TRUETYPE_IMPLEMENTATION #include "stb_truetype.h" -unsigned char* stbtt_RenderText(stbtt_fontinfo* info, int b_w, int b_h, int l_h, int* word) +unsigned char* stbtt_RenderText(stbtt_fontinfo* info, int b_w, int b_h, int l_h, int* word, int* advance) { // https://github.com/justinmeiners/stb-truetype-example /* create a bitmap for the phrase */ @@ -45,6 +45,10 @@ unsigned char* stbtt_RenderText(stbtt_fontinfo* info, int b_w, int b_h, int l_h, kern = stbtt_GetCodepointKernAdvance(info, word[i], word[i + 1]); x += roundf(kern * scale); + if (advance) { + advance[i] = x; + } + ++i; }