X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLaTeXFonts.cpp;h=c9d030e8c343af500af6d0ac204da4c988bcbb43;hb=7067f48fa7afb89575abc58495d076078ce20137;hp=e58b55f5048138c33c496cc68f91153aa1fdb99c;hpb=3335344261baf578872441242affd5375d9e4019;p=lyx.git diff --git a/src/LaTeXFonts.cpp b/src/LaTeXFonts.cpp index e58b55f504..c9d030e8c3 100644 --- a/src/LaTeXFonts.cpp +++ b/src/LaTeXFonts.cpp @@ -35,13 +35,13 @@ namespace lyx { LaTeXFonts latexfonts; -LaTeXFont LaTeXFont::altFont(docstring const & name) +LaTeXFont LaTeXFont::altFont(docstring const & name) const { return theLaTeXFonts().getAltFont(name); } -bool LaTeXFont::available(bool ot1, bool nomath) +bool LaTeXFont::available(bool ot1, bool nomath) const { if (nomath && !nomathfont_.empty()) return altFont(nomathfont_).available(ot1, nomath); @@ -57,8 +57,8 @@ bool LaTeXFont::available(bool ot1, bool nomath) && LaTeXFeatures::isAvailable(to_ascii(package_))) return true; else if (!altfonts_.empty()) { - for (size_t i = 0; i < altfonts_.size(); ++i) { - if (altFont(altfonts_[i]).available(ot1, nomath)) + for (auto const & name : altfonts_) { + if (altFont(name).available(ot1, nomath)) return true; } } @@ -66,7 +66,7 @@ bool LaTeXFont::available(bool ot1, bool nomath) } -bool LaTeXFont::providesNoMath(bool ot1, bool complete) +bool LaTeXFont::providesNoMath(bool ot1, bool complete) const { docstring const usedfont = getUsedFont(ot1, complete, false, false); @@ -79,7 +79,7 @@ bool LaTeXFont::providesNoMath(bool ot1, bool complete) } -bool LaTeXFont::providesOSF(bool ot1, bool complete, bool nomath) +bool LaTeXFont::providesOSF(bool ot1, bool complete, bool nomath) const { docstring const usedfont = getUsedFont(ot1, complete, nomath, false); @@ -96,7 +96,7 @@ bool LaTeXFont::providesOSF(bool ot1, bool complete, bool nomath) } -bool LaTeXFont::providesSC(bool ot1, bool complete, bool nomath) +bool LaTeXFont::providesSC(bool ot1, bool complete, bool nomath) const { docstring const usedfont = getUsedFont(ot1, complete, nomath, false); @@ -111,7 +111,7 @@ bool LaTeXFont::providesSC(bool ot1, bool complete, bool nomath) } -bool LaTeXFont::hasMonolithicExpertSet(bool ot1, bool complete, bool nomath) +bool LaTeXFont::hasMonolithicExpertSet(bool ot1, bool complete, bool nomath) const { docstring const usedfont = getUsedFont(ot1, complete, nomath, false); @@ -124,7 +124,7 @@ bool LaTeXFont::hasMonolithicExpertSet(bool ot1, bool complete, bool nomath) } -bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath) +bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath) const { docstring const usedfont = getUsedFont(ot1, complete, nomath, false); @@ -134,11 +134,11 @@ bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath) return altFont(usedfont).providesScale(ot1, complete, nomath); else if (!available(ot1, nomath)) return false; - return (!scaleoption_.empty()); + return (!scaleoption_.empty() || !scalecmd_.empty()); } -bool LaTeXFont::providesMoreOptions(bool ot1, bool complete, bool nomath) +bool LaTeXFont::providesMoreOptions(bool ot1, bool complete, bool nomath) const { docstring const usedfont = getUsedFont(ot1, complete, nomath, false); @@ -152,7 +152,7 @@ bool LaTeXFont::providesMoreOptions(bool ot1, bool complete, bool nomath) return (moreopts_); } -bool LaTeXFont::provides(std::string const & name, bool ot1, bool complete, bool nomath) +bool LaTeXFont::provides(std::string const & name, bool ot1, bool complete, bool nomath) const { docstring const usedfont = getUsedFont(ot1, complete, nomath, false); @@ -163,15 +163,15 @@ bool LaTeXFont::provides(std::string const & name, bool ot1, bool complete, bool else if (provides_.empty()) return false; - for (size_t i = 0; i < provides_.size(); ++i) { - if (provides_[i] == name) + for (auto const & provide : provides_) { + if (provide == name) return true; } return false; } -docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath, bool osf) +docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath, bool osf) const { if (osf && osfFontOnly()) return osffont_; @@ -200,8 +200,8 @@ docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath, boo return name_; } else if (!altfonts_.empty()) { - for (size_t i = 0; i < altfonts_.size(); ++i) { - LaTeXFont altf = altFont(altfonts_[i]); + for (auto const & name : altfonts_) { + LaTeXFont altf = altFont(name); if (altf.available(ot1, nomath)) return altf.getUsedFont(ot1, complete, nomath, osf); } @@ -211,7 +211,7 @@ docstring const LaTeXFont::getUsedFont(bool ot1, bool complete, bool nomath, boo } -docstring const LaTeXFont::getUsedPackage(bool ot1, bool complete, bool nomath) +docstring const LaTeXFont::getUsedPackage(bool ot1, bool complete, bool nomath) const { docstring const usedfont = getUsedFont(ot1, complete, nomath, false); if (usedfont.empty()) @@ -220,7 +220,7 @@ docstring const LaTeXFont::getUsedPackage(bool ot1, bool complete, bool nomath) } -string const LaTeXFont::getAvailablePackage(bool dryrun) +string const LaTeXFont::getAvailablePackage(bool dryrun) const { if (package_.empty()) return string(); @@ -245,7 +245,7 @@ string const LaTeXFont::getAvailablePackage(bool dryrun) string const LaTeXFont::getPackageOptions(bool ot1, bool complete, bool sc, bool osf, - int scale, string const & extraopts, bool nomath) + int scale, string const & extraopts, bool nomath) const { ostringstream os; bool const needosfopt = (osf != osfdefault_); @@ -292,8 +292,7 @@ string const LaTeXFont::getPackageOptions(bool ot1, bool complete, bool sc, bool string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool sc, - bool osf, bool nomath, string const & extraopts, - int const & scale) + bool osf, bool nomath, string const & extraopts, int scale) const { ostringstream os; @@ -329,6 +328,15 @@ 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, extraopts, scale); + if (scale != 100 && !scalecmd_.empty() + && providesScale(ot1, complete, nomath)) { + if (contains(scalecmd_, '@')) + os << "\\makeatletter\n"; + os << subst(to_ascii(scalecmd_), "$$val", + convert(float(scale) / 100)) << '\n'; + if (contains(scalecmd_, '@')) + os << "\\makeatother\n"; + } if (!preamble_.empty()) os << to_utf8(preamble_); @@ -369,6 +377,7 @@ bool LaTeXFont::readFont(Lexer & lex) LF_PREAMBLE, LF_PROVIDES, LF_REQUIRES, + LF_SCALECMD, LF_SCALEOPTION, LF_SCOPTION, LF_SWITCHDEFAULT @@ -395,6 +404,7 @@ bool LaTeXFont::readFont(Lexer & lex) { "preamble", LF_PREAMBLE }, { "provides", LF_PROVIDES }, { "requires", LF_REQUIRES }, + { "scalecommand", LF_SCALECMD }, { "scaleoption", LF_SCALEOPTION }, { "scoption", LF_SCOPTION }, { "switchdefault", LF_SWITCHDEFAULT } @@ -483,6 +493,9 @@ bool LaTeXFont::readFont(Lexer & lex) case LF_REQUIRES: lex >> required_; break; + case LF_SCALECMD: + lex >> scalecmd_; + break; case LF_SCALEOPTION: lex >> scaleoption_; break; @@ -508,10 +521,10 @@ bool LaTeXFont::readFont(Lexer & lex) bool LaTeXFont::read(Lexer & lex) { - switchdefault_ = 0; - osfdefault_ = 0; - moreopts_ = 0; - osffontonly_ = 0; + switchdefault_ = false; + osfdefault_ = false; + moreopts_ = false; + osffontonly_ = false; if (!lex.next()) { lex.printError("No name given for LaTeX font: `$$Token'.");