[Plib-cvs] plib/src/fnt fnt.cxx,1.7,1.8 fnt.h,1.5,1.6 fntTXF.cxx,1.14,1.15
Brought to you by:
sjbaker
From: Sebastian U. <ud...@us...> - 2002-08-15 00:04:46
|
Update of /cvsroot/plib/plib/src/fnt In directory usw-pr-cvs1:/tmp/cvs-serv12620 Modified Files: fnt.cxx fnt.h fntTXF.cxx Log Message: Andy Ross: Modified FNT to handle character widths correctly Index: fnt.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/fnt/fnt.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- fnt.cxx 12 Dec 2001 23:49:36 -0000 1.7 +++ fnt.cxx 15 Aug 2002 00:04:42 -0000 1.8 @@ -102,14 +102,14 @@ curpos[2] ) ; glEnd () ; - float ww = ( gap + ( fixed_pitch ? width : v_right[cc] ) ) * pointsize ; + float ww = ( gap + ( fixed_pitch ? width : widths[cc] ) ) * pointsize ; curpos[0] += ww ; return ww ; } -void fntTexFont::setGlyph ( char c, +void fntTexFont::setGlyph ( char c, float wid, float tex_left, float tex_right, float tex_bot , float tex_top , float vtx_left, float vtx_right, @@ -119,6 +119,8 @@ exists[cc] = FNT_TRUE ; + widths[cc] = wid; + t_left[cc] = tex_left ; t_right[cc] = tex_right ; t_bot [cc] = tex_bot ; t_top [cc] = tex_top ; @@ -127,7 +129,7 @@ } -int fntTexFont::getGlyph ( char c, +int fntTexFont::getGlyph ( char c, float* wid, float *tex_left, float *tex_right, float *tex_bot , float *tex_top , float *vtx_left, float *vtx_right, @@ -137,6 +139,8 @@ if ( ! exists[cc] ) return FNT_FALSE ; + if ( wid != NULL ) *wid = widths [cc] ; + if ( tex_left != NULL ) *tex_left = t_left [cc] ; if ( tex_right != NULL ) *tex_right = t_right[cc] ; if ( tex_bot != NULL ) *tex_bot = t_bot [cc] ; @@ -209,7 +213,7 @@ if ( b > v_pos + v_bot [cc] ) b = v_pos + v_bot [cc] ; if ( t < v_pos + v_top [cc] ) t = v_pos + v_top [cc] ; - h_pos += gap + ( fixed_pitch ? width : v_right[cc] ) ; + h_pos += gap + ( fixed_pitch ? width : widths[cc] ) ; } if ( left != NULL ) *left = l * pointsize ; @@ -239,5 +243,4 @@ s++ ; } } - Index: fnt.h =================================================================== RCS file: /cvsroot/plib/plib/src/fnt/fnt.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- fnt.h 7 Nov 2001 23:51:09 -0000 1.5 +++ fnt.h 15 Aug 2002 00:04:42 -0000 1.6 @@ -59,7 +59,7 @@ virtual float getWidth () const = 0 ; virtual float getGap () const = 0 ; - virtual int hasGlyph ( char c ) = 0 ; + virtual int hasGlyph ( char c ) const = 0 ; } ; @@ -90,6 +90,10 @@ v_bot==0.0 and v_top==1.0. */ + /* Nominal baseline widths */ + + float widths [ FNTMAX_CHAR ] ; + /* Texture coordinates */ float t_top [ FNTMAX_CHAR ] ; /* Top edge of each character [0..1] */ @@ -171,19 +175,39 @@ float getGap () const { return gap ; } - void setGlyph ( char c, + void setGlyph ( char c, float wid, float tex_left, float tex_right, float tex_bot , float tex_top , float vtx_left, float vtx_right, float vtx_bot , float vtx_top ) ; + void setGlyph ( char c, + float tex_left, float tex_right, + float tex_bot , float tex_top , + float vtx_left, float vtx_right, + float vtx_bot , float vtx_top ) /* deprecated */ + { + setGlyph ( c, vtx_right, + tex_left, tex_right, tex_bot, tex_top, + vtx_left, vtx_right, vtx_bot, vtx_top ) ; + } - int getGlyph ( char c, + int getGlyph ( char c, float* wid, float *tex_left = NULL, float *tex_right = NULL, float *tex_bot = NULL, float *tex_top = NULL, float *vtx_left = NULL, float *vtx_right = NULL, float *vtx_bot = NULL, float *vtx_top = NULL) ; + int getGlyph ( char c, + float *tex_left = NULL, float *tex_right = NULL, + float *tex_bot = NULL, float *tex_top = NULL, + float *vtx_left = NULL, float *vtx_right = NULL, + float *vtx_bot = NULL, float *vtx_top = NULL) /* deprecated */ + { + return getGlyph ( c, NULL, + tex_left, tex_right, tex_bot, tex_top, + vtx_left, vtx_right, vtx_bot, vtx_top ) ; + } - int hasGlyph ( char c ) { return getGlyph ( c ) ; } + int hasGlyph ( char c ) const { return exists[ c ] ; } void getBBox ( const char *s, float pointsize, float italic, float *left, float *right, Index: fntTXF.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/fnt/fntTXF.cxx,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- fntTXF.cxx 21 Apr 2002 03:53:15 -0000 1.14 +++ fntTXF.cxx 15 Aug 2002 00:04:42 -0000 1.15 @@ -246,6 +246,7 @@ glyph . y = _fnt_readShort () ; setGlyph ( (char) glyph.ch, + (float) glyph.step / (float) max_height, (float) glyph.x / (float) w + xstep, (float)( glyph.x + glyph.w ) / (float) w + xstep, (float) glyph.y / (float) h + ystep, |