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