From a5b556bdd6a5bd411d119018d5e7d0edb2064e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sat, 16 Jul 2005 16:13:08 +0000 Subject: [PATCH] make FontInfo & fontinfo(LyXFont const & f) inline git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10249 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/qfont_loader.C | 34 ++++++++++---------------------- src/frontends/qt2/qfont_loader.h | 8 +++++++- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/frontends/qt2/qfont_loader.C b/src/frontends/qt2/qfont_loader.C index b1e7312722..026a9a599e 100644 --- a/src/frontends/qt2/qfont_loader.C +++ b/src/frontends/qt2/qfont_loader.C @@ -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) { if (!lyx_gui::use_gui) return false; - static vector cache_set(LyXFont::NUM_FAMILIES, false); - static vector cache(LyXFont::NUM_FAMILIES, false); + static vector cache_set(LyXFont::NUM_FAMILIES, false); + static vector cache(LyXFont::NUM_FAMILIES, false); LyXFont::FONT_FAMILY family = f.family(); if (cache_set[family]) @@ -368,16 +356,14 @@ bool FontLoader::available(LyXFont const & f) cache_set[family] = true; string const pat = symbolFamily(family); - if (!pat.empty()) { - pair tmp = getSymbolFont(pat); - if (tmp.second) { - cache[family] = true; - return true; - } - + if (pat.empty()) + // We don't care about non-symbol fonts return false; - } - // We don't care about non-symbol fonts - return false; + pair tmp = getSymbolFont(pat); + if (!tmp.second) + return false; + + cache[family] = true; + return true; } diff --git a/src/frontends/qt2/qfont_loader.h b/src/frontends/qt2/qfont_loader.h index a640ecb31d..c0b401547e 100644 --- a/src/frontends/qt2/qfont_loader.h +++ b/src/frontends/qt2/qfont_loader.h @@ -79,7 +79,13 @@ public: static void addToFontPath(); /// 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: /// BUTT ugly !