Corrected issue with wrong text measuring
This commit is contained in:
parent
80c8599e81
commit
528e164ac5
1 changed files with 5 additions and 4 deletions
|
@ -833,8 +833,8 @@ void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
|
||||||
void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
|
void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
|
||||||
{
|
{
|
||||||
int length = strlen(text);
|
int length = strlen(text);
|
||||||
int textOffsetX = 0; // Offset between characters
|
|
||||||
int textOffsetY = 0; // Required for line break!
|
int textOffsetY = 0; // Required for line break!
|
||||||
|
float textOffsetX = 0.0f; // Offset between characters
|
||||||
float scaleFactor = 0.0f;
|
float scaleFactor = 0.0f;
|
||||||
|
|
||||||
int letter = 0; // Current character
|
int letter = 0; // Current character
|
||||||
|
@ -856,7 +856,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
|
||||||
{
|
{
|
||||||
// NOTE: Fixed line spacing of 1.5 lines
|
// NOTE: Fixed line spacing of 1.5 lines
|
||||||
textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor);
|
textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor);
|
||||||
textOffsetX = 0;
|
textOffsetX = 0.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -869,8 +869,8 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
|
||||||
font.chars[index].rec.height*scaleFactor }, (Vector2){ 0, 0 }, 0.0f, tint);
|
font.chars[index].rec.height*scaleFactor }, (Vector2){ 0, 0 }, 0.0f, tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font.chars[index].advanceX == 0) textOffsetX += (int)(font.chars[index].rec.width*scaleFactor + spacing);
|
if (font.chars[index].advanceX == 0) textOffsetX += ((float)font.chars[index].rec.width*scaleFactor + spacing);
|
||||||
else textOffsetX += (int)(font.chars[index].advanceX*scaleFactor + spacing);
|
else textOffsetX += ((float)font.chars[index].advanceX*scaleFactor + spacing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1053,6 +1053,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
|
||||||
|
|
||||||
int next = 1;
|
int next = 1;
|
||||||
letter = GetNextCodepoint(&text[i], &next);
|
letter = GetNextCodepoint(&text[i], &next);
|
||||||
|
|
||||||
// NOTE: normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
|
// NOTE: normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
|
||||||
// but we need to draw all of the bad bytes using the '?' symbol so to not skip any we set `next = 1`
|
// but we need to draw all of the bad bytes using the '?' symbol so to not skip any we set `next = 1`
|
||||||
if(letter == 0x3f) next = 1;
|
if(letter == 0x3f) next = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue