From: mfranz Date: Tue, 6 Jun 2006 12:49:42 +0000 (+0000) Subject: FGFontCache: add getter for the fntTexFont component of a cached font X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=355f86d6cf13e2eafeee87f360c4c23901933692;p=flightgear.git FGFontCache: add getter for the fntTexFont component of a cached font --- diff --git a/src/GUI/new_gui.cxx b/src/GUI/new_gui.cxx index 6c51dd122..4f4b65b98 100644 --- a/src/GUI/new_gui.cxx +++ b/src/GUI/new_gui.cxx @@ -383,6 +383,7 @@ FGColor::merge(const FGColor *color) } + //////////////////////////////////////////////////////////////////////// // FGFontCache class. @@ -416,8 +417,8 @@ FGFontCache::~FGFontCache() _fonts.clear(); } -puFont * -FGFontCache::get(const char *name, float size, float slant) +struct FGFontCache::fnt * +FGFontCache::getfnt(const char *name, float size, float slant) { if (!_initialized) { 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++) _fonts[guifonts[i].name] = new fnt(guifonts[i].font); - _itt_t it; + _itt_t it; if ((it = _fonts.find(name)) != _fonts.end()) - return it->second->pufont; + return it->second; SGPath path(_path); path.append(name); @@ -446,12 +447,23 @@ FGFontCache::get(const char *name, float size, float slant) if (f->texfont->load((char *)path.c_str())) { f->pufont = new puFont; f->pufont->initialize(static_cast(f->texfont), size, slant); - _fonts[name] = f; - return f->pufont; + return _fonts[name] = 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 * diff --git a/src/GUI/new_gui.hxx b/src/GUI/new_gui.hxx index 12f44401a..0957564f4 100644 --- a/src/GUI/new_gui.hxx +++ b/src/GUI/new_gui.hxx @@ -304,6 +304,7 @@ private: map _fonts; typedef map::const_iterator _itt_t; bool _initialized; + struct fnt *getfnt(const char *name, float size, float slant); public: FGFontCache(); @@ -311,6 +312,8 @@ public: puFont *get(const char *name, float size=15.0, float slant=0.0); puFont *get(SGPropertyNode *node); + + fntTexFont *getTexFont(const char *name, float size=15.0, float slant=0.0); };