X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FLaTeXFonts.cpp;h=ad65439b942df50f738a225e63a8a79cdc76390f;hb=97dc58513884bb89b6a015c2c7dc61c8bb3f7dfe;hp=c837815fc659f2d0c31db2a961c54a61cc9b5b4c;hpb=f94220a79cc2aea755be8c03e2e309f837c141ac;p=lyx.git diff --git a/src/LaTeXFonts.cpp b/src/LaTeXFonts.cpp index c837815fc6..ad65439b94 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()) @@ -275,6 +303,9 @@ string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool if (osf && providesOSF(ot1, complete, nomath) && !osffont_.empty()) os << altFont(osffont_).getLaTeXCode(dryrun, ot1, complete, sc, osf, nomath, scale); + if (!preamble_.empty()) + os << to_utf8(preamble_); + return os.str(); } @@ -295,6 +326,7 @@ bool LaTeXFont::readFont(Lexer & lex) LF_OT1_FONT, LF_PACKAGE, LF_PACKAGEOPTION, + LF_PREAMBLE, LF_PROVIDES, LF_REQUIRES, LF_SCALEOPTION, @@ -317,6 +349,7 @@ bool LaTeXFont::readFont(Lexer & lex) { "ot1font", LF_OT1_FONT }, { "package", LF_PACKAGE }, { "packageoption", LF_PACKAGEOPTION }, + { "preamble", LF_PREAMBLE }, { "provides", LF_PROVIDES }, { "requires", LF_REQUIRES }, { "scaleoption", LF_SCALEOPTION }, @@ -340,7 +373,7 @@ bool LaTeXFont::readFont(Lexer & lex) error = true; continue; - default: + default: break; } switch (static_cast(le)) { @@ -386,6 +419,9 @@ bool LaTeXFont::readFont(Lexer & lex) case LF_PACKAGEOPTION: lex >> packageoption_; break; + case LF_PREAMBLE: + preamble_ = lex.getLongString(from_ascii("EndPreamble")); + break; case LF_PROVIDES: { lex.eatLine(); string features = lex.getString();