Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

do not draw the terminating \0 of a string (issue #59)

  • Loading branch information...
commit bdd9b1c44d7b391bf551cd65b1e8d42fae71f4b1 1 parent 9b42e6c
FrMo authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/font.c
6 src/font.c
View
@@ -153,6 +153,10 @@ int loadFonts() {
void drawFontLetter(float x, float y, int letter) {
+// if ((fonts[letter].id == 0) || (!glIsTexture(fonts[letter].id))) {
+// conAdd(LERR, "texture id %u for character 0x%x is invalid", fonts[letter].id, letter);
+// }
+
glBindTexture(GL_TEXTURE_2D, fonts[letter].id);
glCheck();
@@ -237,7 +241,7 @@ void drawFontWordRA(float x, float y, char *word) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- for (i = strlen(word); i >= 0; i--) {
+ for (i = strlen(word) - 1; i >= 0; i--) {
drawFontLetter(x, y, word[i]);
FrMo Collaborator
FrMo added a note

There is another bug hiding here .. before fixing the \0 string issue, the first run through the loop was preserving the space for for the rightmost letter.
Now this is not happening --> the right margin is not aligned any more (example: copyright notice).

fix: add if (strlen(word)>0) x -= fonts[(int)word[strlen(word)-1]].ow; before the loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
FrMo
Collaborator

There is another bug hiding here .. before fixing the \0 string issue, the first run through the loop was preserving the space for for the rightmost letter.
Now this is not happening --> the right margin is not aligned any more (example: copyright notice).

fix: add if (strlen(word)>0) x -= fonts[(int)word[strlen(word)-1]].ow; before the loop.

Please sign in to comment.
Something went wrong with that request. Please try again.