The branch, master, has been updated. - Log -----------------------------------------------------------------
commit c409c9e3d1f470f716ef19c3438ed60428da63e2 Author: Juergen Spitzmueller <sp...@lyx.org> Date: Sat Aug 18 13:10:34 2012 +0200 Allow for general package options for LaTeX font packages (needed e.g. by mathdesign) diff --git a/lib/latexfonts b/lib/latexfonts index 794039a..681831d 100644 --- a/lib/latexfonts +++ b/lib/latexfonts @@ -13,6 +13,7 @@ # AltPackages <alternative packages (comma-separated)> # OT1Package <alternative package specifically for OT1 encoding> # CompletePackage <alternative package for the complete family> +# PackageOptions <general options to be passed to the package> # OsfOption <option for oldstyle figure support> # ScOption <option for true smallcaps support> # OsfScOption <option for combined osf and true smallcaps support> @@ -27,20 +28,23 @@ # done. # * "SwitchDefault 1" makes the font to be loaded by switching the default # family to <name> (e.g., \renewcommand{\rmdefault}{cmr}), whereas -# Package <package> loads it via \usepackage{package}. Normally, only -# one of these options is used per font. +# Package <package> loads it via \usepackage{package}. Only one of these +# options is used per font (SwitchDefault takes precendende). Note that +# SwitchDefault uses the font name. # * If AltPackages are defined, LyX will try to load them in the defined # order if the main package is not available. So # Package mathptmx # AltPackages mathptm,times # will try to load mathptm if mathptmx is not available and then times # if mathptm is not available either. +# No options will be passed to alternative packages! # * If Requires is set, LyX will check for this. If not, it will check # for Package and AltPackages. # * OT1Package will load the defined package instead of the default # package if the font encoding is OT1. This is necessary since some # newer packages for a font do not support this encoding. # The value "none" tells LyX not to load a package in OT1 encoding. +# No options will be passed to OT1 packages! # * CompletePackage is a package that is loaded if the current font is # selected as rm and both sf and tt are set to "default" (this allows # f. ex. to load "bera" as opposed to "beraserif"). diff --git a/src/LaTeXFonts.cpp b/src/LaTeXFonts.cpp index 562a8fc..6f89cd1 100644 --- a/src/LaTeXFonts.cpp +++ b/src/LaTeXFonts.cpp @@ -79,7 +79,7 @@ bool LaTeXFont::providesScale(bool ot1) const } -string const LaTeXFont::getAvailablePackage(bool dryrun, bool ot1, bool complete) +string const LaTeXFont::getAvailablePackage(bool dryrun, bool ot1, bool complete, bool & alt) { if (ot1 && !ot1package_.empty()) { if (ot1package_ != "none" @@ -103,8 +103,10 @@ string const LaTeXFont::getAvailablePackage(bool dryrun, bool ot1, bool complete return to_ascii(package_); else if (!altpackages_.empty()) { for (size_t i = 0; i < altpackages_.size(); ++i) { - if (LaTeXFeatures::isAvailable(to_ascii(altpackages_[i]))) + if (LaTeXFeatures::isAvailable(to_ascii(altpackages_[i]))) { + alt = true; return to_ascii(altpackages_[i]); + } } } // Output unavailable packages in source preview @@ -126,7 +128,11 @@ string const LaTeXFont::getPackageOptions(bool ot1, bool sc, bool osf, int scale return string(); ostringstream os; + if (!packageoption_.empty()) + os << to_ascii(packageoption_); if (sc && osf && providesOSF() && providesSC()) { + if (!os.str().empty()) + os << ','; if (!osfscoption_.empty()) os << to_ascii(osfscoption_); else @@ -164,9 +170,11 @@ string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool "is not available on your system. LyX will fall back to the default font."), requires_, guiname_), true); } else { + bool alt = false; string const package = - getAvailablePackage(dryrun, ot1, complete); - string const packageopts = getPackageOptions(ot1, sc, osf, scale); + getAvailablePackage(dryrun, ot1, complete, alt); + // Package options are not for alternative packages + string const packageopts = alt ? string() : getPackageOptions(ot1, sc, osf, scale); if (packageopts.empty() && !package.empty()) os << "\\usepackage{" << package << "}\n"; else if (!packageopts.empty() && !package.empty()) @@ -192,6 +200,7 @@ bool LaTeXFont::readFont(Lexer & lex) LF_OSFSCOPTION, LF_OT1_PACKAGE, LF_PACKAGE, + LF_PACKAGEOPTION, LF_REQUIRES, LF_SCALEOPTION, LF_SCOPTION, @@ -210,6 +219,7 @@ bool LaTeXFont::readFont(Lexer & lex) { "osfscoption", LF_OSFSCOPTION }, { "ot1package", LF_OT1_PACKAGE }, { "package", LF_PACKAGE }, + { "packageoption", LF_PACKAGEOPTION }, { "requires", LF_REQUIRES }, { "scaleoption", LF_SCALEOPTION }, { "scoption", LF_SCOPTION }, @@ -269,6 +279,9 @@ bool LaTeXFont::readFont(Lexer & lex) case LF_PACKAGE: lex >> package_; break; + case LF_PACKAGEOPTION: + lex >> packageoption_; + break; case LF_REQUIRES: lex >> requires_; break; diff --git a/src/LaTeXFonts.h b/src/LaTeXFonts.h index d12738e..b4d7d43 100644 --- a/src/LaTeXFonts.h +++ b/src/LaTeXFonts.h @@ -43,6 +43,8 @@ public: docstring const & ot1package() { return ot1package_; } /// A package that provides Old Style Figures for this font docstring const & osfpackage() { return osfpackage_; } + /// A package option needed to load this font + docstring const & packageoption() { return packageoption_; } /// A package option for Old Style Figures docstring const & osfoption() { return osfoption_; } /// A package option for true SmallCaps @@ -75,7 +77,8 @@ private: /// Return the preferred available package std::string const getAvailablePackage(bool dryrun, bool ot1, - bool complete); + bool complete, + bool & alt); /// Return the package options std::string const getPackageOptions(bool ot1, bool sc, @@ -98,6 +101,8 @@ private: /// docstring osfpackage_; /// + docstring packageoption_; + /// docstring osfoption_; /// docstring scoption_; ----------------------------------------------------------------------- Summary of changes: lib/latexfonts | 8 ++++++-- src/LaTeXFonts.cpp | 21 +++++++++++++++++---- src/LaTeXFonts.h | 7 ++++++- 3 files changed, 29 insertions(+), 7 deletions(-) hooks/post-receive -- The LyX Source Repository