Simplified progressing through a UTF-8 string in ImageTextEx and MeasureTextEx. This change matches existing precedent in DrawTextEx
This commit is contained in:
parent
ed02fbd369
commit
41e9eda790
|
|
@ -1201,7 +1201,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
|
|||
int letter = 0; // Current character
|
||||
int index = 0; // Index position in sprite font
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
for (int i = 0; i < size;)
|
||||
{
|
||||
byteCounter++;
|
||||
|
||||
|
|
@ -1209,7 +1209,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
|
|||
letter = GetCodepointNext(&text[i], &next);
|
||||
index = GetGlyphIndex(font, letter);
|
||||
|
||||
i += next - 1;
|
||||
i += next;
|
||||
|
||||
if (letter != '\n')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user