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
38 int width(Uchar val) const;
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
59 /// Update fonts after zoom, dpi, font names, or norm change
62 /// Do we have anything matching?
63 bool available(LyXFont const & f);
65 /// Get the QFont for this LyXFont
66 QFont const & get(LyXFont const & f) {
67 return fontinfo(f).font;
70 /// Get the QFont metrics for this LyXFont
71 QFontMetrics const & metrics(LyXFont const & f) {
72 return fontinfo(f).metrics;
75 /// Called before QApplication is initialized
76 static void initFontPath();
78 /// Called the first time when available() can't load a symbol font
79 static void addToFontPath();
81 /// Get font info (font + metrics) for the given LyX font.
82 QLFontInfo & fontinfo(LyXFont const & f) {
84 fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
86 fi = new QLFontInfo(f);
92 QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
95 extern FontLoader fontloader;
97 #endif // QFONT_LOADER_H