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
parent ed02fbd369
commit 41e9eda790
2 changed files with 4 additions and 4 deletions

View File

@ -1201,7 +1201,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
int letter = 0; // Current character int letter = 0; // Current character
int index = 0; // Index position in sprite font int index = 0; // Index position in sprite font
for (int i = 0; i < size; i++) for (int i = 0; i < size;)
{ {
byteCounter++; byteCounter++;
@ -1209,7 +1209,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
letter = GetCodepointNext(&text[i], &next); letter = GetCodepointNext(&text[i], &next);
index = GetGlyphIndex(font, letter); index = GetGlyphIndex(font, letter);
i += next - 1; i += next;
if (letter != '\n') if (letter != '\n')
{ {

View File

@ -1266,7 +1266,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
// Create image to store text // Create image to store text
imText = GenImageColor((int)imSize.x, (int)imSize.y, BLANK); 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 // Get next codepoint from byte string and glyph index in font
int codepointByteCount = 0; 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; 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 // Scale image depending on text size