fshake3d
0.0.1
FreeformDensity3DSurfaceEditor
|
00001 #include "ui_fonts.hpp" 00002 #include <iostream> 00003 00004 Font::Font() 00005 { 00006 const char* windir_path = getenv("windir"); 00007 char buf[1024]; 00008 sprintf(buf, "%s\\fonts\\arial.ttf", windir_path); 00009 00010 mpFTGLPixmapFont = new FTGLPixmapFont( buf /*"C:\\windows\\fonts\\arial.ttf"*/ ); 00011 mpFTGLPixmapFont->FaceSize(12); 00012 } 00013 00014 double Font::computeWidth(const char* text) 00015 { 00016 double w( mpFTGLPixmapFont->Advance(text) ); 00017 return w; 00018 } 00019 00020 double Font::getAscender() const 00021 { 00022 return double( mpFTGLPixmapFont->Ascender() ); 00023 } 00024 00025 double Font::getDescender() const 00026 { 00027 return double( mpFTGLPixmapFont->Ascender() ); 00028 } 00029 00030 00031 void Font::draw(const char* text) 00032 { 00033 mpFTGLPixmapFont->Render(text); 00034 } 00035 00036 #if 0 00037 00038 Font* FontCache::getDefaultFont() 00039 { 00040 if (mpDefaultFont == 0) 00041 { 00042 mpDefaultFont = loadFont( FontInfo("") ); 00043 } 00044 } 00045 00046 Font* FontCache::getFont(const FontInfo& fontinfo) 00047 { 00048 std::map<FontInfo, Font*>::iterator i = mFontMap.find(fontinfo); 00049 if (i != mFontMap.end() ) 00050 { 00051 return i->second; 00052 } 00053 else 00054 { 00055 Font* pFont = loadFont(fontinfo); 00056 if (!pFont) 00057 { 00058 pFont = getDefaultFont(); 00059 } 00060 if (pFont) 00061 { 00062 mFontMap.insert( fontinfo, pFont ); 00063 } 00064 } 00065 } 00066 00067 #endif