diff --git a/src/font.c b/src/font.c
index 17a5a71..ccf0311 100644
--- a/src/font.c
+++ b/src/font.c
@@ -228,7 +228,7 @@ int gl_printText(const glFont* ft_font, const int width, const int height,
       // Time to draw the line.
       m = 0;
       for(j = 0; j < (lastspace-p-1); j++) {
-        m += ft_font->w[(int)buf[j]];
+        m += ft_font->w[(int)txt[p+j+1]];
         if(m > width) break;
         buf[j] = txt[p+j+1];
       }