Am Freitag, den 12.07.2019, 08:59 +0000 schrieb Guenter Milde:
> > If you insist, though, I can add some test and do babelfonts only
> > for
> > these recent versions.
> 
> This would be the right thing as long as Debian/stable ships babel
> 3.9r.

Can you please test the attached patch to this end?

Jürgen
diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx
index 970b26baaa..fb04719377 100644
--- a/lib/chkconfig.ltx
+++ b/lib/chkconfig.ltx
@@ -120,6 +120,29 @@
     #6
   \fi}
 
+% Tests whether an package is present in a specific version (or newer)
+% Syntax: \TestPackageVersion{<name>}{<yyyy/mm/dd>}
+% Note: This requires the package to be loaded first
+
+\newcommand{\TestPackageVersion}[2]{
+  \message{^^J\prefix checking for package #1 at least as of #2...}
+  \IfFileExists{#1.sty}
+  {
+    \@ifpackagelater{#1}{#2}{\existstrue}{\existsfalse}
+  }
+  {
+    \existsfalse
+  }
+  \ifexists
+    \message{yes^^J}
+    \AddVariable{#1}{yes}
+    \AddPackage{#1-#2}
+  \else
+    \message{no^^J}
+    \AddVariable{#1}{no}
+  \fi}
+
+
 % Adapted from ltxcheck.tex
 \newcommand{\TestFont}[2][\default]{
   \def\default{#2}
@@ -527,6 +550,11 @@
 %\TestPackage{mathabx}
 %\TestPackage{mathdesign}% But see above!
 
+%%% Specific package versions
+% This only works if the package has been loaded before
+\IfFileExists{babel.sty}{\RequirePackage{babel}}{}
+\TestPackageVersion{babel}{2017/11/03}
+
 %%% Document classes
 % The list of layout files has been put in this file here by the
 % configure script.
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index dd6e91e1f8..e65e6e4a12 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -1762,8 +1762,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 		os << from_ascii(ams);
 
 	if (useNonTeXFonts) {
-		// Babel loads fontspec itself
-		if (!features.isProvided("fontspec") && !features.useBabel())
+		// Babel (as of 2017/11/03) loads fontspec itself
+		if (!features.isProvided("fontspec")
+		    && !(features.useBabel() && features.isAvailable("babel-2017/11/03")))
 			os << "\\usepackage{fontspec}\n";
 		if (features.mustProvide("unicode-math")
 		    && features.isAvailable("unicode-math"))
@@ -3390,14 +3391,15 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
 		// variants are understood by both engines. However,
 		// we want to provide support for at least TeXLive 2009
 		// (for XeTeX; LuaTeX is only supported as of v.2)
-		// Babel has its own higher-level interface on top of
-		// fontspec that is to be used.
-		bool const babel = features.useBabel();
+		// As of 2017/11/03, Babel has its own higher-level
+		// interface on top of fontspec that is to be used.
+		bool const babelfonts = features.useBabel()
+				&& features.isAvailable("babel-2017/11/03");
 		string const texmapping =
 			(features.runparams().flavor == OutputParams::XETEX) ?
 			"Mapping=tex-text" : "Ligatures=TeX";
 		if (fontsRoman() != "default") {
-			if (babel)
+			if (babelfonts)
 				os << "\\babelfont{rm}[";
 			else
 				os << "\\setmainfont[";
@@ -3411,7 +3413,7 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
 		if (fontsSans() != "default") {
 			string const sans = parseFontName(fontsSans());
 			if (fontsSansScale() != 100) {
-				if (babel)
+				if (babelfonts)
 					os << "\\babelfont{sf}";
 				else
 					os << "\\setsansfont";
@@ -3422,7 +3424,7 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
 				os << texmapping << "]{"
 				   << sans << "}\n";
 			} else {
-				if (babel)
+				if (babelfonts)
 					os << "\\babelfont{sf}[";
 				else
 					os << "\\setsansfont[";
@@ -3435,7 +3437,7 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
 		if (fontsTypewriter() != "default") {
 			string const mono = parseFontName(fontsTypewriter());
 			if (fontsTypewriterScale() != 100) {
-				if (babel)
+				if (babelfonts)
 					os << "\\babelfont{tt}";
 				else
 					os << "\\setmonofont";
@@ -3446,7 +3448,7 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
 				os << "]{"
 				   << mono << "}\n";
 			} else {
-				if (babel)
+				if (babelfonts)
 					os << "\\babelfont{tt}";
 				else
 					os << "\\setmonofont";

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to