diff options
| author | Ray <[email protected]> | 2019-05-06 10:17:34 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-05-06 10:17:34 +0200 |
| commit | 528e164ac5e1a4ecca404c7f54e98325a55b959f (patch) | |
| tree | ca8f7c8d9f42031f87a65d9d74f890f9ab438d82 /src | |
| parent | 80c8599e818fe765f6129bcdb2fda859c8f193cb (diff) | |
| download | raylib-528e164ac5e1a4ecca404c7f54e98325a55b959f.tar.gz raylib-528e164ac5e1a4ecca404c7f54e98325a55b959f.zip | |
Corrected issue with wrong text measuring
Diffstat (limited to 'src')
| -rw-r--r-- | src/text.c | 9 |
1 files changed, 5 insertions, 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) { 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 = 0; + textOffsetX = 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 += (int)(font.chars[index].rec.width*scaleFactor + spacing); - else textOffsetX += (int)(font.chars[index].advanceX*scaleFactor + spacing); + if (font.chars[index].advanceX == 0) textOffsetX += ((float)font.chars[index].rec.width*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; 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; |
