]> git.lyx.org Git - lyx.git/blob - src/FontLoader.h
853e2e44e9618b798797c25daee020e50919bb0b
[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 intelligent
25 guesses about matching font size, and it tries different tags itself in order
26 to match the font loading demands.  Later, I plan to extend this with support 
27 for T1Lib, probably via a new class building on this. (Asger) */
28 class FontLoader {
29 public:
30         ///
31         FontLoader();
32
33         ///
34         ~FontLoader();
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         {
45                 if (fontstruct[family][series][shape][size]!=0)
46                         return fontstruct[family][series][shape][size];
47                 else
48                         return doLoad(family,series,shape,size);
49         };
50 private:
51         /// Array of font structs
52         XFontStruct* fontstruct[4][2][4][10];
53
54         /// Array of font infos
55         FontInfo * fontinfo[4][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 #endif