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