]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qfont_loader.h
another compile fix from herbert
[lyx.git] / src / frontends / qt2 / qfont_loader.h
1 // -*- C++ -*-
2 /**
3  * \file qfont_loader.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef QFONTLOADER_H
13 #define QFONTLOADER_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "lyxfont.h"
20
21 #include <qfont.h>
22 #include <qfontmetrics.h>
23
24 #include <boost/scoped_ptr.hpp>
25
26 /**
27  * Qt font loader for LyX. Matches LyXFonts against
28  * actual QFont instances, and also caches metrics.
29  */
30 class qfont_loader {
31 public:
32         qfont_loader();
33
34         ~qfont_loader();
35
36         /// update fonts after zoom, dpi, font names, or norm change
37         void update();
38
39         /// do we have anything matching?
40         bool available(LyXFont const & f);
41
42         /// get the QFont for this LyXFont
43         QFont const & get(LyXFont const & f);
44
45         /// get the QFont metrics for this LyXFont
46         QFontMetrics const & metrics(LyXFont const & f) {
47                 return getfontinfo(f)->metrics;
48         }
49 private:
50         /// hold info about a particular font
51         struct font_info {
52                 font_info(LyXFont const & f);
53
54                 /// the font instance
55                 QFont font;
56                 /// metrics on the font
57                 QFontMetrics metrics;
58         };
59
60         /// get font info (font + metrics) for the given LyX font. Does not fail.
61         font_info const * getfontinfo(LyXFont const & f);
62
63         /// BUTT ugly !
64         boost::scoped_ptr<font_info> fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
65 };
66
67 extern qfont_loader fontloader;
68
69 #endif // QFONT_LOADER_H