]> git.lyx.org Git - lyx.git/commitdiff
This commit introduces the FontLoader interface class. In the future, I intend to...
authorAbdelrazak Younes <younes@lyx.org>
Tue, 3 Oct 2006 16:17:32 +0000 (16:17 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 3 Oct 2006 16:17:32 +0000 (16:17 +0000)
* frontends/FontLoader.h: new interface class.
* frontends/Application.h: new FontLoader() pure virtual method
* frontends/lyx_gui: update_fonts() and font_available() methods deleted

* [qt3/qt4/gtk]/GuiApplication: implement the new interface

* qt4/GuiFontLoader:
  - renamed from FontLoader
  - now derives from FontLoader
  - now in the lyx::frontend namespace

* qt3/qfont_loader
  - now derives from FontLoader

* gtk/xftFontLoader
  - now derives from FontLoader

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15220 a592a061-630c-0410-9148-cb99ea01b6c8

25 files changed:
development/scons/scons_manifest.py
src/frontends/Application.h
src/frontends/FontLoader.h [new file with mode: 0644]
src/frontends/Makefile.am
src/frontends/gtk/GuiApplication.h
src/frontends/gtk/lyx_gui.C
src/frontends/gtk/xftFontLoader.h
src/frontends/lyx_gui.h
src/frontends/qt3/GuiApplication.h
src/frontends/qt3/QtView.C
src/frontends/qt3/lyx_gui.C
src/frontends/qt3/qfont_loader.C
src/frontends/qt3/qfont_loader.h
src/frontends/qt4/FontLoader.C [deleted file]
src/frontends/qt4/FontLoader.h [deleted file]
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/GuiFontLoader.C [new file with mode: 0644]
src/frontends/qt4/GuiFontLoader.h [new file with mode: 0644]
src/frontends/qt4/Makefile.am
src/frontends/qt4/QLPainter.C
src/frontends/qt4/lyx_gui.C
src/frontends/qt4/qfont_metrics.C
src/lyxfunc.C
src/mathed/MathFactory.C
src/mathed/MathSupport.C

index f4af24b58179bc594a347cb31d18ff9afb9f13e7..6edf247c948741defa8476b329bfa2eb4f7d4d69 100644 (file)
@@ -432,6 +432,7 @@ src_frontends_header_files = Split('''
     Clipboard.h
     Dialogs.h
     FileDialog.h
+    FontLoader.h
     Gui.h
     LyXKeySym.h
     LyXKeySymFactory.h
@@ -1112,9 +1113,9 @@ src_frontends_qt4_header_files = Split('''
     BulletsModule.h
     ColorCache.h
     FileDialog_private.h
-    FontLoader.h
     GuiApplication.h
     GuiClipboard.h
+    GuiFontLoader.h
     GuiImplementation.h
     GuiSelection.h
     GuiView.h
@@ -1232,9 +1233,9 @@ src_frontends_qt4_files = Split('''
     Dialogs.C
     FileDialog.C
     FileDialog_private.C
-    FontLoader.C
     GuiApplication.C
     GuiClipboard.C
+    GuiFontLoader.C
     GuiImplementation.C
     GuiSelection.C
     GuiView.C
index 0959020230e5611236345ef550f9a8ce8b62238c..d9589f8078d11dfde3b000a9867c43c9b8186675 100644 (file)
@@ -27,6 +27,7 @@ namespace frontend {
 
 struct Application_pimpl;
 class Clipboard;
+class FontLoader;
 class Gui;
 class Selection;
 
@@ -65,6 +66,8 @@ public:
        virtual Clipboard & clipboard() = 0;
        ///
        virtual Selection & selection() = 0;
+       ///
+       virtual FontLoader & fontLoader() = 0;
 
        /// return a suitable serif font name.
        virtual std::string const romanFontName() = 0;
diff --git a/src/frontends/FontLoader.h b/src/frontends/FontLoader.h
new file mode 100644 (file)
index 0000000..ea5cf73
--- /dev/null
@@ -0,0 +1,39 @@
+// -*- C++ -*-
+/**
+ * \file FontLoader.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef LYX_FONTLOADER_H
+#define LYX_FONTLOADER_H
+
+class LyXFont;
+
+namespace lyx {
+namespace frontend {
+
+/// Hold info about a particular font
+class FontLoader
+{
+public:
+       ///
+       FontLoader() {}
+       ///
+       virtual ~FontLoader() {}
+
+       /// Update fonts after zoom, dpi, font names, or norm change
+       virtual void update() = 0;
+
+       /// Is the given font available ?
+       virtual bool available(LyXFont const & f) = 0;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QFONT_LOADER_H
index 4ca77284f3eaf28059241e69171ff820e0e8a86d..cb5a5832b5dcbedd8dd74f339c386ae1dc6c1e00 100644 (file)
@@ -21,6 +21,7 @@ libfrontends_la_SOURCES = \
        Dialogs.C \
        Dialogs.h \
        FileDialog.h \
+       FontLoader.h \
        LyXKeySym.h \
        LyXKeySymFactory.h \
        LyXView.C \
index 6526729786666b0591ce502af42f406a186ee9a7..0ffaa0b4b4a620103901c82eb472adc568a89f3b 100644 (file)
@@ -50,6 +50,7 @@ public:
        //@{
        virtual Clipboard& clipboard();
        virtual Selection& selection();
+       virtual FontLoader & fontLoader() { return font_loader_; }
        virtual int const exec();
        virtual Gui & gui() { return gui_; }
        virtual void exit(int status);
@@ -59,7 +60,6 @@ public:
        //@}
 
        ///
-       xftFontLoader & fontLoader() { return font_loader_; }
 
 private:
        ///
index 6cf21913e6069a4cdfa03cd5014d57dcf7225fec..dbf06e4492954df76ccff45cea7773fa482b3ab2 100644 (file)
@@ -152,18 +152,6 @@ void lyx_gui::update_color(LColor_color /*col*/)
 }
 
 
-void lyx_gui::update_fonts()
-{
-       fontLoader.update();
-}
-
-
-bool lyx_gui::font_available(LyXFont const & font)
-{
-       return fontLoader.available(font);
-}
-
-
 namespace {
 
 std::map<int, boost::shared_ptr<io_callback> > callbacks;
index a04f11f5dfaa57f5e5f43c135acd0efbe01522f6..4c2cb086c67bd18b1d3891ae4ae7932a8ba5556b 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef XFT_FONT_LOADER_H
 #define XFT_FONT_LOADER_H
 
+#include "frontends/FontLoader.h"
+
 #include "lyxfont.h"
 
 #include <gtkmm.h>
 class GWorkArea;
 
 
-class xftFontLoader {
+class xftFontLoader: public lyx::frontend::FontLoader {
 public:
        ///
        xftFontLoader();
 
        ///
-       ~xftFontLoader();
+       virtual ~xftFontLoader();
 
        /// Update fonts after zoom, dpi, font names, or norm change
-       void update();
+       virtual void update();
 
-       bool available(LyXFont const & f);
+       virtual bool available(LyXFont const & f);
 
        /// Load font
        XftFont * load(LyXFont::FONT_FAMILY family,
index 6075a1ed96dd4bd72b8c96d884da4e5db374f72c..50628c2d877448b74f6b1c42c86f4ebbb54a991e 100644 (file)
@@ -75,16 +75,6 @@ std::string const hexname(LColor_color col);
  */
 void update_color(LColor_color col);
 
-/**
- * update the font cache
- */
-void update_fonts();
-
-/**
- * is the given font available ?
- */
-bool font_available(LyXFont const & font);
-
 /**
  * add a callback for socket read notification
  * @param fd socket descriptor (file/socket/etc)
index d56e057c5d14f7d7955fa5d107c0ece2517a5137..82eca1c87011cf3ed0d176a40490b74ad76eac9d 100644 (file)
@@ -56,6 +56,7 @@ public:
        //@{
        virtual Clipboard& clipboard();
        virtual Selection& selection();
+       virtual FontLoader & fontLoader() { return font_loader_; }
        virtual int const exec();
        virtual Gui & gui() { return gui_; }
        virtual void exit(int status);
@@ -65,8 +66,6 @@ public:
        //@}
 
        ///
-       FontLoader & fontLoader() { return font_loader_; }
-
 private:
        ///
        GuiImplementation gui_;
@@ -75,7 +74,7 @@ private:
        ///
        GuiSelection selection_;
        ///
-       FontLoader font_loader_;
+       GuiFontLoader font_loader_;
 
 #ifdef Q_WS_X11
 public:
index 9052cf3ae699597dd7d0baa091529f7941509b52..8b62a9c844a1885433f449029881e1dca65ca0d9 100644 (file)
@@ -40,7 +40,7 @@
 
 using std::string;
 
-FontLoader fontloader;
+GuiFontLoader fontloader;
 
 namespace lyx {
 
index 97895780fb8ab566a8c69883738f052406ac6c10..c6465d43d72bd265e7b041d5e5eed2a6237e3607 100644 (file)
@@ -137,18 +137,6 @@ void update_color(LColor_color)
 }
 
 
-void update_fonts()
-{
-       fontloader.update();
-}
-
-
-bool font_available(LyXFont const & font)
-{
-       return fontloader.available(font);
-}
-
-
 void register_socket_callback(int fd, boost::function<void()> func)
 {
        socket_callbacks[fd] = shared_ptr<socket_callback>(new socket_callback(fd, func));
index 7fc882a03d33a78afc553619aa89e3482266e0fb..b0906c7cb0eac5c2af6ee3c04c70a2e3da9b0b59 100644 (file)
@@ -47,7 +47,7 @@ using std::vector;
 using std::string;
 
 
-FontLoader::~FontLoader() {
+GuiFontLoader::~GuiFontLoader() {
 }
 
 namespace {
@@ -193,7 +193,7 @@ pair<QFont, bool> const getSymbolFont(string const & family)
 } // namespace anon
 
 
-FontLoader::FontLoader()
+GuiFontLoader::GuiFontLoader()
 {
        for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1)
                for (int i2 = 0; i2 < 2; ++i2)
@@ -203,7 +203,7 @@ FontLoader::FontLoader()
 }
 
 
-void FontLoader::update()
+void GuiFontLoader::update()
 {
        for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1)
                for (int i2 = 0; i2 < 2; ++i2)
@@ -307,7 +307,7 @@ int QLFontInfo::width(Uchar val)
 }
 
 
-bool FontLoader::available(LyXFont const & f)
+bool GuiFontLoader::available(LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return false;
index eadf2b46cc350e3929fa7b6cdd36fe674da4f049..d18e729ca8d88a3bfbc6d54ed7cd2e9b741196c0 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef QFONTLOADER_H
 #define QFONTLOADER_H
 
+#include "frontends/FontLoader.h"
+
 #include "encoding.h"
 #include "lyxfont.h"
 
@@ -51,19 +53,19 @@ public:
 
 
 /// Hold info about a particular font
-class FontLoader {
+class GuiFontLoader: public lyx::frontend::FontLoader {
 public:
        ///
-       FontLoader();
+       GuiFontLoader();
        
        /// Destructor
-       ~FontLoader();
+       virtual ~GuiFontLoader();
 
        /// Update fonts after zoom, dpi, font names, or norm change
-       void update();
+       virtual void update();
 
        /// Do we have anything matching?
-       bool available(LyXFont const & f);
+       virtual bool available(LyXFont const & f);
 
        /// Get the QFont for this LyXFont
        QFont const & get(LyXFont const & f) {
@@ -94,6 +96,6 @@ private:
        QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
 };
 
-extern FontLoader fontloader;
+extern GuiFontLoader fontloader;
 
 #endif // QFONT_LOADER_H
diff --git a/src/frontends/qt4/FontLoader.C b/src/frontends/qt4/FontLoader.C
deleted file mode 100644 (file)
index 4671563..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-/**
- * \file FontLoader.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger Alstrup
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "FontLoader.h"
-#include "qt_helpers.h"
-
-#include "debug.h"
-#include "lyxrc.h"
-
-#include "frontends/lyx_gui.h"
-
-#include "support/convert.h"
-#include "support/filetools.h"
-#include "support/lstrings.h"
-#include "support/systemcall.h"
-
-#include <qfontinfo.h>
-
-#include <boost/tuple/tuple.hpp>
-
-#ifdef Q_WS_X11
-#include <qwidget.h>
-#include <X11/Xlib.h>
-#include <algorithm>
-#endif
-
-using lyx::support::contains;
-
-using std::endl;
-using std::make_pair;
-
-using std::pair;
-using std::vector;
-using std::string;
-
-
-FontLoader::~FontLoader() {
-}
-
-namespace {
-
-struct symbol_font {
-       LyXFont::FONT_FAMILY lyx_family;
-       string family;
-       string xlfd;
-};
-
-symbol_font symbol_fonts[] = {
-       { LyXFont::SYMBOL_FAMILY,
-               "symbol",
-               "-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific" },
-
-       { LyXFont::CMR_FAMILY,
-               "cmr10",
-               "-*-cmr10-medium-*-*-*-*-*-*-*-*-*-*-*" },
-
-       { LyXFont::CMSY_FAMILY,
-               "cmsy10",
-               "-*-cmsy10-*-*-*-*-*-*-*-*-*-*-*-*" },
-
-       { LyXFont::CMM_FAMILY,
-               "cmmi10",
-               "-*-cmmi10-medium-*-*-*-*-*-*-*-*-*-*-*" },
-
-       { LyXFont::CMEX_FAMILY,
-               "cmex10",
-               "-*-cmex10-*-*-*-*-*-*-*-*-*-*-*-*" },
-
-       { LyXFont::MSA_FAMILY,
-               "msam10",
-               "-*-msam10-*-*-*-*-*-*-*-*-*-*-*-*" },
-
-       { LyXFont::MSB_FAMILY,
-               "msbm10",
-               "-*-msbm10-*-*-*-*-*-*-*-*-*-*-*-*" },
-
-       { LyXFont::EUFRAK_FAMILY,
-               "eufm10",
-               "-*-eufm10-medium-*-*-*-*-*-*-*-*-*-*-*" },
-
-       { LyXFont::WASY_FAMILY,
-               "wasy10",
-               "-*-wasy10-medium-*-*-*-*-*-*-*-*-*-*-*" }
-};
-
-size_t const nr_symbol_fonts = sizeof(symbol_fonts) / sizeof(symbol_font);
-
-
-string getRawName(string const & family)
-{
-       for (size_t i = 0; i < nr_symbol_fonts; ++i)
-               if (family == symbol_fonts[i].family)
-                       return symbol_fonts[i].xlfd;
-
-       lyxerr[Debug::FONT] << "BUG: family not found !" << endl;
-       return string();
-}
-
-
-string const symbolFamily(LyXFont::FONT_FAMILY family)
-{
-       for (size_t i = 0; i < nr_symbol_fonts; ++i) {
-               if (family == symbol_fonts[i].lyx_family)
-                       return symbol_fonts[i].family;
-       }
-       return string();
-}
-
-
-bool isSymbolFamily(LyXFont::FONT_FAMILY family)
-{
-       return family >= LyXFont::SYMBOL_FAMILY &&
-               family <= LyXFont::WASY_FAMILY;
-}
-
-
-bool isChosenFont(QFont & font, string const & family)
-{
-       lyxerr[Debug::FONT] << "raw: " << fromqstr(font.rawName()) << endl;
-
-       QFontInfo fi(font);
-
-       // Note Qt lies about family quite often
-       lyxerr[Debug::FONT] << "alleged fi family: "
-               << fromqstr(fi.family()) << endl;
-
-       // So we check rawName first
-       if (contains(fromqstr(font.rawName()), family)) {
-               lyxerr[Debug::FONT] << " got it ";
-               return true;
-       }
-
-       // Qt 3.2 beta1 returns "xft" for all xft fonts
-       // Qt 4.1 returns "Multi" for all ? xft fonts
-       if (font.rawName() == "xft" || font.rawName() == "Multi") {
-               if (contains(fromqstr(fi.family()), family)) {
-                       lyxerr[Debug::FONT] << " got it (Xft) ";
-                       return true;
-               }
-       }
-
-       return false;
-}
-
-
-pair<QFont, bool> const getSymbolFont(string const & family)
-{
-       lyxerr[Debug::FONT] << "Looking for font family "
-               << family << " ... ";
-       string upper = family;
-       upper[0] = toupper(family[0]);
-
-       QFont font;
-       font.setFamily(toqstr(family));
-
-       if (isChosenFont(font, family)) {
-               lyxerr[Debug::FONT] << "normal!" << endl;
-               return make_pair<QFont, bool>(font, true);
-       }
-
-       font.setFamily(toqstr(upper));
-
-       if (isChosenFont(font, upper)) {
-               lyxerr[Debug::FONT] << "upper!" << endl;
-               return make_pair<QFont, bool>(font, true);
-       }
-
-       // A simple setFamily() fails on Qt 2
-
-       font.setRawName(toqstr(getRawName(family)));
-
-       if (isChosenFont(font, family)) {
-               lyxerr[Debug::FONT] << "raw version!" << endl;
-               return make_pair<QFont, bool>(font, true);
-       }
-
-       lyxerr[Debug::FONT] << " FAILED :-(" << endl;
-       return make_pair<QFont, bool>(font, false);
-}
-
-} // namespace anon
-
-
-FontLoader::FontLoader()
-{
-       for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1)
-               for (int i2 = 0; i2 < 2; ++i2)
-                       for (int i3 = 0; i3 < 4; ++i3)
-                               for (int i4 = 0; i4 < 10; ++i4)
-                                       fontinfo_[i1][i2][i3][i4] = 0;
-}
-
-
-void FontLoader::update()
-{
-       for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1)
-               for (int i2 = 0; i2 < 2; ++i2)
-                       for (int i3 = 0; i3 < 4; ++i3)
-                               for (int i4 = 0; i4 < 10; ++i4) {
-                                       delete fontinfo_[i1][i2][i3][i4];
-                                       fontinfo_[i1][i2][i3][i4] = 0;
-                               }
-}
-
-
-/////////////////////////////////////////////////
-
-
-QLFontInfo::QLFontInfo(LyXFont const & f)
-       : metrics(font)
-{
-
-       string const pat = symbolFamily(f.family());
-       if (!pat.empty()) {
-               bool tmp;
-               boost::tie(font, tmp) = getSymbolFont(pat);
-       } else {
-               switch (f.family()) {
-               case LyXFont::ROMAN_FAMILY:
-                       font.setFamily(toqstr(makeFontName(lyxrc.roman_font_name,
-                                                   lyxrc.roman_font_foundry)));
-                       break;
-               case LyXFont::SANS_FAMILY:
-                       font.setFamily(toqstr(makeFontName(lyxrc.sans_font_name,
-                                                   lyxrc.sans_font_foundry)));
-                       break;
-               case LyXFont::TYPEWRITER_FAMILY:
-                       font.setFamily(toqstr(makeFontName(lyxrc.typewriter_font_name,
-                                                   lyxrc.typewriter_font_foundry)));
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       font.setPointSizeF(convert<double>(lyxrc.font_sizes[f.size()])
-                              * lyxrc.zoom / 100.0);
-
-       switch (f.series()) {
-               case LyXFont::MEDIUM_SERIES:
-                       font.setWeight(QFont::Normal);
-                       break;
-               case LyXFont::BOLD_SERIES:
-                       font.setWeight(QFont::Bold);
-                       break;
-               default:
-                       break;
-       }
-
-       switch (f.realShape()) {
-               case LyXFont::ITALIC_SHAPE:
-               case LyXFont::SLANTED_SHAPE:
-                       font.setItalic(true);
-                       break;
-               default:
-                       break;
-       }
-
-       if (lyxerr.debugging(Debug::FONT)) {
-               lyxerr[Debug::FONT] << "Font '" << f.stateText(0)
-                       << "' matched by\n" << fromqstr(font.rawName()) << endl;
-       }
-
-       lyxerr[Debug::FONT] << "The font has size: "
-                           << font.pointSizeF() << endl;
-
-       // Is this an exact match?
-       if (font.exactMatch())
-               lyxerr[Debug::FONT] << "This font is an exact match" << endl;
-       else
-               lyxerr[Debug::FONT] << "This font is NOT an exact match"
-                                   << endl;
-
-       lyxerr[Debug::FONT] << "XFLD: " << fromqstr(font.rawName()) << endl;
-
-       metrics = QFontMetrics(font);
-}
-
-
-int QLFontInfo::width(Uchar val)
-{
-// Starting with version 3.1.0, Qt/X11 does its own caching of
-// character width, so it is not necessary to provide ours.
-#if defined (USE_LYX_FONTCACHE)
-       QLFontInfo::WidthCache::const_iterator cit = widthcache.find(val);
-       if (cit != widthcache.end())
-               return cit->second;
-
-       int const w = metrics.width(QChar(val));
-       widthcache[val] = w;
-       return w;
-#else
-       return metrics.width(QChar(val));
-#endif
-}
-
-
-bool FontLoader::available(LyXFont const & f)
-{
-       if (!lyx_gui::use_gui)
-               return false;
-
-       static vector<int> cache_set(LyXFont::NUM_FAMILIES, false);
-       static vector<int> 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())
-               // We don't care about non-symbol fonts
-               return false;
-
-       pair<QFont, bool> tmp = getSymbolFont(pat);
-       if (!tmp.second)
-               return false;
-
-       cache[family] = true;
-       return true;
-}
diff --git a/src/frontends/qt4/FontLoader.h b/src/frontends/qt4/FontLoader.h
deleted file mode 100644 (file)
index 1a933d7..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-// -*- C++ -*-
-/**
- * \file FontLoader.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef QFONTLOADER_H
-#define QFONTLOADER_H
-
-#include "encoding.h"
-#include "lyxfont.h"
-
-#include <QFont>
-#include <QFontMetrics>
-
-//#if QT_VERSION < 0x030100
-#define USE_LYX_FONTCACHE
-//#endif
-
-#if defined(USE_LYX_FONTCACHE)
-#include <map>
-#endif
-
-/**
- * Qt font loader for LyX. Matches LyXFonts against
- * actual QFont instances, and also caches metrics.
- */
-class QLFontInfo {
-public:
-       QLFontInfo(LyXFont const & f);
-
-       /// Return pixel width for the given unicode char
-       int width(Uchar val);
-
-       /// The font instance
-       QFont font;
-       /// Metrics on the font
-       QFontMetrics metrics;
-
-#if defined(USE_LYX_FONTCACHE)
-       typedef std::map<Uchar, int> WidthCache;
-       /// Cache of char widths
-       WidthCache widthcache;
-#endif
-};
-
-
-/// Hold info about a particular font
-class FontLoader {
-public:
-       ///
-       FontLoader();
-       
-       /// Destructor
-       ~FontLoader();
-
-       /// Update fonts after zoom, dpi, font names, or norm change
-       void update();
-
-       /// Do we have anything matching?
-       bool available(LyXFont const & f);
-
-       /// Get the QFont for this LyXFont
-       QFont const & get(LyXFont const & f) {
-               return fontinfo(f).font;
-       }
-
-       /// Get the QFont metrics for this LyXFont
-       QFontMetrics const & metrics(LyXFont const & f) {
-               return fontinfo(f).metrics;
-       }
-
-       /// Called the first time when available() can't load a symbol font
-       static void addToFontPath();
-
-       /// Get font info (font + metrics) for the given LyX font.
-       QLFontInfo & fontinfo(LyXFont const & f) {
-               // fi is a reference to the pointer type (QLFontInfo *) in the
-               // fontinfo_ table.
-               QLFontInfo * & fi =
-                       fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
-               if (!fi)
-                       fi = new QLFontInfo(f);
-               return *fi;
-       }
-
-private:
-       /// BUTT ugly !
-       QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
-};
-
-#endif // QFONT_LOADER_H
index 82334a8d130fcd7c85392db96fb1ccf928a2d264..6f3acf8dda78cf05c352499ddabd8b8bd1b1cb33 100644 (file)
@@ -14,7 +14,7 @@
 #define QT4_APPLICATION_H
 
 #include "ColorCache.h"
-#include "FontLoader.h"
+#include "GuiFontLoader.h"
 #include "GuiClipboard.h"
 #include "GuiImplementation.h"
 #include "GuiSelection.h"
@@ -57,6 +57,7 @@ public:
        //@{
        virtual Clipboard& clipboard();
        virtual Selection& selection();
+       virtual FontLoader & fontLoader() { return font_loader_; }
        virtual int const exec();
        virtual Gui & gui() { return gui_; }
        virtual void exit(int status);
@@ -68,7 +69,8 @@ public:
        ///
        ColorCache & colorCache() { return color_cache_; }
        ///
-       FontLoader & fontLoader() { return font_loader_; }
+       ///
+       GuiFontLoader & guiFontLoader() { return font_loader_; }
 
 private:
        ///
@@ -78,7 +80,7 @@ private:
        ///
        GuiSelection selection_;
        ///
-       FontLoader font_loader_;
+       GuiFontLoader font_loader_;
        ///
        ColorCache color_cache_;
 
diff --git a/src/frontends/qt4/GuiFontLoader.C b/src/frontends/qt4/GuiFontLoader.C
new file mode 100644 (file)
index 0000000..3f9fe40
--- /dev/null
@@ -0,0 +1,338 @@
+/**
+ * \file GuiFontLoader.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Asger Alstrup
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiFontLoader.h"
+#include "qt_helpers.h"
+
+#include "debug.h"
+#include "lyxrc.h"
+
+#include "frontends/lyx_gui.h"
+
+#include "support/convert.h"
+#include "support/filetools.h"
+#include "support/lstrings.h"
+#include "support/systemcall.h"
+
+#include <qfontinfo.h>
+
+#include <boost/tuple/tuple.hpp>
+
+#ifdef Q_WS_X11
+#include <qwidget.h>
+#include <X11/Xlib.h>
+#include <algorithm>
+#endif
+
+using lyx::support::contains;
+
+using std::endl;
+using std::make_pair;
+
+using std::pair;
+using std::vector;
+using std::string;
+
+
+namespace lyx {
+namespace frontend {
+
+GuiFontLoader::~GuiFontLoader() {
+}
+
+namespace {
+
+struct symbol_font {
+       LyXFont::FONT_FAMILY lyx_family;
+       string family;
+       string xlfd;
+};
+
+symbol_font symbol_fonts[] = {
+       { LyXFont::SYMBOL_FAMILY,
+               "symbol",
+               "-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific" },
+
+       { LyXFont::CMR_FAMILY,
+               "cmr10",
+               "-*-cmr10-medium-*-*-*-*-*-*-*-*-*-*-*" },
+
+       { LyXFont::CMSY_FAMILY,
+               "cmsy10",
+               "-*-cmsy10-*-*-*-*-*-*-*-*-*-*-*-*" },
+
+       { LyXFont::CMM_FAMILY,
+               "cmmi10",
+               "-*-cmmi10-medium-*-*-*-*-*-*-*-*-*-*-*" },
+
+       { LyXFont::CMEX_FAMILY,
+               "cmex10",
+               "-*-cmex10-*-*-*-*-*-*-*-*-*-*-*-*" },
+
+       { LyXFont::MSA_FAMILY,
+               "msam10",
+               "-*-msam10-*-*-*-*-*-*-*-*-*-*-*-*" },
+
+       { LyXFont::MSB_FAMILY,
+               "msbm10",
+               "-*-msbm10-*-*-*-*-*-*-*-*-*-*-*-*" },
+
+       { LyXFont::EUFRAK_FAMILY,
+               "eufm10",
+               "-*-eufm10-medium-*-*-*-*-*-*-*-*-*-*-*" },
+
+       { LyXFont::WASY_FAMILY,
+               "wasy10",
+               "-*-wasy10-medium-*-*-*-*-*-*-*-*-*-*-*" }
+};
+
+size_t const nr_symbol_fonts = sizeof(symbol_fonts) / sizeof(symbol_font);
+
+
+string getRawName(string const & family)
+{
+       for (size_t i = 0; i < nr_symbol_fonts; ++i)
+               if (family == symbol_fonts[i].family)
+                       return symbol_fonts[i].xlfd;
+
+       lyxerr[Debug::FONT] << "BUG: family not found !" << endl;
+       return string();
+}
+
+
+string const symbolFamily(LyXFont::FONT_FAMILY family)
+{
+       for (size_t i = 0; i < nr_symbol_fonts; ++i) {
+               if (family == symbol_fonts[i].lyx_family)
+                       return symbol_fonts[i].family;
+       }
+       return string();
+}
+
+
+bool isSymbolFamily(LyXFont::FONT_FAMILY family)
+{
+       return family >= LyXFont::SYMBOL_FAMILY &&
+               family <= LyXFont::WASY_FAMILY;
+}
+
+
+bool isChosenFont(QFont & font, string const & family)
+{
+       lyxerr[Debug::FONT] << "raw: " << fromqstr(font.rawName()) << endl;
+
+       QFontInfo fi(font);
+
+       // Note Qt lies about family quite often
+       lyxerr[Debug::FONT] << "alleged fi family: "
+               << fromqstr(fi.family()) << endl;
+
+       // So we check rawName first
+       if (contains(fromqstr(font.rawName()), family)) {
+               lyxerr[Debug::FONT] << " got it ";
+               return true;
+       }
+
+       // Qt 3.2 beta1 returns "xft" for all xft fonts
+       // Qt 4.1 returns "Multi" for all ? xft fonts
+       if (font.rawName() == "xft" || font.rawName() == "Multi") {
+               if (contains(fromqstr(fi.family()), family)) {
+                       lyxerr[Debug::FONT] << " got it (Xft) ";
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+
+pair<QFont, bool> const getSymbolFont(string const & family)
+{
+       lyxerr[Debug::FONT] << "Looking for font family "
+               << family << " ... ";
+       string upper = family;
+       upper[0] = toupper(family[0]);
+
+       QFont font;
+       font.setFamily(toqstr(family));
+
+       if (isChosenFont(font, family)) {
+               lyxerr[Debug::FONT] << "normal!" << endl;
+               return make_pair<QFont, bool>(font, true);
+       }
+
+       font.setFamily(toqstr(upper));
+
+       if (isChosenFont(font, upper)) {
+               lyxerr[Debug::FONT] << "upper!" << endl;
+               return make_pair<QFont, bool>(font, true);
+       }
+
+       // A simple setFamily() fails on Qt 2
+
+       font.setRawName(toqstr(getRawName(family)));
+
+       if (isChosenFont(font, family)) {
+               lyxerr[Debug::FONT] << "raw version!" << endl;
+               return make_pair<QFont, bool>(font, true);
+       }
+
+       lyxerr[Debug::FONT] << " FAILED :-(" << endl;
+       return make_pair<QFont, bool>(font, false);
+}
+
+} // namespace anon
+
+
+GuiFontLoader::GuiFontLoader()
+{
+       for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1)
+               for (int i2 = 0; i2 < 2; ++i2)
+                       for (int i3 = 0; i3 < 4; ++i3)
+                               for (int i4 = 0; i4 < 10; ++i4)
+                                       fontinfo_[i1][i2][i3][i4] = 0;
+}
+
+
+void GuiFontLoader::update()
+{
+       for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1)
+               for (int i2 = 0; i2 < 2; ++i2)
+                       for (int i3 = 0; i3 < 4; ++i3)
+                               for (int i4 = 0; i4 < 10; ++i4) {
+                                       delete fontinfo_[i1][i2][i3][i4];
+                                       fontinfo_[i1][i2][i3][i4] = 0;
+                               }
+}
+
+
+/////////////////////////////////////////////////
+
+
+QLFontInfo::QLFontInfo(LyXFont const & f)
+       : metrics(font)
+{
+
+       string const pat = symbolFamily(f.family());
+       if (!pat.empty()) {
+               bool tmp;
+               boost::tie(font, tmp) = getSymbolFont(pat);
+       } else {
+               switch (f.family()) {
+               case LyXFont::ROMAN_FAMILY:
+                       font.setFamily(toqstr(makeFontName(lyxrc.roman_font_name,
+                                                   lyxrc.roman_font_foundry)));
+                       break;
+               case LyXFont::SANS_FAMILY:
+                       font.setFamily(toqstr(makeFontName(lyxrc.sans_font_name,
+                                                   lyxrc.sans_font_foundry)));
+                       break;
+               case LyXFont::TYPEWRITER_FAMILY:
+                       font.setFamily(toqstr(makeFontName(lyxrc.typewriter_font_name,
+                                                   lyxrc.typewriter_font_foundry)));
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       font.setPointSizeF(convert<double>(lyxrc.font_sizes[f.size()])
+                              * lyxrc.zoom / 100.0);
+
+       switch (f.series()) {
+               case LyXFont::MEDIUM_SERIES:
+                       font.setWeight(QFont::Normal);
+                       break;
+               case LyXFont::BOLD_SERIES:
+                       font.setWeight(QFont::Bold);
+                       break;
+               default:
+                       break;
+       }
+
+       switch (f.realShape()) {
+               case LyXFont::ITALIC_SHAPE:
+               case LyXFont::SLANTED_SHAPE:
+                       font.setItalic(true);
+                       break;
+               default:
+                       break;
+       }
+
+       if (lyxerr.debugging(Debug::FONT)) {
+               lyxerr[Debug::FONT] << "Font '" << f.stateText(0)
+                       << "' matched by\n" << fromqstr(font.rawName()) << endl;
+       }
+
+       lyxerr[Debug::FONT] << "The font has size: "
+                           << font.pointSizeF() << endl;
+
+       // Is this an exact match?
+       if (font.exactMatch())
+               lyxerr[Debug::FONT] << "This font is an exact match" << endl;
+       else
+               lyxerr[Debug::FONT] << "This font is NOT an exact match"
+                                   << endl;
+
+       lyxerr[Debug::FONT] << "XFLD: " << fromqstr(font.rawName()) << endl;
+
+       metrics = QFontMetrics(font);
+}
+
+
+int QLFontInfo::width(Uchar val)
+{
+// Starting with version 3.1.0, Qt/X11 does its own caching of
+// character width, so it is not necessary to provide ours.
+#if defined (USE_LYX_FONTCACHE)
+       QLFontInfo::WidthCache::const_iterator cit = widthcache.find(val);
+       if (cit != widthcache.end())
+               return cit->second;
+
+       int const w = metrics.width(QChar(val));
+       widthcache[val] = w;
+       return w;
+#else
+       return metrics.width(QChar(val));
+#endif
+}
+
+
+bool GuiFontLoader::available(LyXFont const & f)
+{
+       if (!lyx_gui::use_gui)
+               return false;
+
+       static vector<int> cache_set(LyXFont::NUM_FAMILIES, false);
+       static vector<int> 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())
+               // We don't care about non-symbol fonts
+               return false;
+
+       pair<QFont, bool> tmp = getSymbolFont(pat);
+       if (!tmp.second)
+               return false;
+
+       cache[family] = true;
+       return true;
+}
+
+} // namespace frontend
+} // namespace lyx
diff --git a/src/frontends/qt4/GuiFontLoader.h b/src/frontends/qt4/GuiFontLoader.h
new file mode 100644 (file)
index 0000000..3532aa9
--- /dev/null
@@ -0,0 +1,104 @@
+// -*- C++ -*-
+/**
+ * \file GuiFontLoader.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef QT4_FONTLOADER_H
+#define QT4_FONTLOADER_H
+
+#include "frontends/FontLoader.h"
+
+#include "encoding.h"
+#include "lyxfont.h"
+
+#include <QFont>
+#include <QFontMetrics>
+
+//#if QT_VERSION < 0x030100
+#define USE_LYX_FONTCACHE
+//#endif
+
+#if defined(USE_LYX_FONTCACHE)
+#include <map>
+#endif
+
+namespace lyx {
+namespace frontend {
+
+/**
+ * Qt font loader for LyX. Matches LyXFonts against
+ * actual QFont instances, and also caches metrics.
+ */
+class QLFontInfo {
+public:
+       QLFontInfo(LyXFont const & f);
+
+       /// Return pixel width for the given unicode char
+       int width(Uchar val);
+
+       /// The font instance
+       QFont font;
+       /// Metrics on the font
+       QFontMetrics metrics;
+
+#if defined(USE_LYX_FONTCACHE)
+       typedef std::map<Uchar, int> WidthCache;
+       /// Cache of char widths
+       WidthCache widthcache;
+#endif
+};
+
+
+/// Hold info about a particular font
+class GuiFontLoader: public FontLoader 
+{
+public:
+       ///
+       GuiFontLoader();
+       
+       /// Destructor
+       virtual ~GuiFontLoader();
+
+       /// Update fonts after zoom, dpi, font names, or norm change
+       virtual void update();
+
+       /// Do we have anything matching?
+       virtual bool available(LyXFont const & f);
+
+       /// Get the QFont for this LyXFont
+       QFont const & get(LyXFont const & f) {
+               return fontinfo(f).font;
+       }
+
+       /// Get the QFont metrics for this LyXFont
+       QFontMetrics const & metrics(LyXFont const & f) {
+               return fontinfo(f).metrics;
+       }
+
+       /// Get font info (font + metrics) for the given LyX font.
+       QLFontInfo & fontinfo(LyXFont const & f) {
+               // fi is a reference to the pointer type (QLFontInfo *) in the
+               // fontinfo_ table.
+               QLFontInfo * & fi =
+                       fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
+               if (!fi)
+                       fi = new QLFontInfo(f);
+               return *fi;
+       }
+
+private:
+       /// BUTT ugly !
+       QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
+};
+
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // QT4_FONTLOADER_H
index 59a5f03314fad93e6ed542eb9127d1005535a2c0..c20a0970abd0df423936408e67585447d7728ee8 100644 (file)
@@ -34,9 +34,9 @@ libqt4_la_SOURCES = \
        ColorCache.h ColorCache.C \
        Dialogs.C \
        FileDialog.C \
-       FontLoader.h FontLoader.C \
        GuiApplication.C GuiApplication.h \
        GuiClipboard.h GuiClipboard.C \
+       GuiFontLoader.h GuiFontLoader.C \
        GuiSelection.h GuiSelection.C \
        GuiImplementation.h GuiImplementation.C \
        LyXKeySymFactory.C \
index 62976f682d1c785a290c397d15a0c6e4cc37d460..f306ebc330944b6873d35b2859837300030d184e 100644 (file)
@@ -202,8 +202,8 @@ void QLPainter::smallCapsText(int x, int y,
        LyXFont smallfont(f);
        smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
 
-       QFont const & qfont = guiApp->fontLoader().get(f);
-       QFont const & qsmallfont = guiApp->fontLoader().get(smallfont);
+       QFont const & qfont = guiApp->guiFontLoader().get(f);
+       QFont const & qsmallfont = guiApp->guiFontLoader().get(smallfont);
        QFontMetrics const & qfontm = QFontMetrics(qfont);
        QFontMetrics const & qsmallfontm = QFontMetrics(qsmallfont);
 
@@ -252,7 +252,7 @@ void QLPainter::text(int x, int y, char_type const * s, size_t ls,
 
        if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
                setQPainterPen(f.realColor());
-               qp_->setFont(guiApp->fontLoader().get(f));
+               qp_->setFont(guiApp->guiFontLoader().get(f));
                // We need to draw the text as LTR as we use our own bidi code.
                qp_->setLayoutDirection(Qt::LeftToRight);
                qp_->drawText(x, y, str);
index f50c58d4269ebb785c33cac4892a658ac5927f1c..ea848a26ce0c9a2d2a472e7c372d61e257085e46 100644 (file)
@@ -140,18 +140,6 @@ void update_color(LColor_color)
 }
 
 
-void update_fonts()
-{
-       guiApp->fontLoader().update();
-}
-
-
-bool font_available(LyXFont const & font)
-{
-       return guiApp->fontLoader().available(font);
-}
-
-
 void register_socket_callback(int fd, boost::function<void()> func)
 {
        socket_callbacks[fd] = shared_ptr<socket_callback>(new socket_callback(fd, func));
index 915c2934abe5f14b227b9519cec50e923df4cf4d..00f924c01149e875b6ada9cd1c43a3da0d88552d 100644 (file)
@@ -39,8 +39,8 @@ int smallcapswidth(QString const & s, LyXFont const & f)
        LyXFont smallfont = f;
        smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
 
-       QFontMetrics const & qm = guiApp->fontLoader().metrics(f);
-       QFontMetrics const & qsmallm = guiApp->fontLoader().metrics(smallfont);
+       QFontMetrics const & qm = guiApp->guiFontLoader().metrics(f);
+       QFontMetrics const & qsmallm = guiApp->guiFontLoader().metrics(smallfont);
 
        int w = 0;
 
@@ -65,7 +65,7 @@ int font_metrics::maxAscent(LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       return guiApp->fontLoader().metrics(f).ascent();
+       return guiApp->guiFontLoader().metrics(f).ascent();
 }
 
 
@@ -75,7 +75,7 @@ int font_metrics::maxDescent(LyXFont const & f)
                return 1;
        // We add 1 as the value returned by QT is different than X
        // See http://doc.trolltech.com/2.3/qfontmetrics.html#200b74
-       return guiApp->fontLoader().metrics(f).descent() + 1;
+       return guiApp->guiFontLoader().metrics(f).descent() + 1;
 }
 
 
@@ -83,7 +83,7 @@ int font_metrics::ascent(char_type c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       QRect const & r = guiApp->fontLoader().metrics(f).boundingRect(ucs4_to_qchar(c));
+       QRect const & r = guiApp->guiFontLoader().metrics(f).boundingRect(ucs4_to_qchar(c));
        // Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
        // value by the height: (x, -y-height, width, height).
        // Other versions return: (x, -y, width, height)
@@ -99,7 +99,7 @@ int font_metrics::descent(char_type c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       QRect const & r = guiApp->fontLoader().metrics(f).boundingRect(ucs4_to_qchar(c));
+       QRect const & r = guiApp->guiFontLoader().metrics(f).boundingRect(ucs4_to_qchar(c));
        // Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
        // value by the height: (x, -y-height, width, height).
        // Other versions return: (x, -y, width, height)
@@ -115,7 +115,7 @@ int font_metrics::lbearing(char_type c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       return guiApp->fontLoader().metrics(f).leftBearing(ucs4_to_qchar(c));
+       return guiApp->guiFontLoader().metrics(f).leftBearing(ucs4_to_qchar(c));
 }
 
 
@@ -123,7 +123,7 @@ int font_metrics::rbearing(char_type c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       QFontMetrics const & m = guiApp->fontLoader().metrics(f);
+       QFontMetrics const & m = guiApp->guiFontLoader().metrics(f);
 
        // Qt rbearing is from the right edge of the char's width().
        QChar sc = ucs4_to_qchar(c);
@@ -141,7 +141,7 @@ int font_metrics::width(char_type const * s, size_t ls, LyXFont const & f)
        if (f.realShape() == LyXFont::SMALLCAPS_SHAPE)
                return smallcapswidth(ucs2, f);
 
-       QLFontInfo & fi = guiApp->fontLoader().fontinfo(f);
+       lyx::frontend::QLFontInfo & fi = guiApp->guiFontLoader().fontinfo(f);
 
        if (ls == 1)
                return fi.width(ucs2[0].unicode());
@@ -166,7 +166,7 @@ int font_metrics::signedWidth(docstring const & s, LyXFont const & f)
 void font_metrics::rectText(docstring const & str, LyXFont const & f,
        int & w, int & ascent, int & descent)
 {
-       QFontMetrics const & m = guiApp->fontLoader().metrics(f);
+       QFontMetrics const & m = guiApp->guiFontLoader().metrics(f);
        static int const d = 2;
        w = width(str, f) + d * 2 + 2;
        ascent = m.ascent() + d;
@@ -178,7 +178,7 @@ void font_metrics::rectText(docstring const & str, LyXFont const & f,
 void font_metrics::buttonText(docstring const & str, LyXFont const & f,
        int & w, int & ascent, int & descent)
 {
-       QFontMetrics const & m = guiApp->fontLoader().metrics(f);
+       QFontMetrics const & m = guiApp->guiFontLoader().metrics(f);
        static int const d = 3;
        w = width(str, f) + d * 2 + 2;
        ascent = m.ascent() + d;
index ea80d9fc8d6d1a5d3a17f13139ba749099cc3b69..783bef10f036a30e8e8e3fd0e79cfe754278f67f 100644 (file)
@@ -76,6 +76,7 @@
 #include "frontends/Alert.h"
 #include "frontends/Dialogs.h"
 #include "frontends/FileDialog.h"
+#include "frontends/FontLoader.h"
 #include "frontends/lyx_gui.h"
 #include "frontends/LyXKeySym.h"
 #include "frontends/LyXView.h"
@@ -1352,7 +1353,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                case LFUN_SCREEN_FONT_UPDATE:
                        // handle the screen font changes.
                        lyxrc.set_font_norm_type();
-                       lyx_gui::update_fonts();
+                       theApp->fontLoader().update();
                        // All visible buffers will need resize
                        view()->resize();
                        break;
index fd322961d4f82c45726fc121fab55b114955e65c..6a3fb9d9891d6fe78742d59175be34a1ff4241bd 100644 (file)
@@ -60,7 +60,8 @@
 #include "support/filetools.h" // LibFileSearch
 #include "support/lstrings.h"
 
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
+#include "frontends/FontLoader.h"
 
 #include <fstream>
 #include <sstream>
@@ -88,7 +89,7 @@ bool math_font_available(string & name)
        augmentFont(f, name);
 
        // Do we have the font proper?
-       if (lyx_gui::font_available(f))
+       if (theApp->fontLoader().available(f))
                return true;
 
        // can we fake it?
index 99bb7e43c0aa76ec9a8a0ee90237d19f4dd22f2f..448b74055e41829d914ebeed767c0b41edc74ebd 100644 (file)
 #include "debug.h"
 #include "LColor.h"
 
+#include "frontends/Application.h"
 #include "frontends/Painter.h"
 #include "frontends/font_metrics.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/FontLoader.h"
 
 #include <map>
 #include <sstream>
@@ -670,9 +671,9 @@ void augmentFont(LyXFont & font, string const & name)
        if (!initialized) {
                initialized = true;
                // fake fonts if necessary
-               if (!lyx_gui::font_available(getFont("mathfrak")))
+               if (!theApp->fontLoader().available(getFont("mathfrak")))
                        fakeFont("mathfrak", "lyxfakefrak");
-               if (!lyx_gui::font_available(getFont("mathcal")))
+               if (!theApp->fontLoader().available(getFont("mathcal")))
                        fakeFont("mathcal", "lyxfakecal");
        }
        fontinfo * info = searchFont(name);