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>
26 #include <boost/scoped_ptr.hpp>
32 * Qt font loader for LyX. Matches Fonts against
33 * actual QFont instances, and also caches metrics.
38 GuiFontInfo(FontInfo const & f);
42 /// Metrics on the font
43 boost::scoped_ptr<GuiFontMetrics> metrics;
47 /// Hold info about a particular font
48 class GuiFontLoader : public FontLoader
55 virtual ~GuiFontLoader() {}
57 virtual void update();
58 virtual bool available(FontInfo const & f);
59 inline virtual FontMetrics const & metrics(FontInfo const & f) {
60 return *fontinfo(f).metrics.get();
63 /// Get the QFont for this FontInfo
64 QFont const & get(FontInfo const & f) {
65 return fontinfo(f).font;
69 /// Get font info (font + metrics) for the given LyX font.
70 GuiFontInfo & fontinfo(FontInfo const & f) {
71 BOOST_ASSERT(f.family() < NUM_FAMILIES);
72 BOOST_ASSERT(f.series() < 2);
73 BOOST_ASSERT(f.realShape() < 4);
74 BOOST_ASSERT(f.size() < 10);
75 // fi is a reference to the pointer type (GuiFontInfo *) in the
78 fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
80 fi = new GuiFontInfo(f);
86 GuiFontInfo * fontinfo_[NUM_FAMILIES][2][4][10];
90 } // namespace frontend
93 #endif // QT4_FONTLOADER_H