|
|
KText is responsible for drawing bitmapped text.
|
KText::KText( char *fontName , KFont *table )
|
Initialises a KText instance ( using the constructor )
Example :
KText *myfont ;
myfont = new KText( KMiscTools::makeFilePath( "font.tga" ), fonttablePtr ) ; |
void setFontTable( KFont *fontTable )
|
sets the default font table to use with the bitmap.
Example :
KFont fontTablePtr[] ={
{ 'a',10,8,18,17,9,10 } ,
{ 'b',22,8,30,17,9,10 } ,
{ 'c',32,8,41,17,10,10 } ,
etc....
{0,0,0,0,0,0,0}
}
myFont->setFontTable( fontTablePtr ) ;
|
void KText::loadFontBitmap( char *font_Filename )
|
loads a bitmap and associates it with the font.
Example :
KText myFont ;
myFont.loadFontBitmap( KMiscTools::makeFilePath( "superfont.tga" ) ) ;
|
| void drawStringFromLeft( char *txt , long x , long y, long kerning = 0 ) |
Draws a string at the specified X and Y coordinnates.
The Kerning parameter enables you to set the spacing between characters.
Example :
KText *myFont ;
myFont = new KText( KMiscTools::MakeFilePath( "font.tga") , fontTablePtr ) ;
myFont->drawStringFromLeft( "A beautiful text" ,100,100,2) ;
It's also possible to pass an integer value to be displayed ( floats not supported )
long score = 12850 ;
myFont->drawStringFromLeft( score ,100,100,2) ;
|
| void drawStringFromRight( char *txt , long x , long y, long kerning = 0 ) |
Draws a string at the specified X and Y coordinates being the right of the string. ( right aligned )
The Kerning parameter enables you to set the spacing between characters.
Example :
KText *myFont ;
myFont = new KText( KMiscTools::MakeFilePath( "font.tga") , fontTablePtr ) ;
myFont->drawStringFromRight( "A beautiful text" ,100,100,2) ;
|
| void drawStringCentered( char *txt , long x1,long x2 , long y, long kerning = 0 ) |
Draws a string at centered into the specified X1 and X2 range ( if possible ) and at Y coordinnates.
The Kerning parameter enables you to set the spacing between characters.
Example :
KText *myFont ;
myFont = new KText( KMiscTools::MakeFilePath( "font.tga") , fontTabePtr ) ;
myFont->drawStringCentered( "A beautiful text" ,100,500,100,2) ;
|
| long getStringWidth( char *txt , long kerning = 0 ) |
| Returns the width of a string in the current font.
Example :
long stringWidthInPixels = myFont->getStringWidth("A beautiful text" , 2 ) ;
|
|
setColor( float r , float g , float b , float blendFactor )
|
sets the blit color and the opacity of the drawn text ( 0 to 1 )
myText->setColor( 1,0,0,1 ) ; //will draw your text in red if it was a white bitmap.
|
|