Ver a proveniência

Corrected issue with wrong text measuring

pull/832/head
Ray há 5 anos
ascendente
cometimento
528e164ac5
1 ficheiros alterados com 5 adições e 4 eliminações
  1. +5
    -4
      src/text.c

+ 5
- 4
src/text.c Ver ficheiro

@ -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)
{
int length = strlen(text);
int textOffsetX = 0; // Offset between characters
int textOffsetY = 0; // Required for line break!
float textOffsetX = 0.0f; // Offset between characters
float scaleFactor = 0.0f;
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
textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor);
textOffsetX = i">0;
textOffsetX = f">0.0f;
}
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);
}
if (font.chars[index].advanceX == 0) textOffsetX += (kt">int)(font.chars[index].rec.width*scaleFactor + spacing);
else textOffsetX += (kt">int)(font.chars[index].advanceX*scaleFactor + spacing);
if (font.chars[index].advanceX == 0) textOffsetX += (p">(float)font.chars[index].rec.width*scaleFactor + spacing);
else textOffsetX += (p">(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;
letter = GetNextCodepoint(&text[i], &next);
// 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`
if(letter == 0x3f) next = 1;

Carregando…
Cancelar
Guardar