]> git.lyx.org Git - lyx.git/blob - src/LaTeXFonts.h
Fix pdf format conversion
[lyx.git] / src / LaTeXFonts.h
1 // -*- C++ -*-
2 /**
3  * \file LaTeXFonts.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Spitzmüller
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef LATEXFONTS_H
13 #define LATEXFONTS_H
14
15 #include "support/docstring.h"
16
17 #include <map>
18 #include <vector>
19
20
21 namespace lyx {
22
23 class Lexer;
24
25 /// LaTeX Font definition
26 class LaTeXFont {
27 public:
28         /// TeX font
29         LaTeXFont() : switchdefault_(false) {}
30         /// The font name
31         docstring const & name() { return name_; }
32         /// The name to appear in the document dialog
33         docstring const & guiname() { return guiname_; }
34         /// Font family (rm, sf, tt)
35         docstring const & family() { return family_; }
36         /// The package that provides this font
37         docstring const & package() { return package_; }
38         /// Alternative font if package() is not available
39         std::vector<docstring> const & altfonts() { return altfonts_; }
40         /// A font that provides all families
41         docstring const & completefont() { return completefont_; }
42         /// A font specifically needed for OT1 font encoding
43         docstring const & ot1font() { return ot1font_; }
44         /// A font that provides Old Style Figures for this type face
45         docstring const & osffont() { return osffont_; }
46         /// A package option needed to load this font
47         docstring const & packageoption() { return packageoption_; }
48         /// A package option for Old Style Figures
49         docstring const & osfoption() { return osfoption_; }
50         /// A package option for true SmallCaps
51         docstring const & scoption() { return scoption_; }
52         /// A package option for both Old Style Figures and SmallCaps
53         docstring const & osfscoption() { return osfscoption_; }
54         /// A package option for font scaling
55         docstring const & scaleoption() { return scaleoption_; }
56         /// Alternative requirement to test for
57         docstring const & requires() { return requires_; }
58         /// Does this font provide a given \p feature
59         bool provides(std::string const & name, bool ot1,
60                       bool complete, bool nomath);
61         /// Issue the familydefault switch
62         bool switchdefault() const { return switchdefault_; }
63         /// Does the font provide Old Style Figures as default?
64         bool osfDefault() const { return osfdefault_; }
65         /// Is this font available?
66         bool available(bool ot1, bool nomath);
67         /// Does this font provide an alternative without math? 
68         bool providesNoMath(bool ot1, bool complete);
69         /// Does this font provide Old Style Figures?
70         bool providesOSF(bool ot1, bool complete, bool nomath);
71         /// Does this font provide optional true SmallCaps?
72         bool providesSC(bool ot1, bool complete, bool nomath);
73         /** does this font provide OSF and Small Caps only via 
74          * a single, undifferentiated expert option?
75          */
76         bool hasMonolithicExpertSet(bool ot1, bool complete, bool nomath);
77         /// Does this font provide scaling?
78         bool providesScale(bool ot1, bool complete, bool nomath);
79         /// Return the LaTeX Code
80         std::string const getLaTeXCode(bool dryrun, bool ot1, bool complete,
81                                        bool sc, bool osf, bool nomath,
82                                        int const & scale = 100);
83         /// Return the actually used font
84         docstring const getUsedFont(bool ot1, bool complete, bool nomath);
85         ///
86         bool read(Lexer & lex);
87         ///
88         bool readFont(Lexer & lex);
89 private:
90         /// Return the preferred available package 
91         std::string const getAvailablePackage(bool dryrun);
92         /// Return the package options
93         std::string const getPackageOptions(bool ot1,
94                                             bool complete,
95                                             bool sc,
96                                             bool osf,
97                                             int scale,
98                                             bool nomath);
99         /// Return an alternative font
100         LaTeXFont altFont(docstring const & name);
101         ///
102         docstring name_;
103         ///
104         docstring guiname_;
105         ///
106         docstring family_;
107         ///
108         docstring package_;
109         ///
110         std::vector<docstring> altfonts_;
111         ///
112         docstring completefont_;
113         ///
114         docstring nomathfont_;
115         ///
116         docstring ot1font_;
117         ///
118         docstring osffont_;
119         ///
120         docstring packageoption_;
121         ///
122         docstring osfoption_;
123         ///
124         docstring scoption_;
125         ///
126         docstring osfscoption_;
127         ///
128         docstring scaleoption_;
129         ///
130         std::vector<std::string> provides_;
131         ///
132         docstring requires_;
133         ///
134         std::string preamble_;
135         ///
136         bool osfdefault_;
137         ///
138         bool switchdefault_;
139 };
140   
141   
142 /** The list of available LaTeX fonts
143  */
144 class LaTeXFonts {
145 public:
146         ///
147         typedef std::map<docstring, LaTeXFont> TexFontMap;
148         /// Get all LaTeXFonts
149         TexFontMap getLaTeXFonts();
150         /// Get a specific LaTeXFont \p name
151         LaTeXFont getLaTeXFont(docstring const & name);
152         /// Get a specific AltFont \p name
153         LaTeXFont getAltFont(docstring const & name);
154 private:
155         ///
156         void readLaTeXFonts();
157         ///
158         TexFontMap texfontmap_;
159         ///
160         TexFontMap texaltfontmap_;
161 };
162
163 /// Implementation is in LyX.cpp
164 extern LaTeXFonts & theLaTeXFonts();
165
166
167 } // namespace lyx
168
169 #endif