]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xfont_loader.h
Introduce LFUN_PRINT.
[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
19 class FontInfo;
20
21 /** This class takes care of loading fonts. It uses FontInfo to make
22 intelligent guesses about matching font size, and it tries different tags
23 itself in order to match the font loading demands.  Later, I plan to extend
24 this with support for T1Lib, probably via a new class building on this.
25 (Asger) */
26 class xfont_loader {
27 public:
28         ///
29         xfont_loader();
30
31         ///
32         ~xfont_loader();
33
34         /// Update fonts after zoom, dpi, font names, or norm change
35         void update();
36
37         /// Load font
38         XFontStruct * load(LyXFont::FONT_FAMILY family,
39                            LyXFont::FONT_SERIES series,
40                            LyXFont::FONT_SHAPE shape,
41                            LyXFont::FONT_SIZE size) {
42                 if (fontstruct[family][series][shape][size] != 0)
43                         return fontstruct[family][series][shape][size];
44                 else
45                         return doLoad(family, series, shape, size);
46         };
47         /// Do we have anything matching?
48         bool available(LyXFont const & f);
49
50 private:
51         /// Array of font structs
52         XFontStruct * fontstruct[LyXFont::NUM_FAMILIES][2][4][10];
53
54         /// Array of font infos
55         FontInfo * fontinfo[LyXFont::NUM_FAMILIES][2][4];
56
57         /// Reset font handler
58         void reset();
59
60         /// Unload all fonts
61         void unload();
62
63         /// Get font info
64         void getFontinfo(LyXFont::FONT_FAMILY family,
65                          LyXFont::FONT_SERIES series,
66                          LyXFont::FONT_SHAPE shape);
67
68         /** Does the actual loading of a font. Updates fontstruct. */
69         XFontStruct * doLoad(LyXFont::FONT_FAMILY family,
70                              LyXFont::FONT_SERIES series,
71                              LyXFont::FONT_SHAPE shape,
72                              LyXFont::FONT_SIZE size);
73 };
74
75 ///
76 extern xfont_loader fontloader;
77
78 #endif