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