3 * \file GuiFontLoader.h
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.
12 #ifndef QT4_FONTLOADER_H
13 #define QT4_FONTLOADER_H
15 #include "frontends/FontLoader.h"
19 #include "GuiFontMetrics.h"
25 #include <boost/assert.hpp>
31 * Qt font loader for LyX. Matches Fonts against
32 * actual QFont instances, and also caches metrics.
37 GuiFontInfo(FontInfo const & f);
41 /// Metrics on the font
42 GuiFontMetrics metrics;
46 /// Hold info about a particular font
47 class GuiFontLoader : public FontLoader
54 virtual ~GuiFontLoader();
56 virtual void update();
57 virtual bool available(FontInfo const & f);
58 inline virtual FontMetrics const & metrics(FontInfo const & f) {
59 return fontinfo(f).metrics;
62 /// Get the QFont for this FontInfo
63 QFont const & get(FontInfo const & f) {
64 return fontinfo(f).font;
68 /// Get font info (font + metrics) for the given LyX font.
69 GuiFontInfo & fontinfo(FontInfo const & f) {
70 BOOST_ASSERT(f.family() < NUM_FAMILIES);
71 BOOST_ASSERT(f.series() < 2);
72 BOOST_ASSERT(f.realShape() < 4);
73 BOOST_ASSERT(f.size() < 10);
74 // fi is a reference to the pointer type (GuiFontInfo *) in the
77 fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
79 fi = new GuiFontInfo(f);
85 GuiFontInfo * fontinfo_[NUM_FAMILIES][2][4][10];
89 } // namespace frontend
92 #endif // QT4_FONTLOADER_H