[Fix] Fixed some font regressions.

This commit is contained in:
Allanis 2014-03-04 00:34:44 +00:00
parent 4d3dfd5637
commit cccb8cbff3

View File

@ -75,7 +75,8 @@ int gl_printWidthForText(const glFont* ft_font, char* txt,
int i, n, lastspace; int i, n, lastspace;
if(ft_font == NULL) ft_font = &gl_defFont; if(ft_font == NULL)
ft_font = &gl_defFont;
/* Limit size per line. */ /* Limit size per line. */
lastspace = 0; /* last ' ' or '\n' in the text. */ lastspace = 0; /* last ' ' or '\n' in the text. */
@ -312,7 +313,7 @@ int gl_printText(const glFont* ft_font, const int width, const int height,
else COLOUR(*c); else COLOUR(*c);
p = 0; /* Where we last drew up to. */ p = 0; /* Where we last drew up to. */
while(by - y < 0) { while(y - by > -1e-5) {
i = gl_printWidthForText(ft_font, &txt[p], width); i = gl_printWidthForText(ft_font, &txt[p], width);
glMatrixMode(GL_MODELVIEW); /* Using MODELVIEW, PROJECTION gets full fast. */ glMatrixMode(GL_MODELVIEW); /* Using MODELVIEW, PROJECTION gets full fast. */
@ -395,17 +396,21 @@ int gl_printHeight(const glFont* ft_font, const int width,
vsprintf(txt, fmt, ap); vsprintf(txt, fmt, ap);
va_end(ap); va_end(ap);
} }
if(txt[0] == '\0')
return 0;
y = 0.; y = 0.;
p = 0; p = 0;
while(1) { do {
i = gl_printWidthForText(ft_font, &txt[p], width); i = gl_printWidthForText(ft_font, &txt[p], width);
if(txt[p+i] == '\0') if(txt[p+i] == '\0')
break; break;
p += i + 1; p += i + 1;
y += 1.5*(double)ft_font->h; /* Move position down. */ y += 1.5*(double)ft_font->h; /* Move position down. */
} } while(txt[p-1] != '\0');
return (int)(y - 0.5*(double)ft_font->h); return (int)(y - 0.5*(double)ft_font->h);
} }