]> git.lyx.org Git - lyx.git/blob - src/FontLoader.h
Various fixes, removed "default" language, inserted new lyxrc tag
[lyx.git] / src / FontLoader.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1997 Asger Alstrup
8  *           and the LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef FONTLOADER_H_
13 #define FONTLOADER_H_ 
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19
20 #include FORMS_H_LOCATION
21 #include "lyxfont.h"
22 #include "LString.h"
23
24 class FontInfo;
25
26 /** This class takes care of loading fonts. It uses FontInfo to make 
27 intelligent guesses about matching font size, and it tries different tags 
28 itself in order to match the font loading demands.  Later, I plan to extend 
29 this with support for T1Lib, probably via a new class building on this. 
30 (Asger) */
31 class FontLoader {
32 public:
33         ///
34         FontLoader();
35
36         ///
37         ~FontLoader();
38
39         /// Update fonts after zoom, dpi, font names, or norm change
40         void update();
41
42         /// Load font
43         XFontStruct * load(LyXFont::FONT_FAMILY family, 
44                            LyXFont::FONT_SERIES series, 
45                            LyXFont::FONT_SHAPE shape, 
46                            LyXFont::FONT_SIZE size) {
47                 if (fontstruct[family][series][shape][size] != 0)
48                         return fontstruct[family][series][shape][size];
49                 else
50                         return doLoad(family, series, shape, size);
51         };
52 private:
53         /// Array of font structs
54         XFontStruct * fontstruct[4][2][4][10];
55
56         /// Array of font infos
57         FontInfo * fontinfo[4][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 FontLoader fontloader;
79
80 #endif