4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
19 #include <QFontMetrics>
21 //#if QT_VERSION < 0x030100
22 #define USE_LYX_FONTCACHE
25 #if defined(USE_LYX_FONTCACHE)
30 * Qt font loader for LyX. Matches LyXFonts against
31 * actual QFont instances, and also caches metrics.
35 QLFontInfo(LyXFont const & f);
37 /// Return pixel width for the given unicode char
42 /// Metrics on the font
45 #if defined(USE_LYX_FONTCACHE)
46 typedef std::map<Uchar, int> WidthCache;
47 /// Cache of char widths
48 WidthCache widthcache;
53 /// Hold info about a particular font
62 /// Update fonts after zoom, dpi, font names, or norm change
65 /// Do we have anything matching?
66 bool available(LyXFont const & f);
68 /// Get the QFont for this LyXFont
69 QFont const & get(LyXFont const & f) {
70 return fontinfo(f).font;
73 /// Get the QFont metrics for this LyXFont
74 QFontMetrics const & metrics(LyXFont const & f) {
75 return fontinfo(f).metrics;
78 /// Called before QApplication is initialized
79 static void initFontPath();
81 /// Called the first time when available() can't load a symbol font
82 static void addToFontPath();
84 /// Get font info (font + metrics) for the given LyX font.
85 QLFontInfo & fontinfo(LyXFont const & f) {
86 // fi is a reference to the pointer type (QLFontInfo *) in the
89 fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
91 fi = new QLFontInfo(f);
97 QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
100 #endif // QFONT_LOADER_H