]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xfont_loader.h
Really dull and boring header shit
[lyx.git] / src / frontends / xforms / xfont_loader.h
1 // -*- C++ -*-
2 /**
3  * \file xfont_loader.h
4  * Read the file COPYING
5  *
6  * \author Asger Alstrup
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #ifndef FONTLOADER_H_
12 #define FONTLOADER_H_
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include <X11/Xlib.h>
19 #include "lyxfont.h"
20 #include "LString.h"
21
22 class FontInfo;
23
24 /** This class takes care of loading fonts. It uses FontInfo to make
25 intelligent guesses about matching font size, and it tries different tags
26 itself in order to match the font loading demands.  Later, I plan to extend
27 this with support for T1Lib, probably via a new class building on this.
28 (Asger) */
29 class xfont_loader {
30 public:
31         ///
32         xfont_loader();
33
34         ///
35         ~xfont_loader();
36
37         /// Update fonts after zoom, dpi, font names, or norm change
38         void update();
39
40         /// Load font
41         XFontStruct * load(LyXFont::FONT_FAMILY family,
42                            LyXFont::FONT_SERIES series,
43                            LyXFont::FONT_SHAPE shape,
44                            LyXFont::FONT_SIZE size) {
45                 if (fontstruct[family][series][shape][size] != 0)
46                         return fontstruct[family][series][shape][size];
47                 else
48                         return doLoad(family, series, shape, size);
49         };
50         /// Do we have anything matching?
51         bool available(LyXFont const & f);
52
53 private:
54         /// Array of font structs
55         XFontStruct * fontstruct[LyXFont::NUM_FAMILIES][2][4][10];
56
57         /// Array of font infos
58         FontInfo * fontinfo[LyXFont::NUM_FAMILIES][2][4];
59
60         /// Reset font handler
61         void reset();
62
63         /// Unload all fonts
64         void unload();
65
66         /// Get font info
67         void getFontinfo(LyXFont::FONT_FAMILY family,
68                          LyXFont::FONT_SERIES series,
69                          LyXFont::FONT_SHAPE shape);
70
71         /** Does the actual loading of a font. Updates fontstruct. */
72         XFontStruct * 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 xfont_loader fontloader;
80
81 #endif