]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFonts.cpp
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / LaTeXFonts.cpp
index 8cd51139c1576f178bdcdb44a966bfccf79713c7..b52a8c06d5e9c94bf96808fc4aa1f0f21f39a974 100644 (file)
@@ -137,6 +137,21 @@ bool LaTeXFont::providesScale(bool ot1, bool complete, bool nomath)
        return (!scaleoption_.empty());
 }
 
+
+bool LaTeXFont::providesMoreOptions(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).providesMoreOptions(ot1, complete, nomath);
+       else if (!available(ot1, nomath))
+               return false;
+
+       return (moreopts_);
+}
+
 bool LaTeXFont::provides(std::string const & name, bool ot1, bool complete, bool nomath)
 {
        docstring const usedfont = getUsedFont(ot1, complete, nomath);
@@ -228,15 +243,16 @@ string const LaTeXFont::getAvailablePackage(bool dryrun)
 
 
 string const LaTeXFont::getPackageOptions(bool ot1, bool complete, bool sc, bool osf,
-                                         int scale, bool nomath)
+                                         int scale, string const & extraopts, bool nomath)
 {
        ostringstream os;
        bool const needosfopt = (osf != osfdefault_);
        bool const has_osf = providesOSF(ot1, complete, nomath);
        bool const has_sc = providesSC(ot1, complete, nomath);
+       bool const moreopts = providesMoreOptions(ot1, complete, nomath);
 
-       if (!packageoption_.empty())
-               os << to_ascii(packageoption_);
+       if (!packageoptions_.empty())
+               os << to_ascii(packageoptions_);
 
        if (sc && needosfopt && has_osf && has_sc) {
                if (!os.str().empty())
@@ -263,12 +279,19 @@ string const LaTeXFont::getPackageOptions(bool ot1, bool complete, bool sc, bool
                os << subst(to_ascii(scaleoption_), "$$val",
                            convert<std::string>(float(scale) / 100));
        }
+
+       if (moreopts && !extraopts.empty()) {
+               if (!os.str().empty())
+                       os << ',';
+               os << extraopts;
+       }
        return os.str();
 }
 
 
 string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool sc,
-                                    bool osf, bool nomath, int const & scale)
+                                    bool osf, bool nomath, string const & extraopts,
+                                    int const & scale)
 {
        ostringstream os;
 
@@ -276,7 +299,8 @@ string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool
        if (usedfont.empty())
                return string();
        else if (usedfont != name_)
-               return altFont(usedfont).getLaTeXCode(dryrun, ot1, complete, sc, osf, nomath, scale);
+               return altFont(usedfont).getLaTeXCode(dryrun, ot1, complete, sc,
+                                                     osf, nomath, extraopts, scale);
 
        if (switchdefault_) {
                if (family_.empty()) {
@@ -294,14 +318,15 @@ string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool
        } else {
                string const package =
                        getAvailablePackage(dryrun);
-               string const packageopts = getPackageOptions(ot1, complete, sc, osf, scale, nomath);
+               string const packageopts = getPackageOptions(ot1, complete, sc, osf, scale, extraopts, nomath);
                if (packageopts.empty() && !package.empty())
                        os << "\\usepackage{" << package << "}\n";
                else if (!packageopts.empty() && !package.empty())
                        os << "\\usepackage[" << packageopts << "]{" << package << "}\n";
        }
        if (osf && providesOSF(ot1, complete, nomath) && !osffont_.empty())
-               os << altFont(osffont_).getLaTeXCode(dryrun, ot1, complete, sc, osf, nomath, scale);
+               os << altFont(osffont_).getLaTeXCode(dryrun, ot1, complete, sc, osf,
+                                                    nomath, extraopts, scale);
 
        if (!preamble_.empty())
                os << to_utf8(preamble_);
@@ -335,8 +360,9 @@ bool LaTeXFont::readFont(Lexer & lex)
                LF_OSFOPTION,
                LF_OSFSCOPTION,
                LF_OT1_FONT,
+               LF_MOREOPTS,
                LF_PACKAGE,
-               LF_PACKAGEOPTION,
+               LF_PACKAGEOPTIONS,
                LF_PREAMBLE,
                LF_PROVIDES,
                LF_REQUIRES,
@@ -353,6 +379,7 @@ bool LaTeXFont::readFont(Lexer & lex)
                { "family",               LF_FAMILY },
                { "fontencoding",         LF_FONTENC },
                { "guiname",              LF_GUINAME },
+               { "moreoptions",          LF_MOREOPTS },
                { "nomathfont",           LF_NOMATHFONT },
                { "osfdefault",           LF_OSFDEFAULT },
                { "osffont",              LF_OSFFONT },
@@ -360,7 +387,7 @@ bool LaTeXFont::readFont(Lexer & lex)
                { "osfscoption",          LF_OSFSCOPTION },
                { "ot1font",              LF_OT1_FONT },
                { "package",              LF_PACKAGE },
-               { "packageoption",        LF_PACKAGEOPTION },
+               { "packageoptions",       LF_PACKAGEOPTIONS },
                { "preamble",             LF_PREAMBLE },
                { "provides",             LF_PROVIDES },
                { "requires",             LF_REQUIRES },
@@ -434,8 +461,8 @@ bool LaTeXFont::readFont(Lexer & lex)
                case LF_PACKAGE:
                        lex >> package_;
                        break;
-               case LF_PACKAGEOPTION:
-                       lex >> packageoption_;
+               case LF_PACKAGEOPTIONS:
+                       lex >> packageoptions_;
                        break;
                case LF_PREAMBLE:
                        preamble_ = lex.getLongString(from_ascii("EndPreamble"));
@@ -455,6 +482,9 @@ bool LaTeXFont::readFont(Lexer & lex)
                case LF_SCOPTION:
                        lex >> scoption_;
                        break;
+               case LF_MOREOPTS:
+                       lex >> moreopts_;
+                       break;
                case LF_SWITCHDEFAULT:
                        lex >> switchdefault_;
                        break;
@@ -473,6 +503,7 @@ bool LaTeXFont::read(Lexer & lex)
 {
        switchdefault_ = 0;
        osfdefault_ = 0;
+       moreopts_ = 0;
 
        if (!lex.next()) {
                lex.printError("No name given for LaTeX font: `$$Token'.");