mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix math fonts problem
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6329 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
60322bc9d7
commit
88969c910b
@ -1,3 +1,8 @@
|
||||
2003-03-03 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* qfont_loader.C (available): Rewrite as the old version did not
|
||||
work properly.
|
||||
|
||||
2003-02-28 Alfredo Braunstein <abraunst@libero.it>
|
||||
|
||||
* QLImage.C
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <qstringlist.h>
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <qwidget.h>
|
||||
#include <X11/Xlib.h>
|
||||
@ -33,7 +35,9 @@
|
||||
#endif
|
||||
|
||||
using std::endl;
|
||||
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
using std::make_pair;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -135,7 +139,7 @@ bool isSymbolFamily(LyXFont::FONT_FAMILY family)
|
||||
}
|
||||
|
||||
|
||||
QFont const getSymbolFont(string const & family)
|
||||
pair<QFont, bool> const getSymbolFont(string const & family)
|
||||
{
|
||||
lyxerr[Debug::FONT] << "Looking for font family "
|
||||
<< family << " ... ";
|
||||
@ -148,14 +152,14 @@ QFont const getSymbolFont(string const & family)
|
||||
// Note Qt lies about family, so we use rawName.
|
||||
if (contains(fromqstr(font.rawName()), family)) {
|
||||
lyxerr[Debug::FONT] << " got it !" << endl;
|
||||
return font;
|
||||
return make_pair<QFont, bool>(font, true);
|
||||
}
|
||||
|
||||
font.setFamily(toqstr(upper));
|
||||
|
||||
if (contains(fromqstr(font.rawName()), upper)) {
|
||||
lyxerr[Debug::FONT] << " got it (uppercase version) !" << endl;
|
||||
return font;
|
||||
return make_pair<QFont, bool>(font, true);
|
||||
}
|
||||
|
||||
// A simple setFamily() fails on Qt 2
|
||||
@ -164,61 +168,13 @@ QFont const getSymbolFont(string const & family)
|
||||
|
||||
if (contains(fromqstr(font.rawName()), family)) {
|
||||
lyxerr[Debug::FONT] << " got it (raw version) !" << endl;
|
||||
return font;
|
||||
return make_pair<QFont, bool>(font, true);
|
||||
}
|
||||
|
||||
lyxerr[Debug::FONT] << " FAILED :-(" << endl;
|
||||
return font;
|
||||
return make_pair<QFont, bool>(font, false);
|
||||
}
|
||||
|
||||
|
||||
bool isAvailable(LyXFont const & f)
|
||||
{
|
||||
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;
|
||||
|
||||
QString const family(toqstr(tmp));
|
||||
|
||||
lyxerr[Debug::FONT] << "Family " << tmp
|
||||
<< " isAvailable ?";
|
||||
|
||||
QFontDatabase db;
|
||||
// pass false for match-locale: LaTeX fonts
|
||||
// do not have non-matching locale according
|
||||
// to Qt 2
|
||||
QStringList sl(db.families(false));
|
||||
|
||||
for (QStringList::Iterator it = sl.begin(); it != sl.end(); ++it) {
|
||||
// Case-insensitive for Cmmi10 vs. cmmi10
|
||||
if ((*it).lower().startsWith(family.lower())) {
|
||||
lyxerr[Debug::FONT]
|
||||
<< "found family "
|
||||
<< fromqstr(*it) << endl;
|
||||
cache[lyxfamily] = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
lyxerr[Debug::FONT] << " no." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
@ -258,16 +214,7 @@ void qfont_loader::update()
|
||||
|
||||
QFont const & qfont_loader::get(LyXFont const & f)
|
||||
{
|
||||
static bool first_call = true;
|
||||
|
||||
if (first_call && isSymbolFamily(f.family())) {
|
||||
first_call = false;
|
||||
addFontPath();
|
||||
}
|
||||
|
||||
QFont const & ret(getfontinfo(f)->font);
|
||||
|
||||
return ret;
|
||||
return getfontinfo(f)->font;
|
||||
}
|
||||
|
||||
|
||||
@ -277,7 +224,8 @@ qfont_loader::font_info::font_info(LyXFont const & f)
|
||||
|
||||
string const pat = symbolFamily(f.family());
|
||||
if (!pat.empty()) {
|
||||
font = getSymbolFont(pat);
|
||||
bool tmp;
|
||||
boost::tie(font, tmp) = getSymbolFont(pat);
|
||||
} else {
|
||||
switch (f.family()) {
|
||||
case LyXFont::ROMAN_FAMILY:
|
||||
@ -377,5 +325,41 @@ bool qfont_loader::available(LyXFont const & f)
|
||||
if (!lyxrc.use_gui)
|
||||
return false;
|
||||
|
||||
return isAvailable(f);
|
||||
static vector<bool> cache_set(LyXFont::NUM_FAMILIES, false);
|
||||
static vector<bool> cache(LyXFont::NUM_FAMILIES, false);
|
||||
|
||||
LyXFont::FONT_FAMILY family = f.family();
|
||||
if (cache_set[family])
|
||||
return cache[family];
|
||||
cache_set[family] = true;
|
||||
|
||||
string const pat = symbolFamily(family);
|
||||
if (!pat.empty()) {
|
||||
pair<QFont, bool> tmp = getSymbolFont(pat);
|
||||
if (tmp.second) {
|
||||
cache[family] = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the font is a tex symbol font and it is not available,
|
||||
// we try to add the xfonts directory to the font path.
|
||||
static bool first_time = true;
|
||||
if (!first_time || family == LyXFont::SYMBOL_FAMILY
|
||||
|| family == LyXFont::WASY_FAMILY)
|
||||
return false;
|
||||
|
||||
first_time = false;
|
||||
addFontPath();
|
||||
tmp = getSymbolFont(pat);
|
||||
if (tmp.second) {
|
||||
cache[family] = true;
|
||||
return true;
|
||||
}
|
||||
// We don't need to set cache[family] to false, as it
|
||||
//is initialized to false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// We don't care about non-symbol fonts
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user