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