X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiFontLoader.h;h=40c15f5ea0b60ab6391a5ae2532d76257b34f23d;hb=39d569661a3f4411d4501f9a8db9c7360ef5d568;hp=566b7d44631f28aaaec2dc4e35dc2b7fcb64c65d;hpb=78135f77517f5a1465fdba270336e1fa1b616a58;p=lyx.git diff --git a/src/frontends/qt4/GuiFontLoader.h b/src/frontends/qt4/GuiFontLoader.h index 566b7d4463..40c15f5ea0 100644 --- a/src/frontends/qt4/GuiFontLoader.h +++ b/src/frontends/qt4/GuiFontLoader.h @@ -9,100 +9,25 @@ * Full author contact details are available in file CREDITS. */ -#ifndef QT4_FONTLOADER_H -#define QT4_FONTLOADER_H +#ifndef GUI_FONTLOADER_H +#define GUI_FONTLOADER_H -#include "frontends/FontLoader.h" - -#include "encoding.h" -#include "lyxfont.h" - -#include -#include - -// 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(Q_WS_MACX) -#define USE_LYX_FONTCACHE -#include -#endif +class QFont; 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); - - /// The font instance - QFont font; - /// Metrics on the font - QFontMetrics metrics; - -#ifndef USE_LYX_FONTCACHE - /// Return pixel width for the given unicode char - int width(Uchar val) { return metrics.width(QChar(val)); } -#else - /// Return pixel width for the given unicode char - int width(Uchar val); +class FontInfo; -private: - typedef std::map WidthCache; - /// Cache of char widths - WidthCache widthcache; -#endif // USE_LYX_FONTCACHE -}; - - -/// 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; - } +namespace frontend { -private: - /// BUTT ugly ! - QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10]; -}; +class GuiFontMetrics; +/// Metrics on the font +GuiFontMetrics const & getFontMetrics(FontInfo const & f); +/// Get the QFont for this FontInfo +QFont const & getFont(FontInfo const & f); } // namespace frontend } // namespace lyx -#endif // QT4_FONTLOADER_H +#endif // GUI_FONTLOADER_H