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