From bef1c78c5d299715799c54a31cca7cbed88c2a8d Mon Sep 17 00:00:00 2001 From: Alec Murphy Date: Sat, 12 Apr 2025 18:04:40 -0400 Subject: [PATCH] System/Utilities/TrueType: Change pointer type to I32* for @stbtt_RenderText() --- System/Utilities/TrueType.HC | 2 +- src/truetype/truetype.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/System/Utilities/TrueType.HC b/System/Utilities/TrueType.HC index 83ed0a9..75de182 100644 --- a/System/Utilities/TrueType.HC +++ b/System/Utilities/TrueType.HC @@ -35,7 +35,7 @@ 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, U8* word) +U8* @stbtt_RenderText(stbtt_fontinfo* info, I32 b_w, I32 b_h, I32 l_h, I32* word) { U64 reg RDI rdi = info; U64 reg RSI rsi = b_w; diff --git a/src/truetype/truetype.c b/src/truetype/truetype.c index 88c100c..32f1a00 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, char* word) +unsigned char* stbtt_RenderText(stbtt_fontinfo* info, int b_w, int b_h, int l_h, int* word) { // https://github.com/justinmeiners/stb-truetype-example /* create a bitmap for the phrase */ @@ -18,8 +18,8 @@ unsigned char* stbtt_RenderText(stbtt_fontinfo* info, int b_w, int b_h, int l_h, ascent = roundf(ascent * scale); descent = roundf(descent * scale); - int i; - for (i = 0; i < strlen(word); ++i) { + int i = 0; + while (word[i]) { /* how wide is this character */ int ax; int lsb; @@ -44,6 +44,8 @@ unsigned char* stbtt_RenderText(stbtt_fontinfo* info, int b_w, int b_h, int l_h, int kern; kern = stbtt_GetCodepointKernAdvance(info, word[i], word[i + 1]); x += roundf(kern * scale); + + ++i; } return bitmap;