From 003d675c2f3bb66f147b99def57296545d4c170e Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 13 Jul 2019 08:42:42 +0200 Subject: [PATCH] Use \babelfonts only if babel >= 3.15 is available. --- lib/chkconfig.ltx | 28 ++++++++++++++++++++++++++++ lib/doc/LaTeXConfig.lyx | 27 ++++++++++++++++++++++++++- src/BufferParams.cpp | 22 ++++++++++++---------- 3 files changed, 66 insertions(+), 11 deletions(-) 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{}{} +% 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/lib/doc/LaTeXConfig.lyx b/lib/doc/LaTeXConfig.lyx index 8ad9a5b318..3f7fcf8737 100644 --- a/lib/doc/LaTeXConfig.lyx +++ b/lib/doc/LaTeXConfig.lyx @@ -1,5 +1,5 @@ #LyX 2.4 created this file. For more info see https://www.lyx.org/ -\lyxformat 578 +\lyxformat 580 \begin_document \begin_header \save_transient_properties true @@ -4940,6 +4940,31 @@ Table of contents \end_layout \begin_deeper +\begin_layout Standard + +\change_inserted -712698321 1563000039 +As of version 3.15 (2017/11/03), +\family sans +babel +\family default + also provides specific commands to select OpenType, TrueType and PostScript + fonts from the Operating System (with XeTeX or LuaTeX). + If this version (or a newer one) is installed (on your system: +\begin_inset Info +type "package" +arg "babel-2017/11/03" +\end_inset + +), \SpecialChar LyX + will use this rather than +\family sans +fontspec +\family default +'s commands. +\change_unchanged + +\end_layout + \begin_layout Standard Your \SpecialChar LaTeX installation has hyphenation patterns for the following languages: 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"; -- 2.39.2