System/Utilities/TrueType: Update stbtt_RenderText() API to include advance

This commit is contained in:
Alec Murphy 2025-04-19 10:41:55 -04:00
parent 33b795fa93
commit 78ba717732
2 changed files with 8 additions and 3 deletions

View file

@ -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;
}