]> git.lyx.org Git - lyx.git/blob - src/LaTeXFonts.h
Remove obsolete (and false) comment.
[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         // FIXME Add fontenc tag to classes which is used if no font is specified?
30         LaTeXFont() : osfdefault_(false), switchdefault_(false), moreopts_(false) { fontenc_.push_back("T1"); }
31         /// The font name
32         docstring const & name() { return name_; }
33         /// The name to appear in the document dialog
34         docstring const & guiname() { return guiname_; }
35         /// Font family (rm, sf, tt)
36         docstring const & family() { return family_; }
37         /// The package that provides this font
38         docstring const & package() { return package_; }
39         /// Does this provide a specific font encoding?
40         bool hasFontenc(std::string const &) const;
41         /// The font encoding(s)
42         std::vector<std::string> const & fontencs() const { return fontenc_; }
43         /// Alternative font if package() is not available
44         std::vector<docstring> const & altfonts() { return altfonts_; }
45         /// A font that provides all families
46         docstring const & completefont() { return completefont_; }
47         /// A font specifically needed for OT1 font encoding
48         docstring const & ot1font() { return ot1font_; }
49         /// A font that provides Old Style Figures for this type face
50         docstring const & osffont() { return osffont_; }
51         /// A package option for Old Style Figures
52         docstring const & osfoption() { return osfoption_; }
53         /// A package option for true SmallCaps
54         docstring const & scoption() { return scoption_; }
55         /// A package option for both Old Style Figures and SmallCaps
56         docstring const & osfscoption() { return osfscoption_; }
57         /// A package option for font scaling
58         docstring const & scaleoption() { return scaleoption_; }
59         /// Does this provide additional options?
60         bool providesMoreOptions(bool ot1, bool complete, bool nomath);
61         /// Alternative requirement to test for
62         docstring const & required() { return requires_; }
63         /// Does this font provide a given \p feature
64         bool provides(std::string const & name, bool ot1,
65                       bool complete, bool nomath);
66         /// Issue the familydefault switch
67         bool switchdefault() const { return switchdefault_; }
68         /// Does the font provide Old Style Figures as default?
69         bool osfDefault() const { return osfdefault_; }
70         /// Is this font available?
71         bool available(bool ot1, bool nomath);
72         /// Does this font provide an alternative without math?
73         bool providesNoMath(bool ot1, bool complete);
74         /// Does this font provide Old Style Figures?
75         bool providesOSF(bool ot1, bool complete, bool nomath);
76         /// Does this font provide optional true SmallCaps?
77         bool providesSC(bool ot1, bool complete, bool nomath);
78         /** does this font provide OSF and Small Caps only via
79          * a single, undifferentiated expert option?
80          */
81         bool hasMonolithicExpertSet(bool ot1, bool complete, bool nomath);
82         /// Does this font provide scaling?
83         bool providesScale(bool ot1, bool complete, bool nomath);
84         /// Return the LaTeX Code
85         std::string const getLaTeXCode(bool dryrun, bool ot1, bool complete,
86                                        bool sc, bool osf, bool nomath,
87                                        std::string const & extraopts = std::string(),
88                                        int const & scale = 100);
89         /// Return the actually used font
90         docstring const getUsedFont(bool ot1, bool complete, bool nomath);
91         /// Return the actually used package
92         docstring const getUsedPackage(bool ot1, bool complete, bool nomath);
93         ///
94         bool read(Lexer & lex);
95         ///
96         bool readFont(Lexer & lex);
97 private:
98         /// Return the preferred available package
99         std::string const getAvailablePackage(bool dryrun);
100         /// Return the package options
101         std::string const getPackageOptions(bool ot1,
102                                             bool complete,
103                                             bool sc,
104                                             bool osf,
105                                             int scale,
106                                             std::string const & extraopts,
107                                             bool nomath);
108         /// Return an alternative font
109         LaTeXFont altFont(docstring const & name);
110         ///
111         docstring name_;
112         ///
113         docstring guiname_;
114         ///
115         docstring family_;
116         ///
117         docstring package_;
118         ///
119         std::vector<std::string> fontenc_;
120         ///
121         std::vector<docstring> altfonts_;
122         ///
123         docstring completefont_;
124         ///
125         docstring nomathfont_;
126         ///
127         docstring ot1font_;
128         ///
129         docstring osffont_;
130         ///
131         docstring packageoptions_;
132         ///
133         docstring osfoption_;
134         ///
135         docstring scoption_;
136         ///
137         docstring osfscoption_;
138         ///
139         docstring scaleoption_;
140         ///
141         std::vector<std::string> provides_;
142         ///
143         docstring requires_;
144         ///
145         docstring preamble_;
146         ///
147         bool osfdefault_;
148         ///
149         bool switchdefault_;
150         ///
151         bool moreopts_;
152 };
153
154
155 /** The list of available LaTeX fonts
156  */
157 class LaTeXFonts {
158 public:
159         ///
160         typedef std::map<docstring, LaTeXFont> TexFontMap;
161         /// Get all LaTeXFonts
162         TexFontMap getLaTeXFonts();
163         /// Get a specific LaTeXFont \p name
164         LaTeXFont getLaTeXFont(docstring const & name);
165         /// Get a specific AltFont \p name
166         LaTeXFont getAltFont(docstring const & name);
167 private:
168         ///
169         void readLaTeXFonts();
170         ///
171         TexFontMap texfontmap_;
172         ///
173         TexFontMap texaltfontmap_;
174 };
175
176 /// Implementation is in LyX.cpp
177 extern LaTeXFonts & theLaTeXFonts();
178
179
180 } // namespace lyx
181
182 #endif