]> git.lyx.org Git - lyx.git/blob - src/LaTeXFonts.h
Docstringify getLongString in general and preamble snippets in particular
[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() : osfdefault_(false), 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         /// Return the actually used package
86         docstring const getUsedPackage(bool ot1, bool complete, bool nomath);
87         ///
88         bool read(Lexer & lex);
89         ///
90         bool readFont(Lexer & lex);
91 private:
92         /// Return the preferred available package 
93         std::string const getAvailablePackage(bool dryrun);
94         /// Return the package options
95         std::string const getPackageOptions(bool ot1,
96                                             bool complete,
97                                             bool sc,
98                                             bool osf,
99                                             int scale,
100                                             bool nomath);
101         /// Return an alternative font
102         LaTeXFont altFont(docstring const & name);
103         ///
104         docstring name_;
105         ///
106         docstring guiname_;
107         ///
108         docstring family_;
109         ///
110         docstring package_;
111         ///
112         std::vector<docstring> altfonts_;
113         ///
114         docstring completefont_;
115         ///
116         docstring nomathfont_;
117         ///
118         docstring ot1font_;
119         ///
120         docstring osffont_;
121         ///
122         docstring packageoption_;
123         ///
124         docstring osfoption_;
125         ///
126         docstring scoption_;
127         ///
128         docstring osfscoption_;
129         ///
130         docstring scaleoption_;
131         ///
132         std::vector<std::string> provides_;
133         ///
134         docstring requires_;
135         ///
136         docstring preamble_;
137         ///
138         bool osfdefault_;
139         ///
140         bool switchdefault_;
141 };
142   
143   
144 /** The list of available LaTeX fonts
145  */
146 class LaTeXFonts {
147 public:
148         ///
149         typedef std::map<docstring, LaTeXFont> TexFontMap;
150         /// Get all LaTeXFonts
151         TexFontMap getLaTeXFonts();
152         /// Get a specific LaTeXFont \p name
153         LaTeXFont getLaTeXFont(docstring const & name);
154         /// Get a specific AltFont \p name
155         LaTeXFont getAltFont(docstring const & name);
156 private:
157         ///
158         void readLaTeXFonts();
159         ///
160         TexFontMap texfontmap_;
161         ///
162         TexFontMap texaltfontmap_;
163 };
164
165 /// Implementation is in LyX.cpp
166 extern LaTeXFonts & theLaTeXFonts();
167
168
169 } // namespace lyx
170
171 #endif