[Plib-cvs] CVS: plib/src/pui puFont.cxx,1.12,1.13
Brought to you by:
sjbaker
From: Sebastian U. <ud...@us...> - 2002-03-02 17:47:30
|
Update of /cvsroot/plib/plib/src/pui In directory usw-pr-cvs1:/tmp/cvs-serv4160 Modified Files: puFont.cxx Log Message: Changed getStringHeight () behaviour with textured fonts Index: puFont.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puFont.cxx,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- puFont.cxx 2 Mar 2002 14:36:24 -0000 1.12 +++ puFont.cxx 2 Mar 2002 17:47:25 -0000 1.13 @@ -96,6 +96,20 @@ } +static int count_lines ( const char *str ) +{ + int k = 0 ; + + if ( str != NULL ) + { + for ( k = 1 ; *str != '\0' ; str++ ) + if ( *str == '\n' ) + k++ ; + } + + return k ; +} + #ifdef _PU_USE_GLUT_FONTS static int getGLUTStringHeight ( GlutFont glut_font_handle ) { @@ -121,21 +135,16 @@ if ( glut_font_handle != (GlutFont) 0 ) { int i = getGLUTStringHeight ( glut_font_handle ) + getStringDescender () ; - int num_lines = 1 ; - for ( const char *p = s ; *p != '\0' ; p++ ) - if ( *p == '\n' ) - num_lines++ ; - - return ( i * num_lines ) - getStringDescender () ; + return ( i * count_lines ( s ) ) - getStringDescender () ; } #endif // #ifdef _PU_USE_GLUT_FONTS if ( fnt_font_handle != NULL ) { - float t, b ; - fnt_font_handle -> getBBox ( s, pointsize, slant, NULL, NULL, &b, &t ) ; - return (int) t ; + float i = pointsize * 1.333f ; + + return (int) ( ( i * count_lines ( s ) ) - ( 0.333f * pointsize ) ) ; } return 0 ; |