Call to addFontPath() in isAvailable

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5888 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2002-12-21 11:41:29 +00:00
parent 8a8724129a
commit 45dbf3c19f
2 changed files with 29 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2002-12-21 Dekel Tsur <dekelts@tau.ac.il>
* qfont_loader.C (isAvailable): Call to addFontPath().
Also, add a cache.
2002-12-20 John Levon <levon@movementarian.org>
* lyx_gui.C: fix exit to use std::exit, so we don't

View File

@ -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<bool> cache(LyXFont::NUM_FAMILIES, false);
static std::vector<bool> 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();
}