From b0b5a097bb79eec709eeafe8df062e8d47c6677e Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 7 Jul 2010 20:16:53 +0000 Subject: [PATCH] fix font loading bug causing E0xx glyphs to get zero size git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10275 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_draw.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/gl_draw.c b/gl_draw.c index 63896464..fe798831 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -546,7 +546,7 @@ static float snap_to_pixel_x(float x, float roundUpAt); extern int con_linewidth; // to force rewrapping void LoadFont(qboolean override, const char *name, dp_font_t *fnt, float scale, float voffset) { - int i; + int i, ch; float maxwidth; char widthfile[MAX_QPATH]; char *widthbuf; @@ -610,16 +610,16 @@ void LoadFont(qboolean override, const char *name, dp_font_t *fnt, float scale, dpsnprintf(widthfile, sizeof(widthfile), "%s.width", fnt->texpath); // unspecified width == 1 (base width) - for(i = 1; i < 256; ++i) - fnt->width_of[i] = 1; + for(ch = 0; ch < 256; ++ch) + fnt->width_of[ch] = 1; // FIXME load "name.width", if it fails, fill all with 1 if((widthbuf = (char *) FS_LoadFile(widthfile, tempmempool, true, &widthbufsize))) { float extraspacing = 0; const char *p = widthbuf; - int ch = 0; + ch = 0; while(ch < 256) { if(!COM_ParseToken_Simple(&p, false, false)) @@ -641,17 +641,6 @@ void LoadFont(qboolean override, const char *name, dp_font_t *fnt, float scale, case '-': case '.': fnt->width_of[ch] = atof(com_token) + extraspacing; - if (fnt->ft2) - { - for (i = 0; i < MAX_FONT_SIZES; ++i) - { - //Font_MapForIndex(fnt->ft2, i)->width_of[ch] = snap_to_pixel_x(fnt->width_of[ch] * fnt->req_sizes[i], 0.4); - ft2_font_map_t *map = Font_MapForIndex(fnt->ft2, i); - if (!map) - break; - map->width_of[ch] = Font_SnapTo(fnt->width_of[ch], 1/map->size); - } - } ch++; break; default: @@ -680,8 +669,20 @@ void LoadFont(qboolean override, const char *name, dp_font_t *fnt, float scale, Mem_Free(widthbuf); } - maxwidth = fnt->width_of[1]; - for(i = 2; i < 256; ++i) + if(fnt->ft2) + { + for (i = 0; i < MAX_FONT_SIZES; ++i) + { + ft2_font_map_t *map = Font_MapForIndex(fnt->ft2, i); + if (!map) + break; + for(ch = 0; ch < 256; ++ch) + map->width_of[ch] = Font_SnapTo(fnt->width_of[ch], 1/map->size); + } + } + + maxwidth = fnt->width_of[0]; + for(i = 1; i < 256; ++i) maxwidth = max(maxwidth, fnt->width_of[i]); fnt->maxwidth = maxwidth; -- 2.39.2