From 74b7a22b6eac24a9254d8091db555548e599e44e Mon Sep 17 00:00:00 2001 From: Allanis Date: Wed, 20 Mar 2013 23:17:40 +0000 Subject: [PATCH] [Fix] Font width issues.. --- src/font.c | 9 ++++----- src/land.c | 12 ++++++------ src/menu.c | 8 ++++---- src/player.c | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/font.c b/src/font.c index 649b224..bd220f7 100644 --- a/src/font.c +++ b/src/font.c @@ -279,6 +279,7 @@ static void glFontMakeDList(FT_Face face, char ch, GLuint list_base, GLubyte* expanded_data; int w, h; int i, j; + double x, y; if(FT_Load_Glyph(face, FT_Get_Char_Index(face, ch), FT_LOAD_FORCE_AUTOHINT)) WARN("FT_Load_Glyph failed"); @@ -324,11 +325,8 @@ static void glFontMakeDList(FT_Face face, char ch, GLuint list_base, glTranslated(bitmap_glyph->left, bitmap_glyph->top-bitmap.rows, 0); // Take the opengl POT wrapping into account. - double x = (double)bitmap.width/(double)w; - double y = (double)bitmap.rows/(double)h; - - // Give the width a value. - width_base[(int)ch] = bitmap.width; + x = (double)bitmap.width/(double)w; + y = (double)bitmap.rows/(double)h; // Draw the texture mapped quad. glBindTexture(GL_TEXTURE_2D, tex_base[(int)ch]); @@ -345,6 +343,7 @@ static void glFontMakeDList(FT_Face face, char ch, GLuint list_base, glPopMatrix(); glTranslated(face->glyph->advance.x >> 6, 0,0); + width_base[(int)ch] = (int)(face->glyph->advance.x >> 6); // End of the display list. glEndList(); diff --git a/src/land.c b/src/land.c index cde1459..5b5b2fd 100644 --- a/src/land.c +++ b/src/land.c @@ -97,8 +97,8 @@ static void commodity_exchange(void) { window_addText(secondary_wid, -20, -40, BUTTON_WIDTH/2, 20, 0, "txtDInfo", &gl_smallFont, &cBlack, NULL); - window_addText(secondary_wid, -40, -80, BUTTON_WIDTH-20, 60, 0, - "txtDesc", &gl_smallFont, &cBlack, NULL); + window_addText(secondary_wid, -40, -80, BUTTON_WIDTH-20, + BUTTON_WIDTH, 0, "txtDesc", &gl_smallFont, &cBlack, NULL); goods = malloc(sizeof(char*)*planet->ncommodities); for(i = 0; i < planet->ncommodities; i++) @@ -219,7 +219,7 @@ static void outfits(void) { 250, 96, 0, "txtDDesc", &gl_smallFont, &cBlack, NULL); window_addText(secondary_wid, 20+200+40, -200, - OUTFITS_WIDTH-360, 200, 0, "txtDescription", + OUTFITS_WIDTH-300, 200, 0, "txtDescription", &gl_smallFont, NULL, NULL); // Set up the outfits to buy/sell. @@ -401,7 +401,7 @@ static void shipyard(void) { window_addText(secondary_wid, 20+200+40, -160, - SHIPYARD_WIDTH-360, 200, 0, "txtDescription", + SHIPYARD_WIDTH-300, 200, 0, "txtDescription", &gl_smallFont, NULL, NULL); // Setup the ships to buy/sell. @@ -474,7 +474,7 @@ static void spaceport_bar(void) { secondary_wid = window_create("SpacePort Bar", -1, -1, BAR_WIDTH, BAR_HEIGHT); window_addText(secondary_wid, 20, -30, - BAR_WIDTH-140, BAR_HEIGHT - 40 - BUTTON_HEIGHT, 0, + BAR_WIDTH-40, BAR_HEIGHT - 40 - BUTTON_HEIGHT, 0, "txtDescription", &gl_smallFont, &cBlack, planet->bar_description); window_addButton(secondary_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, @@ -524,7 +524,7 @@ void land(Planet* p) { // Pretty display. window_addImage(land_wid, 20, -40, "imgPlanet", p->gfx_exterior); - window_addText(land_wid, 440, 80, 200, 460, 0, + window_addText(land_wid, 440, 80, LAND_WIDTH-460, 460, 0, "txtPlanetDesc", &gl_smallFont, &cBlack, p->description); // Buttons. window_addButton(land_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, diff --git a/src/menu.c b/src/menu.c index 79c51b5..1b8327f 100644 --- a/src/menu.c +++ b/src/menu.c @@ -10,10 +10,10 @@ #include "player.h" #include "menu.h" -#define MAIN_WIDTH 120 +#define MAIN_WIDTH 130 #define MAIN_HEIGHT 250 -#define MENU_WIDTH 120 +#define MENU_WIDTH 130 #define MENU_HEIGHT 200 #define INFO_WIDTH 320 @@ -22,10 +22,10 @@ #define OUTFITS_WIDTH 400 #define OUTFITS_HEIGHT 200 -#define DEATH_WIDTH 120 +#define DEATH_WIDTH 130 #define DEATH_HEIGHT 150 -#define BUTTON_WIDTH 80 +#define BUTTON_WIDTH 90 #define BUTTON_HEIGHT 30 #define menu_Open(f) (menu_open |= (f)) diff --git a/src/player.c b/src/player.c index 6693226..5c4be41 100644 --- a/src/player.c +++ b/src/player.c @@ -542,7 +542,7 @@ void player_render(void) { credits2str(str, player_credits, 2); i = gl_printWidth(&gl_smallFont, str); - gl_print(&gl_smallFont, gui.misc.x + gui.misc.w - 15 - i, j, + gl_print(&gl_smallFont, gui.misc.x + gui.misc.w - 8 - i, j, NULL, str); // Cargo and co.