1
0
Fork 0

FGFontCache: add getter for the fntTexFont component of a cached font

This commit is contained in:
mfranz 2006-06-06 12:49:42 +00:00
parent d8cd8f96aa
commit 355f86d6cf
2 changed files with 22 additions and 7 deletions

View file

@ -383,6 +383,7 @@ FGColor::merge(const FGColor *color)
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// FGFontCache class. // FGFontCache class.
@ -416,8 +417,8 @@ FGFontCache::~FGFontCache()
_fonts.clear(); _fonts.clear();
} }
puFont * struct FGFontCache::fnt *
FGFontCache::get(const char *name, float size, float slant) FGFontCache::getfnt(const char *name, float size, float slant)
{ {
if (!_initialized) { if (!_initialized) {
char *envp = ::getenv("FG_FONTS"); char *envp = ::getenv("FG_FONTS");
@ -432,10 +433,10 @@ FGFontCache::get(const char *name, float size, float slant)
for (int i=0; guifonts[i].name; i++) for (int i=0; guifonts[i].name; i++)
_fonts[guifonts[i].name] = new fnt(guifonts[i].font); _fonts[guifonts[i].name] = new fnt(guifonts[i].font);
_itt_t it;
_itt_t it;
if ((it = _fonts.find(name)) != _fonts.end()) if ((it = _fonts.find(name)) != _fonts.end())
return it->second->pufont; return it->second;
SGPath path(_path); SGPath path(_path);
path.append(name); path.append(name);
@ -446,12 +447,23 @@ FGFontCache::get(const char *name, float size, float slant)
if (f->texfont->load((char *)path.c_str())) { if (f->texfont->load((char *)path.c_str())) {
f->pufont = new puFont; f->pufont = new puFont;
f->pufont->initialize(static_cast<fntFont *>(f->texfont), size, slant); f->pufont->initialize(static_cast<fntFont *>(f->texfont), size, slant);
_fonts[name] = f; return _fonts[name] = f;
return f->pufont;
} }
delete f; delete f;
return _fonts["default"]->pufont; return _fonts["default"];
}
puFont *
FGFontCache::get(const char *name, float size, float slant)
{
return getfnt(name, size, slant)->pufont;
}
fntTexFont *
FGFontCache::getTexFont(const char *name, float size, float slant)
{
return getfnt(name, size, slant)->texfont;
} }
puFont * puFont *

View file

@ -304,6 +304,7 @@ private:
map<const string,fnt *> _fonts; map<const string,fnt *> _fonts;
typedef map<const string,fnt *>::const_iterator _itt_t; typedef map<const string,fnt *>::const_iterator _itt_t;
bool _initialized; bool _initialized;
struct fnt *getfnt(const char *name, float size, float slant);
public: public:
FGFontCache(); FGFontCache();
@ -311,6 +312,8 @@ public:
puFont *get(const char *name, float size=15.0, float slant=0.0); puFont *get(const char *name, float size=15.0, float slant=0.0);
puFont *get(SGPropertyNode *node); puFont *get(SGPropertyNode *node);
fntTexFont *getTexFont(const char *name, float size=15.0, float slant=0.0);
}; };