[Change] No idea why I even made them while(1) in the first place..

This commit is contained in:
Allanis 2014-02-11 05:02:57 +00:00
parent 5fcf3bbc92
commit 3b3450213a

View File

@ -34,7 +34,7 @@ static void glFontMakeDList(FT_Face face, char ch,
GLuint list_base, GLuint* tex_base,
int* width_base);
static int font_limitSize(const glFont* ft_font, int* width,
char* text, const int max);
char* txt, const int max);
/**
* @brief Limits the text to max.
@ -70,7 +70,7 @@ static int font_limitSize(const glFont* ft_font, int* width,
* @param width Width to match.
* @return Number of characters that fit.
*/
int gl_printWidthForText(const glFont* ft_font, char* text,
int gl_printWidthForText(const glFont* ft_font, char* txt,
const int width) {
int i, n, lastspace;
@ -81,30 +81,28 @@ int gl_printWidthForText(const glFont* ft_font, char* text,
lastspace = 0; /* last ' ' or '\n' in the text. */
n = 0; /* Current width. */
i = 0; /* Current position. */
while(1) {
/* Check if we found an EOL character. */
if((text[i] == '\n') || (text[i] == '\0'))
return i;
while((txt[i] != '\n') && (txt[i] != '\0')) {
/* Characters we should ignore. */
if(text[i] == '\t')
if(txt[i] == '\t') {
i++;
continue;
}
/* Increase size. */
n += ft_font->w[(int)text[i]];
n += ft_font->w[(int)txt[i]];
/* Save last space. */
if(text[i] == ' ')
if(txt[i] == ' ')
lastspace = i;
/* Check if out of bounds. */
if(n > width)
break;
return lastspace;
/* Check next character. */
i++;
}
return lastspace;
return i;
}
/**
@ -314,7 +312,7 @@ int gl_printText(const glFont* ft_font, const int width, const int height,
else COLOUR(*c);
p = 0; /* Where we last drew up to. */
while(1) {
while(by - y < 0) {
i = gl_printWidthForText(ft_font, &txt[p], width);
glMatrixMode(GL_MODELVIEW); /* Using MODELVIEW, PROJECTION gets full fast. */
@ -329,8 +327,6 @@ int gl_printText(const glFont* ft_font, const int width, const int height,
break;
p += i + 1;
y -= 1.5*(double)ft_font->h; /* Move position down. */
if(by - y > (double)height)
break;
}
glDisable(GL_TEXTURE_2D);