+ PuFontMap::iterator it, end = _puFonts.end();
+ for (it = _puFonts.begin(); it != end; ++it)
+ delete it->second;
+}
+
+inline bool FGFontCache::FntParamsLess::operator()(const FntParams& f1,
+ const FntParams& f2) const
+{
+ int comp = f1.name.compare(f2.name);
+ if (comp < 0)
+ return true;
+ else if (comp > 0)
+ return false;
+ if (f1.size < f2.size)
+ return true;
+ else if (f1.size > f2.size)
+ return false;
+ return f1.slant < f2.slant;
+}
+
+struct FGFontCache::fnt *
+FGFontCache::getfnt(const char *name, float size, float slant)
+{
+ string fontName(name);
+ FntParams fntParams(fontName, size, slant);
+ PuFontMap::iterator i = _puFonts.find(fntParams);
+ if (i != _puFonts.end())
+ return i->second;
+ // fntTexFont s are all preloaded into the _texFonts map
+ TexFontMap::iterator texi = _texFonts.find(fontName);
+ fntTexFont* texfont = 0;
+ puFont* pufont = 0;
+ if (texi != _texFonts.end()) {
+ texfont = texi->second;
+ } else {
+ const GuiFont* guifont = std::find_if(&guifonts[0], guifontsEnd,
+ GuiFont::Predicate(name));
+ if (guifont != guifontsEnd) {
+ pufont = guifont->font;
+ }
+ }
+ fnt* f = new fnt;
+ if (pufont) {
+ f->pufont = pufont;
+ } else if (texfont) {
+ f->texfont = texfont;
+ f->pufont = new puFont;
+ f->pufont->initialize(static_cast<fntFont *>(f->texfont), size, slant);
+ } else {
+ f->pufont = guifonts[0].font;
+ }
+ _puFonts[fntParams] = f;
+ return f;