]> git.lyx.org Git - lyx.git/blob - src/FontLoader.h
added a regex to be used when the system is missing one, use noinst instead of pkglib...
[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 #include "LString.h"
22
23 class FontInfo;
24
25 /** This class takes care of loading fonts. It uses FontInfo to make 
26 intelligent guesses about matching font size, and it tries different tags 
27 itself in order to match the font loading demands.  Later, I plan to extend 
28 this with support for T1Lib, probably via a new class building on this. 
29 (Asger) */
30 class FontLoader {
31 public:
32         ///
33         FontLoader();
34
35         ///
36         ~FontLoader();
37
38         /// Update fonts after zoom, dpi, font names, or norm change
39         void update();
40
41         /// Load font
42         XFontStruct* load(LyXFont::FONT_FAMILY family, 
43                           LyXFont::FONT_SERIES series, 
44                           LyXFont::FONT_SHAPE shape, 
45                           LyXFont::FONT_SIZE size)
46         {
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 #endif