]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qfont_loader.h
better selection and scrolling behaviour
[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 /**
25  * Qt font loader for LyX. Matches LyXFonts against
26  * actual QFont instances, and also caches metrics.
27  */
28 class qfont_loader {
29 public:
30         qfont_loader();
31
32         ~qfont_loader();
33
34         /// update fonts after zoom, dpi, font names, or norm change
35         void update();
36
37         /// do we have anything matching?
38         bool available(LyXFont const & f);
39
40         /// get the QFont for this LyXFont
41         QFont const & get(LyXFont const & f);
42
43         /// get the QFont metrics for this LyXFont
44         QFontMetrics const & metrics(LyXFont const & f) {
45                 return getfontinfo(f)->metrics;
46         }
47 private:
48         /// hold info about a particular font
49         struct font_info {
50                 font_info(LyXFont const & f);
51
52                 /// the font instance
53                 QFont font;
54                 /// metrics on the font
55                 QFontMetrics metrics;
56         };
57
58         /// get font info (font + metrics) for the given LyX font. Does not fail.
59         font_info const * getfontinfo(LyXFont const & f);
60
61         /// BUTT ugly !
62         font_info const * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
63 };
64
65 extern qfont_loader fontloader;
66
67 #endif // QFONT_LOADER_H