From 96892ea8d7dd024de36c135845e2981c7f957bc6 Mon Sep 17 00:00:00 2001 From: Andrew Dunning Date: Sat, 12 Jan 2019 20:39:47 -0500 Subject: LaTeX template: Simplify fontspec usage (#5218) Simplify the approach of #5212, ensuring that `mainfont` is used as the base font for scaling and that LuaLaTeX does not display the mono font with TeX ligatures (as it does not use the `Mapping=tex-ansi` option). With a modified version of `\defaultfontfeatures`, fontspec will continue to report scaling against the old default font in the log, but it nonetheless displays main font at the specified size. Using this rather than setting `Scale=MatchLowercase` for each family individually means that users will not lose scaling when upgrading to the new template if they were using other font options. Scaling can be disabled for an individual family by adding the option `Scale=1` to `sansfontoptions`, `monofontoptions`, etc. Remove the `\setromanfont` command added in #4665, as this is not documented in the fontspec manual and appears to be a deprecated alias for `\setmainfont`. For the release notes, I should also add that one can imitate the previous appearance with `-V mainfontoptions="Scale=MatchLowercase"`. --- MANUAL.txt | 7 +++---- data/templates/default.latex | 17 ++++++++--------- test/lhs-test.latex | 2 ++ test/lhs-test.latex+lhs | 2 ++ test/writer.latex | 2 ++ test/writers-lang-and-dir.latex | 2 ++ 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/MANUAL.txt b/MANUAL.txt index bfe35edfc..8954957d2 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -1527,13 +1527,12 @@ LaTeX variables are used when [creating a PDF]. `fontfamily` set to [`mathpazo`] provides Palatino with old-style figures and true small caps; may be repeated for multiple options -`mainfont`, `romanfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont` +`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont` : font families for use with `xelatex` or `lualatex`: take the name of any system font, using the - [`fontspec`] package. Note that if `CJKmainfont` is used, - the [`xecjk`] package must be available. + [`fontspec`] package. `CJKmainfont` uses the [`xecjk`] package. -`mainfontoptions`, `romanfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions` +`mainfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions` : options to use with `mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont` in `xelatex` and `lualatex`. Allow for any choices available through [`fontspec`], such as the OpenType features diff --git a/data/templates/default.latex b/data/templates/default.latex index 1691f3a21..b9dbbb774 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -110,30 +110,29 @@ $if(mathspec)$ $else$ \usepackage{unicode-math} $endif$ + \defaultfontfeatures{Scale=MatchLowercase} + \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} $if(mainfont)$ \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$} $endif$ -$if(romanfont)$ - \setromanfont[$if(romanfontoptions)$$for(romanfontoptions)$$romanfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$romanfont$} -$endif$ $if(sansfont)$ - \setsansfont[$if(sansfontoptions)$$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$sansfont$} + \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$} $endif$ $if(monofont)$ - \setmonofont[$if(monofontoptions)$$for(monofontoptions)$$monofontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$monofont$} + \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$} $endif$ $for(fontfamilies)$ - \newfontfamily{$fontfamilies.name$}[$if(fontfamilies.options)$$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$fontfamilies.font$} + \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$} $endfor$ $if(mathfont)$ $if(mathspec)$ \ifxetex - \setmathfont(Digits,Latin,Greek)[$if(mathfontoptions)$$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$mathfont$} + \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} \else - \setmathfont[$if(mathfontoptions)$$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$mathfont$} + \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} \fi $else$ - \setmathfont[$if(mathfontoptions)$$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$mathfont$} + \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} $endif$ $endif$ $if(CJKmainfont)$ diff --git a/test/lhs-test.latex b/test/lhs-test.latex index 5d8442f2a..f18af737c 100644 --- a/test/lhs-test.latex +++ b/test/lhs-test.latex @@ -12,6 +12,8 @@ \usepackage{textcomp} % provides euro and other symbols \else % if luatex or xelatex \usepackage{unicode-math} + \defaultfontfeatures{Scale=MatchLowercase} + \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} \fi % use upquote if available, for straight quotes in verbatim environments \IfFileExists{upquote.sty}{\usepackage{upquote}}{} diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs index 9c8797d5e..dc6f2803b 100644 --- a/test/lhs-test.latex+lhs +++ b/test/lhs-test.latex+lhs @@ -12,6 +12,8 @@ \usepackage{textcomp} % provides euro and other symbols \else % if luatex or xelatex \usepackage{unicode-math} + \defaultfontfeatures{Scale=MatchLowercase} + \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} \fi % use upquote if available, for straight quotes in verbatim environments \IfFileExists{upquote.sty}{\usepackage{upquote}}{} diff --git a/test/writer.latex b/test/writer.latex index 155dcd407..d801e1590 100644 --- a/test/writer.latex +++ b/test/writer.latex @@ -12,6 +12,8 @@ \usepackage{textcomp} % provides euro and other symbols \else % if luatex or xelatex \usepackage{unicode-math} + \defaultfontfeatures{Scale=MatchLowercase} + \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} \fi % use upquote if available, for straight quotes in verbatim environments \IfFileExists{upquote.sty}{\usepackage{upquote}}{} diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex index f18e9a7d6..bb3575771 100644 --- a/test/writers-lang-and-dir.latex +++ b/test/writers-lang-and-dir.latex @@ -13,6 +13,8 @@ \usepackage{textcomp} % provides euro and other symbols \else % if luatex or xelatex \usepackage{unicode-math} + \defaultfontfeatures{Scale=MatchLowercase} + \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} \fi % use upquote if available, for straight quotes in verbatim environments \IfFileExists{upquote.sty}{\usepackage{upquote}}{} -- cgit v1.2.3