]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/xftFontLoader.h
Joao latest bits
[lyx.git] / src / frontends / gtk / xftFontLoader.h
1 // -*- C++ -*-
2 /**
3  * \file xftFontLoader.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Huang Ying
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef XFT_FONT_LOADER_H
13 #define XFT_FONT_LOADER_H
14
15 #include "lyxfont.h"
16
17 #include <X11/Xft/Xft.h>
18
19 class GWorkArea;
20
21
22 class xftFontLoader {
23 public:
24         ///
25         xftFontLoader();
26
27         ///
28         ~xftFontLoader();
29
30         /// Update fonts after zoom, dpi, font names, or norm change
31         void update();
32
33         bool available(LyXFont const & f);
34
35         /// Load font
36         XftFont * load(LyXFont::FONT_FAMILY family,
37                       LyXFont::FONT_SERIES series,
38                       LyXFont::FONT_SHAPE shape,
39                       LyXFont::FONT_SIZE size)
40         {
41                 if (fonts_[family][series][shape][size])
42                         return fonts_[family][series][shape][size];
43                 else
44                         return doLoad(family, series, shape, size);
45         }
46         bool isSpecial(LyXFont const & f)
47         {
48                 switch (f.family()) {
49                 case LyXFont::CMR_FAMILY:
50                 case LyXFont::EUFRAK_FAMILY:
51                         return true;
52                 default:
53                         break;
54                 }
55                 return f.isSymbolFont();
56         }
57 private:
58         /// Array of fonts
59         XftFont * fonts_[LyXFont::NUM_FAMILIES][2][4][10];
60         XftPattern * getFontPattern(LyXFont::FONT_FAMILY family,
61                                     LyXFont::FONT_SERIES series,
62                                     LyXFont::FONT_SHAPE shape,
63                                     LyXFont::FONT_SIZE size);
64         std::string familyString(LyXFont::FONT_FAMILY family);
65         /// Reset font handler
66         void reset();
67
68         /// Unload all fonts
69         void unload();
70
71         /** Does the actual loading of a font. Updates fontstruct. */
72         XftFont * doLoad(LyXFont::FONT_FAMILY family,
73                          LyXFont::FONT_SERIES series,
74                          LyXFont::FONT_SHAPE shape,
75                          LyXFont::FONT_SIZE size);
76 };
77
78 ///
79 extern xftFontLoader fontLoader;
80
81 #endif