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