lyx_mirror/src/LaTeXFonts.h

192 lines
5.6 KiB
C
Raw Normal View History

// -*- C++ -*-
/**
* \file LaTeXFonts.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#ifndef LATEXFONTS_H
#define LATEXFONTS_H
#include "support/docstring.h"
#include <map>
#include <vector>
namespace lyx {
class Lexer;
/// LaTeX Font definition
class LaTeXFont {
public:
/// TeX font
// FIXME Add fontenc tag to classes which is used if no font is specified?
LaTeXFont() : osfdefault_(false), switchdefault_(false), moreopts_(false),
osffontonly_(false) { fontenc_.push_back("T1"); }
/// The font name
2020-11-01 12:00:49 +00:00
docstring const & name() const { return name_; }
/// The name to appear in the document dialog
2020-11-01 12:00:49 +00:00
docstring const & guiname() const { return guiname_; }
/// Font family (rm, sf, tt)
2020-11-01 12:00:49 +00:00
docstring const & family() const { return family_; }
/// The package that provides this font
2020-11-01 12:00:49 +00:00
docstring const & package() const { return package_; }
/// Does this provide a specific font encoding?
bool hasFontenc(std::string const &) const;
/// The font encoding(s)
std::vector<std::string> const & fontencs() const { return fontenc_; }
/// Alternative font if package() is not available
2020-11-01 12:00:49 +00:00
std::vector<docstring> const & altfonts() const { return altfonts_; }
/// A font that provides all families
2020-11-01 12:00:49 +00:00
docstring const & completefont() const { return completefont_; }
/// A font specifically needed for OT1 font encoding
2020-11-01 12:00:49 +00:00
docstring const & ot1font() const { return ot1font_; }
/// A font that provides Old Style Figures for this type face
2020-11-01 12:00:49 +00:00
docstring const & osffont() const { return osffont_; }
/// A package option for Old Style Figures
2020-11-01 12:00:49 +00:00
docstring const & osfoption() const { return osfoption_; }
/// A package option for true SmallCaps
2020-11-01 12:00:49 +00:00
docstring const & scoption() const { return scoption_; }
/// A package option for both Old Style Figures and SmallCaps
2020-11-01 12:00:49 +00:00
docstring const & osfscoption() const { return osfscoption_; }
/// A package option for font scaling
2020-11-01 12:00:49 +00:00
docstring const & scaleoption() const { return scaleoption_; }
/// A macro for font scaling
2020-11-01 12:00:49 +00:00
docstring const & scalecmd() const { return scalecmd_; }
/// Does this provide additional options?
2020-11-01 12:00:49 +00:00
bool providesMoreOptions(bool ot1, bool complete, bool nomath) const;
/// Alternative requirement to test for
2020-11-01 12:00:49 +00:00
docstring const & required() const { return required_; }
/// Does this font provide a given \p feature
bool provides(std::string const & name, bool ot1,
2020-11-01 12:00:49 +00:00
bool complete, bool nomath) const;
/// Issue the familydefault switch
bool switchdefault() const { return switchdefault_; }
2012-09-19 15:46:55 +00:00
/// Does the font provide Old Style Figures as default?
bool osfDefault() const { return osfdefault_; }
/// Does OSF font replace (rather than complement) the non-OSF one?
bool osfFontOnly() const { return osffontonly_; }
/// Is this font available?
2020-11-01 12:00:49 +00:00
bool available(bool ot1, bool nomath) const;
2017-07-03 17:45:58 +00:00
/// Does this font provide an alternative without math?
2020-11-01 12:00:49 +00:00
bool providesNoMath(bool ot1, bool complete) const;
/// Does this font provide Old Style Figures?
2020-11-01 12:00:49 +00:00
bool providesOSF(bool ot1, bool complete, bool nomath) const;
/// Does this font provide optional true SmallCaps?
2020-11-01 12:00:49 +00:00
bool providesSC(bool ot1, bool complete, bool nomath) const;
2017-07-03 17:45:58 +00:00
/** does this font provide OSF and Small Caps only via
* a single, undifferentiated expert option?
*/
2020-11-01 12:00:49 +00:00
bool hasMonolithicExpertSet(bool ot1, bool complete, bool nomath) const;
/// Does this font provide scaling?
2020-11-01 12:00:49 +00:00
bool providesScale(bool ot1, bool complete, bool nomath) const;
2012-08-18 09:57:16 +00:00
/// Return the LaTeX Code
std::string const getLaTeXCode(bool dryrun, bool ot1, bool complete,
bool sc, bool osf, bool nomath,
std::string const & extraopts = std::string(),
2020-11-01 12:00:49 +00:00
int scale = 100) const;
/// Return the actually used font
2020-11-01 12:00:49 +00:00
docstring const getUsedFont(bool ot1, bool complete, bool nomath, bool osf) const;
/// Return the actually used package
2020-11-01 12:00:49 +00:00
docstring const getUsedPackage(bool ot1, bool complete, bool nomath) const;
///
bool read(Lexer & lex);
///
bool readFont(Lexer & lex);
private:
2017-07-03 17:45:58 +00:00
/// Return the preferred available package
2020-11-01 12:00:49 +00:00
std::string const getAvailablePackage(bool dryrun) const;
2012-08-18 09:57:16 +00:00
/// Return the package options
std::string const getPackageOptions(bool ot1,
bool complete,
2012-08-18 09:57:16 +00:00
bool sc,
bool osf,
int scale,
std::string const & extraopts,
2020-11-01 12:00:49 +00:00
bool nomath) const;
/// Return an alternative font
2020-11-01 12:00:49 +00:00
LaTeXFont altFont(docstring const & name) const;
///
docstring name_;
///
docstring guiname_;
///
docstring family_;
///
docstring package_;
///
std::vector<std::string> fontenc_;
///
std::vector<docstring> altfonts_;
///
docstring completefont_;
///
docstring nomathfont_;
///
docstring ot1font_;
///
docstring osffont_;
///
2019-07-17 19:16:05 +00:00
docstring packageoptions_;
///
docstring osfoption_;
///
docstring scoption_;
///
docstring osfscoption_;
///
docstring scaleoption_;
///
docstring scalecmd_;
///
std::vector<std::string> provides_;
///
docstring required_;
///
docstring preamble_;
2013-02-09 10:00:42 +00:00
///
2012-09-19 15:46:55 +00:00
bool osfdefault_;
///
bool switchdefault_;
///
bool moreopts_;
///
bool osffontonly_;
};
2017-07-03 17:45:58 +00:00
/** The list of available LaTeX fonts
*/
class LaTeXFonts {
public:
///
typedef std::map<docstring, LaTeXFont> TexFontMap;
/// Get all LaTeXFonts
TexFontMap getLaTeXFonts();
/// Get a specific LaTeXFont \p name
LaTeXFont getLaTeXFont(docstring const & name);
/// Get a specific AltFont \p name
LaTeXFont getAltFont(docstring const & name);
private:
///
void readLaTeXFonts();
///
TexFontMap texfontmap_;
///
TexFontMap texaltfontmap_;
};
/// Implementation is in LyX.cpp
extern LaTeXFonts & theLaTeXFonts();
} // namespace lyx
#endif