]> git.lyx.org Git - lyx.git/blob - src/LaTeXFonts.h
54ed5ad9c4f97c11c7faed97fb285f7f3b7b16c7
[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 packages if package() is not available
39         std::vector<docstring> const & altpackages() { return altpackages_; }
40         /// A package that provides all families
41         docstring const & completepackage() { return completepackage_; }
42         /// A package specifically needed for OT1 font encoding
43         docstring const & ot1package() { return ot1package_; }
44         /// A package that provides Old Style Figures for this font
45         docstring const & osfpackage() { return osfpackage_; }
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) const;
60         /// Issue the familydefault switch
61         bool switchdefault() const { return switchdefault_; }
62         /// Is this font available?
63         bool available(bool ot1 = false) const;
64         /// Does this font provide Old Style Figures?
65         bool providesOSF(bool ot1 = false) const;
66         /// Does this font provide optional true SmallCaps?
67         bool providesSC(bool ot1 = false) const;
68         /// Does this font provide scaling?
69         bool providesScale(bool ot1 = false) const;
70         /// Return the LaTeX Code
71         std::string const getLaTeXCode(bool dryrun, bool ot1, bool complete,
72                                        bool sc, bool osf,
73                                        int const & scale = 100);
74         ///
75         bool read(Lexer & lex);
76         ///
77         bool readFont(Lexer & lex);
78 private:
79         /// Return the preferred available package 
80         std::string const getAvailablePackage(bool dryrun,
81                                               bool ot1,
82                                               bool complete,
83                                               bool & alt);
84         /// Return the package options
85         std::string const getPackageOptions(bool ot1,
86                                             bool sc,
87                                             bool osf,
88                                             int scale);
89         ///
90         docstring name_;
91         ///
92         docstring guiname_;
93         ///
94         docstring family_;
95         ///
96         docstring package_;
97         ///
98         std::vector<docstring> altpackages_;
99         ///
100         docstring completepackage_;
101         ///
102         docstring ot1package_;
103         ///
104         docstring osfpackage_;
105         ///
106         docstring packageoption_;
107         ///
108         docstring osfoption_;
109         ///
110         docstring scoption_;
111         ///
112         docstring osfscoption_;
113         ///
114         docstring scaleoption_;
115         ///
116         std::vector<std::string> provides_;
117         ///
118         docstring requires_;
119         ///
120         bool switchdefault_;
121         ///
122         bool available_;
123         ///
124         bool available_ot1_;
125 };
126   
127   
128 /** The list of available LaTeX fonts
129  */
130 class LaTeXFonts {
131 public:
132         ///
133         typedef std::map<docstring, LaTeXFont> TexFontMap;
134         /// Get all LaTeXFonts
135         TexFontMap getLaTeXFonts();
136         /// Get a specific LaTeXFont \p name
137         LaTeXFont getLaTeXFont(docstring const & name);
138 private:
139         ///
140         void readLaTeXFonts();
141         ///
142         TexFontMap texfontmap_;
143 };
144
145 /// Implementation is in LyX.cpp
146 extern LaTeXFonts & theLaTeXFonts();
147
148
149 } // namespace lyx
150
151 #endif