use font line height instead of created size to determine line height

This commit is contained in:
Josh Holtrop 2014-06-08 14:22:11 -04:00
parent 37f954292c
commit 71926f325d

View File

@ -40,17 +40,18 @@ void display(SDL_Window * window)
glVertex3f(10.0, 210.0, 0.0);
glVertex3f(10.0, 202.0, 0.0);
glEnd();
font->Render("abcdefghijklmnopqrstuvwxyz", -1, FTPoint(10, HEIGHT - FONT_SIZE, 0));
font->Render("ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, FTPoint(10, HEIGHT - FONT_SIZE * 2, 0));
float line_height = font->LineHeight();
font->Render("abcdefghijklmnopqrstuvwxyz", -1, FTPoint(10, HEIGHT - line_height, 0));
font->Render("ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, FTPoint(10, HEIGHT - line_height * 2, 0));
for (int i = 0; i < 26; i++)
{
char s[2];
s[0] = 'A' + i;
s[1] = '\0';
float advance = font->Advance("M");
font->Render(s, -1, FTPoint(10 + advance * i, HEIGHT - FONT_SIZE * 3, 0));
font->Render(s, -1, FTPoint(10 + advance * i, HEIGHT - line_height * 3, 0));
}
font->Render("0123456789", -1, FTPoint(10, HEIGHT - FONT_SIZE * 4, 0));
font->Render("0123456789", -1, FTPoint(10, HEIGHT - line_height * 4, 0));
SDL_GL_SwapWindow(window);
}