]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/xftFontLoader.h
enable Font cache only for MacOSX and inline width() for other platform.
[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 "frontends/FontLoader.h"
16
17 #include "lyxfont.h"
18
19 #include <gtkmm.h>
20 #include <X11/Xft/Xft.h>
21
22 class GWorkArea;
23
24
25 class xftFontLoader: public lyx::frontend::FontLoader {
26 public:
27         ///
28         xftFontLoader();
29
30         ///
31         virtual ~xftFontLoader();
32
33         /// Update fonts after zoom, dpi, font names, or norm change
34         virtual void update();
35
36         virtual bool available(LyXFont const & f);
37
38         /// Load font
39         XftFont * load(LyXFont::FONT_FAMILY family,
40                       LyXFont::FONT_SERIES series,
41                       LyXFont::FONT_SHAPE shape,
42                       LyXFont::FONT_SIZE size)
43         {
44                 if (fonts_[family][series][shape][size])
45                         return fonts_[family][series][shape][size];
46                 else
47                         return doLoad(family, series, shape, size);
48         }
49
50         bool isSpecial(LyXFont const & f)
51         {
52                 switch (f.family()) {
53                 case LyXFont::CMR_FAMILY:
54                 case LyXFont::EUFRAK_FAMILY:
55                         return true;
56                 default:
57                         break;
58                 }
59                 return f.isSymbolFont();
60         }
61 private:
62         /// Array of fonts
63         XftFont * fonts_[LyXFont::NUM_FAMILIES][2][4][10];
64         XftPattern * getFontPattern(LyXFont::FONT_FAMILY family,
65                                     LyXFont::FONT_SERIES series,
66                                     LyXFont::FONT_SHAPE shape,
67                                     LyXFont::FONT_SIZE size);
68         std::string familyString(LyXFont::FONT_FAMILY family);
69         /// Reset font handler
70         void reset();
71
72         /// Unload all fonts
73         void unload();
74
75         /** Does the actual loading of a font. Updates fontstruct. */
76         XftFont * doLoad(LyXFont::FONT_FAMILY family,
77                          LyXFont::FONT_SERIES series,
78                          LyXFont::FONT_SHAPE shape,
79                          LyXFont::FONT_SIZE size);
80 };
81
82 ///
83 extern xftFontLoader fontLoader;
84
85 #endif