X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLaTeXFonts.cpp;h=8cd51139c1576f178bdcdb44a966bfccf79713c7;hb=c5301a6495b108df5b307da39dad5be65926f76b;hp=4cc1b82315bd157e0788be8494d90927bb78340d;hpb=9cbba74a62bce39c5128800474edcb45028a6df2;p=lyx.git diff --git a/src/LaTeXFonts.cpp b/src/LaTeXFonts.cpp index 4cc1b82315..8cd51139c1 100644 --- a/src/LaTeXFonts.cpp +++ b/src/LaTeXFonts.cpp @@ -19,6 +19,7 @@ #include "support/convert.h" #include "support/debug.h" +#include "support/docstream.h" #include "support/FileName.h" #include "support/filetools.h" #include "support/gettext.h" @@ -110,6 +111,19 @@ bool LaTeXFont::providesSC(bool ot1, bool complete, bool nomath) } +bool LaTeXFont::hasMonolithicExpertSet(bool ot1, bool complete, bool nomath) +{ + docstring const usedfont = getUsedFont(ot1, complete, nomath); + + if (usedfont.empty()) + return false; + else if (usedfont != name_) + return altFont(usedfont).hasMonolithicExpertSet(ot1, complete, nomath); + return (!osfoption_.empty() && !scoption_.empty() && osfoption_ == scoption_) + || (osfoption_.empty() && scoption_.empty() && !osfscoption_.empty()); +} + + bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath) { docstring const usedfont = getUsedFont(ot1, complete, nomath); @@ -163,6 +177,11 @@ docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath) else if (!package_.empty() && LaTeXFeatures::isAvailable(to_ascii(package_))) return name_; + else if (!preamble_.empty() && package_.empty() + && requires_.empty() && !switchdefault_ + && altfonts_.empty()) { + return name_; + } else if (!altfonts_.empty()) { for (size_t i = 0; i < altfonts_.size(); ++i) { LaTeXFont altf = altFont(altfonts_[i]); @@ -175,6 +194,15 @@ docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath) } +docstring const LaTeXFont::getUsedPackage(bool ot1, bool complete, bool nomath) +{ + docstring const usedfont = getUsedFont(ot1, complete, nomath); + if (usedfont.empty()) + return docstring(); + return theLaTeXFonts().getLaTeXFont(usedfont).package(); +} + + string const LaTeXFont::getAvailablePackage(bool dryrun) { if (package_.empty()) @@ -276,12 +304,22 @@ string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool os << altFont(osffont_).getLaTeXCode(dryrun, ot1, complete, sc, osf, nomath, scale); if (!preamble_.empty()) - os << preamble_; + os << to_utf8(preamble_); return os.str(); } +bool LaTeXFont::hasFontenc(string const & name) const +{ + for (auto const & fe : fontenc_) { + if (fe == name) + return true; + } + return false; +} + + bool LaTeXFont::readFont(Lexer & lex) { enum LaTeXFontTags { @@ -289,6 +327,7 @@ bool LaTeXFont::readFont(Lexer & lex) LF_COMPLETE_FONT, LF_END, LF_FAMILY, + LF_FONTENC, LF_GUINAME, LF_NOMATHFONT, LF_OSFDEFAULT, @@ -312,6 +351,7 @@ bool LaTeXFont::readFont(Lexer & lex) { "completefont", LF_COMPLETE_FONT }, { "endfont", LF_END }, { "family", LF_FAMILY }, + { "fontencoding", LF_FONTENC }, { "guiname", LF_GUINAME }, { "nomathfont", LF_NOMATHFONT }, { "osfdefault", LF_OSFDEFAULT }, @@ -345,7 +385,7 @@ bool LaTeXFont::readFont(Lexer & lex) error = true; continue; - default: + default: break; } switch (static_cast(le)) { @@ -367,6 +407,12 @@ bool LaTeXFont::readFont(Lexer & lex) case LF_GUINAME: lex >> guiname_; break; + case LF_FONTENC: { + lex.eatLine(); + string fe = lex.getString(); + fontenc_ = getVectorFromString(fe); + break; + } case LF_NOMATHFONT: lex >> nomathfont_; break; @@ -392,7 +438,7 @@ bool LaTeXFont::readFont(Lexer & lex) lex >> packageoption_; break; case LF_PREAMBLE: - preamble_ = lex.getLongString("EndPreamble"); + preamble_ = lex.getLongString(from_ascii("EndPreamble")); break; case LF_PROVIDES: { lex.eatLine(); @@ -440,6 +486,9 @@ bool LaTeXFont::read(Lexer & lex) return false; } + if (fontenc_.empty()) + fontenc_.push_back("T1"); + return true; }