]> git.lyx.org Git - lyx.git/blob - src/LaTeXFonts.h
Fix text direction issue for InsetInfo in RTL context
[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) { 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 needed to load this font
52         docstring const & packageoption() { return packageoption_; }
53         /// A package option for Old Style Figures
54         docstring const & osfoption() { return osfoption_; }
55         /// A package option for true SmallCaps
56         docstring const & scoption() { return scoption_; }
57         /// A package option for both Old Style Figures and SmallCaps
58         docstring const & osfscoption() { return osfscoption_; }
59         /// A package option for font scaling
60         docstring const & scaleoption() { return scaleoption_; }
61         /// Alternative requirement to test for
62         docstring const & requires() { 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                                        int const & scale = 100);
88         /// Return the actually used font
89         docstring const getUsedFont(bool ot1, bool complete, bool nomath);
90         /// Return the actually used package
91         docstring const getUsedPackage(bool ot1, bool complete, bool nomath);
92         ///
93         bool read(Lexer & lex);
94         ///
95         bool readFont(Lexer & lex);
96 private:
97         /// Return the preferred available package
98         std::string const getAvailablePackage(bool dryrun);
99         /// Return the package options
100         std::string const getPackageOptions(bool ot1,
101                                             bool complete,
102                                             bool sc,
103                                             bool osf,
104                                             int scale,
105                                             bool nomath);
106         /// Return an alternative font
107         LaTeXFont altFont(docstring const & name);
108         ///
109         docstring name_;
110         ///
111         docstring guiname_;
112         ///
113         docstring family_;
114         ///
115         docstring package_;
116         ///
117         std::vector<std::string> fontenc_;
118         ///
119         std::vector<docstring> altfonts_;
120         ///
121         docstring completefont_;
122         ///
123         docstring nomathfont_;
124         ///
125         docstring ot1font_;
126         ///
127         docstring osffont_;
128         ///
129         docstring packageoption_;
130         ///
131         docstring osfoption_;
132         ///
133         docstring scoption_;
134         ///
135         docstring osfscoption_;
136         ///
137         docstring scaleoption_;
138         ///
139         std::vector<std::string> provides_;
140         ///
141         docstring requires_;
142         ///
143         docstring preamble_;
144         ///
145         bool osfdefault_;
146         ///
147         bool switchdefault_;
148 };
149
150
151 /** The list of available LaTeX fonts
152  */
153 class LaTeXFonts {
154 public:
155         ///
156         typedef std::map<docstring, LaTeXFont> TexFontMap;
157         /// Get all LaTeXFonts
158         TexFontMap getLaTeXFonts();
159         /// Get a specific LaTeXFont \p name
160         LaTeXFont getLaTeXFont(docstring const & name);
161         /// Get a specific AltFont \p name
162         LaTeXFont getAltFont(docstring const & name);
163 private:
164         ///
165         void readLaTeXFonts();
166         ///
167         TexFontMap texfontmap_;
168         ///
169         TexFontMap texaltfontmap_;
170 };
171
172 /// Implementation is in LyX.cpp
173 extern LaTeXFonts & theLaTeXFonts();
174
175
176 } // namespace lyx
177
178 #endif