diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 2ea975a6ee..af09d02c84 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2002-12-21 Dekel Tsur + + * qfont_loader.C (isAvailable): Call to addFontPath(). + Also, add a cache. + 2002-12-20 John Levon * lyx_gui.C: fix exit to use std::exit, so we don't diff --git a/src/frontends/qt2/qfont_loader.C b/src/frontends/qt2/qfont_loader.C index e173367087..e0395b8f9d 100644 --- a/src/frontends/qt2/qfont_loader.C +++ b/src/frontends/qt2/qfont_loader.C @@ -129,6 +129,13 @@ string const symbolFamily(LyXFont::FONT_FAMILY family) } +bool isSymbolFamily(LyXFont::FONT_FAMILY family) +{ + return family >= LyXFont::SYMBOL_FAMILY && + family <= LyXFont::WASY_FAMILY; +} + + QFont const getSymbolFont(string const & family) { lyxerr[Debug::FONT] << "Looking for font family " @@ -168,7 +175,21 @@ QFont const getSymbolFont(string const & family) bool isAvailable(LyXFont const & f) { - string const tmp = symbolFamily(f.family()); + static std::vector cache(LyXFont::NUM_FAMILIES, false); + static std::vector cache_initialized(LyXFont::NUM_FAMILIES, false); + static bool first_call = true; + + LyXFont::FONT_FAMILY lyxfamily = f.family(); + if (cache_initialized[lyxfamily]) + return cache[lyxfamily]; + cache_initialized[lyxfamily] = true; + + if (first_call && isSymbolFamily(lyxfamily)) { + first_call = false; + addFontPath(); + } + + string const tmp = symbolFamily(lyxfamily); if (tmp.empty()) return false; @@ -190,6 +211,7 @@ bool isAvailable(LyXFont const & f) lyxerr[Debug::FONT] << "found family " << fromqstr(*it) << endl; + cache[lyxfamily] = true; return true; } } @@ -239,7 +261,7 @@ QFont const & qfont_loader::get(LyXFont const & f) { static bool first_call = true; - if (first_call) { + if (first_call && isSymbolFamily(f.family())) { first_call = false; addFontPath(); }