make FontInfo & fontinfo(LyXFont const & f) inline

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10249 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2005-07-16 16:13:08 +00:00
parent 7e08de938a
commit a5b556bdd6
2 changed files with 17 additions and 25 deletions

View File

@ -342,25 +342,13 @@ int FontInfo::width(Uchar val) const
} }
FontInfo & FontLoader::fontinfo(LyXFont const & f)
{
FontInfo * fi = fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
if (fi)
return *fi;
FontInfo * fi2 = new FontInfo(f);
fontinfo_[f.family()][f.series()][f.realShape()][f.size()] = fi2;
return *fi2;
}
bool FontLoader::available(LyXFont const & f) bool FontLoader::available(LyXFont const & f)
{ {
if (!lyx_gui::use_gui) if (!lyx_gui::use_gui)
return false; return false;
static vector<bool> cache_set(LyXFont::NUM_FAMILIES, false); static vector<int> cache_set(LyXFont::NUM_FAMILIES, false);
static vector<bool> cache(LyXFont::NUM_FAMILIES, false); static vector<int> cache(LyXFont::NUM_FAMILIES, false);
LyXFont::FONT_FAMILY family = f.family(); LyXFont::FONT_FAMILY family = f.family();
if (cache_set[family]) if (cache_set[family])
@ -368,16 +356,14 @@ bool FontLoader::available(LyXFont const & f)
cache_set[family] = true; cache_set[family] = true;
string const pat = symbolFamily(family); string const pat = symbolFamily(family);
if (!pat.empty()) { if (pat.empty())
pair<QFont, bool> tmp = getSymbolFont(pat); // We don't care about non-symbol fonts
if (tmp.second) {
cache[family] = true;
return true;
}
return false; return false;
}
// We don't care about non-symbol fonts pair<QFont, bool> tmp = getSymbolFont(pat);
return false; if (!tmp.second)
return false;
cache[family] = true;
return true;
} }

View File

@ -79,7 +79,13 @@ public:
static void addToFontPath(); static void addToFontPath();
/// get font info (font + metrics) for the given LyX font. Does not fail. /// get font info (font + metrics) for the given LyX font. Does not fail.
FontInfo & fontinfo(LyXFont const & f); FontInfo & fontinfo(LyXFont const & f) {
FontInfo * & fi =
fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
if (!fi)
fi = new FontInfo(f);
return *fi;
}
private: private:
/// BUTT ugly ! /// BUTT ugly !