]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFonts.cpp
Fix bug #12772
[lyx.git] / src / LaTeXFonts.cpp
index 00e19fa57dce537979b854e4652a52b6f7c46f48..c9d030e8c343af500af6d0ac204da4c988bcbb43 100644 (file)
@@ -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);
 
@@ -138,7 +138,7 @@ bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath)
 }
 
 
-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;
 
@@ -522,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'.");