rFontContainer Class Reference

List of all members.

Public Member Functions

void clear ()
float GetWidth (tString const &str, float height)
void Render (tString const &str, float height, tCoord const &where)
FTFont & GetFont (float height)
void BBox (tString const &str, float height, tCoord where, float &l, float &b, float &r, float &t)
 ~rFontContainer ()

Private Member Functions

FTFont & New (int size)
FTFont * Load (tString const &path)


Detailed Description

Definition at line 203 of file rFont.cpp.


Constructor & Destructor Documentation

rFontContainer::~rFontContainer (  )  [inline]

Definition at line 291 of file rFont.cpp.

00291                       {
00292         clear();
00293     }


Member Function Documentation

FTFont & rFontContainer::New ( int  size  )  [private]

Definition at line 333 of file rFont.cpp.

References customFont, tDirectories::Data(), fontFile, tPath::GetReadPath(), and Load().

00333                                     {
00334     FTFont *font;
00335     tString theFontFile("");
00336 
00337     if(useCustomFont == 1) {
00338         theFontFile = customFont;
00339     } else {
00340         theFontFile = "textures/" + fontFile;
00341         theFontFile = tDirectories::Data().GetReadPath(theFontFile);
00342     }
00343     font = Load(theFontFile);
00344     //std::cout << "Use custom font: " << useCustomFont << std::endl;
00345     //std::cout << "The font file: " << theFontFile << std::endl;
00346     if(font->Error()) {
00347         std::cerr << "Error while loading font from path '" << theFontFile << "'. Error code: " << font->Error() << std::endl;
00348         //delete font;
00349         std::cerr << "Loading default font instead.  Sorry." << std::endl;
00350         font = Load(tDirectories::Data().GetReadPath("textures/Armagetronad.ttf"));
00351 
00352     }
00353     font->FaceSize(size);
00354     (*this)[size] = font;
00355     return *font;
00356 }

Here is the call graph for this function:

FTFont * rFontContainer::Load ( tString const &  path  )  [private]

Definition at line 309 of file rFont.cpp.

References sr_fontBitmap, sr_fontExtruded, sr_fontOutline, sr_fontPixmap, and sr_fontPolygon.

Referenced by New().

00309                                                 {
00310     FTFont *font;
00311     switch (sr_fontType) {
00312     case sr_fontPixmap:
00313         font = new FTGLPixmapFont(path);
00314         break;
00315     case sr_fontBitmap:
00316         font = new FTGLBitmapFont(path);
00317         break;
00318     case sr_fontPolygon:
00319         font = new FTGLPolygonFont(path);
00320         break;
00321     case sr_fontOutline:
00322         font = new FTGLOutlineFont(path);
00323         break;
00324     case sr_fontExtruded:
00325         font = new FTGLExtrdFont(path);
00326         reinterpret_cast<FTGLExtrdFont *>(font)->Depth(10.);
00327         break;
00328     default:
00329         font = new FTGLTextureFont(path);
00330     }
00331     return font;
00332 }

Here is the caller graph for this function:

void rFontContainer::clear (  )  [inline]

Definition at line 207 of file rFont.cpp.

Referenced by sr_ReloadFont().

00207                  {
00208         for(iterator i = begin(); i != end(); ++i) {
00209             delete i->second;
00210         }
00211         std::map<int, FTFont *>::clear();
00212     }

Here is the caller graph for this function:

float rFontContainer::GetWidth ( tString const &  str,
float  height 
) [inline]

Definition at line 213 of file rFont.cpp.

References sr_bigFontThresholdHeight, sr_fontPixmap, sr_screenHeight, and sr_screenWidth.

Referenced by rTextField::FlushLine(), rTextField::GetTextLength(), and rTextField::StringOutput().

00213                                                      {
00214         if(sr_fontType == sr_fontPixmap) {
00215             return height*(height*sr_screenHeight < sr_bigFontThresholdHeight ? .41 : .5)*str.size();
00216         }
00217         return GetFont(height).Advance(str.c_str())/sr_screenWidth*2.;
00218     }

Here is the caller graph for this function:

void rFontContainer::Render ( tString const &  str,
float  height,
tCoord const &  where 
) [inline]

Definition at line 219 of file rFont.cpp.

References rFont::Render(), rFont::s_defaultFont, rFont::s_defaultFontSmall, rITexture::Select(), sr_bigFontThresholdHeight, sr_fontExtruded, sr_fontOld, sr_fontTexture, sr_screenHeight, sr_screenWidth, rTextureGroups::TEX_WALL, tCoord::x, and tCoord::y.

Referenced by rTextField::FlushLine().

00219                                                                        {
00220         if (sr_fontType != sr_fontOld) {
00221             if(sr_fontType >= sr_fontTexture) {
00222                 glPushMatrix();
00223                 glTranslatef(where.x, where.y, 0.);
00224                 glScalef(2./sr_screenWidth, 2./sr_screenHeight, 1.);
00225                 if(sr_fontType == sr_fontTexture) {
00226                     glEnable(GL_TEXTURE_2D);
00227                     glEnable(GL_BLEND);
00228                     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00229                 }
00230                 if(sr_fontType == sr_fontExtruded) {
00231                     glEnable( GL_DEPTH_TEST);
00232                     glDisable( GL_BLEND);
00233                     glEnable(GL_TEXTURE_2D);
00234                     static rFileTexture sg_RimWallNoWrap(rTextureGroups::TEX_WALL,"textures/dir_wall.png",1,0);
00235                     sg_RimWallNoWrap.Select();
00236                     glRotatef(45,1.,0.,0.);
00237                 }
00238             } else {
00239                 glRasterPos2f(where.x, where.y);
00240             }
00241             GetFont(height).Render(str.c_str());
00242             if(sr_fontType >= sr_fontTexture) {
00243                 glPopMatrix();
00244             }
00245         } else {
00246             rFont *font;
00247             float widthFactor;
00248             if (height*sr_screenHeight < sr_bigFontThresholdHeight) {
00249                 font = &rFont::s_defaultFontSmall;
00250                 widthFactor = .41;
00251             } else {
00252                 font = &rFont::s_defaultFont;
00253                 widthFactor = .5;
00254             }
00255             float left = where.x;
00256             for(tString::const_iterator i = str.begin(); i < str.end(); ++i, left += height*widthFactor) {
00257                 //void rFont::Render(unsigned char c,REAL left,REAL top,REAL right,REAL bot){
00258                 font->Render(*i, left, where.y+height, left+widthFactor*height, where.y);
00259                 //F->Render(buffer[realx],l,t,l+cwidth,t-cheight);
00260             }
00261         }
00262     }

Here is the call graph for this function:

Here is the caller graph for this function:

FTFont& rFontContainer::GetFont ( float  height  )  [inline]

Definition at line 263 of file rFont.cpp.

References sr_screenHeight.

00263                                   {
00264         int size = int(height*sr_fontSizeFactor*sr_screenHeight/2.+.5);
00265         if(count(size)) {
00266             return *((*this)[size]); //already exists
00267         } else {
00268             return New(size);
00269         }
00270     }

void rFontContainer::BBox ( tString const &  str,
float  height,
tCoord  where,
float &  l,
float &  b,
float &  r,
float &  t 
) [inline]

Definition at line 271 of file rFont.cpp.

References sr_fontOld, sr_screenHeight, sr_screenWidth, tCoord::x, and tCoord::y.

Referenced by rTextField::FlushLine().

00271                                                                                                       {
00272         if(sr_fontType != sr_fontOld) {
00273             float rubbish;
00274             GetFont(height).BBox(str.c_str(), l, b, rubbish, r, t, rubbish);
00275             l/=sr_screenWidth/2.;
00276             r/=sr_screenWidth/2.;
00277             t/=sr_screenHeight/2.;
00278             b/=sr_screenHeight/2.;
00279             l+=where.x-0.005;
00280             r+=where.x+0.005;
00281             t+=where.y+0.005;
00282             b+=where.y-0.005;
00283             return;
00284         } else {
00285             l=where.x;
00286             r=where.x+GetWidth(str, height);
00287             b=where.y;
00288             t=where.y+height;
00289         }
00290     }

Here is the caller graph for this function:


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:52:38 2008 for Armagetron Advanced by  doxygen 1.5.4