Simplified progressing through a UTF-8 string in ImageTextEx and MeasureTextEx. This change matches existing precedent in DrawTextEx

This commit is contained in:
anon 2023-04-02 11:09:04 +01:00
commit 41e9eda790

View file

@ -1266,7 +1266,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
// Create image to store text
imText = GenImageColor((int)imSize.x, (int)imSize.y, BLANK);
for (int i = 0; i < size; i++)
for (int i = 0; i < size;)
{
// Get next codepoint from byte string and glyph index in font
int codepointByteCount = 0;
@ -1292,7 +1292,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
else textOffsetX += font.glyphs[index].advanceX + (int)spacing;
}
i += (codepointByteCount - 1); // Move text bytes counter to next codepoint
i += codepointByteCount; // Move text bytes counter to next codepoint
}
// Scale image depending on text size