From 205096733a808ba496550f3b74b40cb983a00642 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 3 Oct 2006 16:17:32 +0000 Subject: [PATCH] This commit introduces the FontLoader interface class. In the future, I intend to extend it with a proper encapsulation of font metrics. * 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 --- development/scons/scons_manifest.py | 5 ++- src/frontends/Application.h | 3 ++ src/frontends/FontLoader.h | 39 +++++++++++++++++++ src/frontends/Makefile.am | 1 + src/frontends/gtk/GuiApplication.h | 2 +- src/frontends/gtk/lyx_gui.C | 12 ------ src/frontends/gtk/xftFontLoader.h | 10 +++-- src/frontends/lyx_gui.h | 10 ----- src/frontends/qt3/GuiApplication.h | 5 +-- src/frontends/qt3/QtView.C | 2 +- src/frontends/qt3/lyx_gui.C | 12 ------ src/frontends/qt3/qfont_loader.C | 8 ++-- src/frontends/qt3/qfont_loader.h | 14 ++++--- src/frontends/qt4/GuiApplication.h | 8 ++-- .../qt4/{FontLoader.C => GuiFontLoader.C} | 18 ++++++--- .../qt4/{FontLoader.h => GuiFontLoader.h} | 31 +++++++++------ src/frontends/qt4/Makefile.am | 2 +- src/frontends/qt4/QLPainter.C | 6 +-- src/frontends/qt4/lyx_gui.C | 12 ------ src/frontends/qt4/qfont_metrics.C | 22 +++++------ src/lyxfunc.C | 3 +- src/mathed/MathFactory.C | 5 ++- src/mathed/MathSupport.C | 7 ++-- 23 files changed, 128 insertions(+), 109 deletions(-) create mode 100644 src/frontends/FontLoader.h rename src/frontends/qt4/{FontLoader.C => GuiFontLoader.C} (96%) rename src/frontends/qt4/{FontLoader.h => GuiFontLoader.h} (82%) diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index f4af24b581..6edf247c94 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -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 diff --git a/src/frontends/Application.h b/src/frontends/Application.h index 0959020230..d9589f8078 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -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 index 0000000000..ea5cf7388b --- /dev/null +++ b/src/frontends/FontLoader.h @@ -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 diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index 4ca77284f3..cb5a5832b5 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -21,6 +21,7 @@ libfrontends_la_SOURCES = \ Dialogs.C \ Dialogs.h \ FileDialog.h \ + FontLoader.h \ LyXKeySym.h \ LyXKeySymFactory.h \ LyXView.C \ diff --git a/src/frontends/gtk/GuiApplication.h b/src/frontends/gtk/GuiApplication.h index 6526729786..0ffaa0b4b4 100644 --- a/src/frontends/gtk/GuiApplication.h +++ b/src/frontends/gtk/GuiApplication.h @@ -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: /// diff --git a/src/frontends/gtk/lyx_gui.C b/src/frontends/gtk/lyx_gui.C index 6cf21913e6..dbf06e4492 100644 --- a/src/frontends/gtk/lyx_gui.C +++ b/src/frontends/gtk/lyx_gui.C @@ -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 > callbacks; diff --git a/src/frontends/gtk/xftFontLoader.h b/src/frontends/gtk/xftFontLoader.h index a04f11f5df..4c2cb086c6 100644 --- a/src/frontends/gtk/xftFontLoader.h +++ b/src/frontends/gtk/xftFontLoader.h @@ -12,6 +12,8 @@ #ifndef XFT_FONT_LOADER_H #define XFT_FONT_LOADER_H +#include "frontends/FontLoader.h" + #include "lyxfont.h" #include @@ -20,18 +22,18 @@ 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, diff --git a/src/frontends/lyx_gui.h b/src/frontends/lyx_gui.h index 6075a1ed96..50628c2d87 100644 --- a/src/frontends/lyx_gui.h +++ b/src/frontends/lyx_gui.h @@ -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) diff --git a/src/frontends/qt3/GuiApplication.h b/src/frontends/qt3/GuiApplication.h index d56e057c5d..82eca1c870 100644 --- a/src/frontends/qt3/GuiApplication.h +++ b/src/frontends/qt3/GuiApplication.h @@ -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: diff --git a/src/frontends/qt3/QtView.C b/src/frontends/qt3/QtView.C index 9052cf3ae6..8b62a9c844 100644 --- a/src/frontends/qt3/QtView.C +++ b/src/frontends/qt3/QtView.C @@ -40,7 +40,7 @@ using std::string; -FontLoader fontloader; +GuiFontLoader fontloader; namespace lyx { diff --git a/src/frontends/qt3/lyx_gui.C b/src/frontends/qt3/lyx_gui.C index 97895780fb..c6465d43d7 100644 --- a/src/frontends/qt3/lyx_gui.C +++ b/src/frontends/qt3/lyx_gui.C @@ -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 func) { socket_callbacks[fd] = shared_ptr(new socket_callback(fd, func)); diff --git a/src/frontends/qt3/qfont_loader.C b/src/frontends/qt3/qfont_loader.C index 7fc882a03d..b0906c7cb0 100644 --- a/src/frontends/qt3/qfont_loader.C +++ b/src/frontends/qt3/qfont_loader.C @@ -47,7 +47,7 @@ using std::vector; using std::string; -FontLoader::~FontLoader() { +GuiFontLoader::~GuiFontLoader() { } namespace { @@ -193,7 +193,7 @@ pair 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; diff --git a/src/frontends/qt3/qfont_loader.h b/src/frontends/qt3/qfont_loader.h index eadf2b46cc..d18e729ca8 100644 --- a/src/frontends/qt3/qfont_loader.h +++ b/src/frontends/qt3/qfont_loader.h @@ -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/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index 82334a8d13..6f3acf8dda 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -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/FontLoader.C b/src/frontends/qt4/GuiFontLoader.C similarity index 96% rename from src/frontends/qt4/FontLoader.C rename to src/frontends/qt4/GuiFontLoader.C index 467156329f..3f9fe409c9 100644 --- a/src/frontends/qt4/FontLoader.C +++ b/src/frontends/qt4/GuiFontLoader.C @@ -1,5 +1,5 @@ /** - * \file FontLoader.C + * \file GuiFontLoader.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -11,7 +11,7 @@ #include -#include "FontLoader.h" +#include "GuiFontLoader.h" #include "qt_helpers.h" #include "debug.h" @@ -44,7 +44,10 @@ using std::vector; using std::string; -FontLoader::~FontLoader() { +namespace lyx { +namespace frontend { + +GuiFontLoader::~GuiFontLoader() { } namespace { @@ -191,7 +194,7 @@ pair 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) @@ -201,7 +204,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) @@ -305,7 +308,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; @@ -330,3 +333,6 @@ bool FontLoader::available(LyXFont const & f) cache[family] = true; return true; } + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/qt4/FontLoader.h b/src/frontends/qt4/GuiFontLoader.h similarity index 82% rename from src/frontends/qt4/FontLoader.h rename to src/frontends/qt4/GuiFontLoader.h index 1a933d73f5..3532aa98e7 100644 --- a/src/frontends/qt4/FontLoader.h +++ b/src/frontends/qt4/GuiFontLoader.h @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * \file FontLoader.h + * \file GuiFontLoader.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -9,8 +9,10 @@ * Full author contact details are available in file CREDITS. */ -#ifndef QFONTLOADER_H -#define QFONTLOADER_H +#ifndef QT4_FONTLOADER_H +#define QT4_FONTLOADER_H + +#include "frontends/FontLoader.h" #include "encoding.h" #include "lyxfont.h" @@ -26,6 +28,9 @@ #include #endif +namespace lyx { +namespace frontend { + /** * Qt font loader for LyX. Matches LyXFonts against * actual QFont instances, and also caches metrics. @@ -51,19 +56,20 @@ public: /// Hold info about a particular font -class FontLoader { +class GuiFontLoader: public 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) { @@ -75,9 +81,6 @@ public: 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 @@ -94,4 +97,8 @@ private: QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10]; }; -#endif // QFONT_LOADER_H + +} // namespace frontend +} // namespace lyx + +#endif // QT4_FONTLOADER_H diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index 59a5f03314..c20a0970ab 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -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 \ diff --git a/src/frontends/qt4/QLPainter.C b/src/frontends/qt4/QLPainter.C index 62976f682d..f306ebc330 100644 --- a/src/frontends/qt4/QLPainter.C +++ b/src/frontends/qt4/QLPainter.C @@ -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); diff --git a/src/frontends/qt4/lyx_gui.C b/src/frontends/qt4/lyx_gui.C index f50c58d426..ea848a26ce 100644 --- a/src/frontends/qt4/lyx_gui.C +++ b/src/frontends/qt4/lyx_gui.C @@ -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 func) { socket_callbacks[fd] = shared_ptr(new socket_callback(fd, func)); diff --git a/src/frontends/qt4/qfont_metrics.C b/src/frontends/qt4/qfont_metrics.C index 915c2934ab..00f924c011 100644 --- a/src/frontends/qt4/qfont_metrics.C +++ b/src/frontends/qt4/qfont_metrics.C @@ -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; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index ea80d9fc8d..783bef10f0 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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; diff --git a/src/mathed/MathFactory.C b/src/mathed/MathFactory.C index fd322961d4..6a3fb9d989 100644 --- a/src/mathed/MathFactory.C +++ b/src/mathed/MathFactory.C @@ -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 #include @@ -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? diff --git a/src/mathed/MathSupport.C b/src/mathed/MathSupport.C index 99bb7e43c0..448b74055e 100644 --- a/src/mathed/MathSupport.C +++ b/src/mathed/MathSupport.C @@ -20,9 +20,10 @@ #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 #include @@ -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); -- 2.39.5