git.iko.soy/typeable/pandoc
on master help sign in
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"`.

commit96892ea8d7dd024de36c135845e2981c7f957bc6 authorAndrew Dunning <adunning@users.noreply.github.com> dateSat 12 Jan 2019, 20:39 (8 years ago) parentfd222b8
6 files changed+19−13
MANUAL.txt+3−4 data/templates/default.latex+8−9 test/lhs-test.latex+2 test/lhs-test.latex+lhs+2 test/writer.latex+2 test/writers-lang-and-dir.latex+2
MANUAL.txt+3−4
@@ -1527,13 +1527,12 @@ LaTeX variables are used when [creating a PDF].
15271527 `fontfamily` set to [`mathpazo`] provides Palatino with old-style
15281528 figures and true small caps; may be repeated for multiple options
15291529
1530−`mainfont`, `romanfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`
1530+`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`
15311531: font families for use with `xelatex` or
15321532 `lualatex`: take the name of any system font, using the
1533− [`fontspec`] package. Note that if `CJKmainfont` is used,
1534− the [`xecjk`] package must be available.
1533+ [`fontspec`] package. `CJKmainfont` uses the [`xecjk`] package.
15351534
1536−`mainfontoptions`, `romanfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions`
1535+`mainfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions`
15371536: options to use with `mainfont`, `sansfont`, `monofont`, `mathfont`,
15381537 `CJKmainfont` in `xelatex` and `lualatex`. Allow for any choices
15391538 available through [`fontspec`], such as the OpenType features
data/templates/default.latex+8−9
@@ -110,30 +110,29 @@ $if(mathspec)$
110110$else$
111111 \usepackage{unicode-math}
112112$endif$
113+ \defaultfontfeatures{Scale=MatchLowercase}
114+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
113115$if(mainfont)$
114116 \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}
115117$endif$
116−$if(romanfont)$
117− \setromanfont[$if(romanfontoptions)$$for(romanfontoptions)$$romanfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$romanfont$}
118−$endif$
119118$if(sansfont)$
120− \setsansfont[$if(sansfontoptions)$$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$sansfont$}
119+ \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
121120$endif$
122121$if(monofont)$
123− \setmonofont[$if(monofontoptions)$$for(monofontoptions)$$monofontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$monofont$}
122+ \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$}
124123$endif$
125124$for(fontfamilies)$
126− \newfontfamily{$fontfamilies.name$}[$if(fontfamilies.options)$$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$fontfamilies.font$}
125+ \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$}
127126$endfor$
128127$if(mathfont)$
129128$if(mathspec)$
130129 \ifxetex
131− \setmathfont(Digits,Latin,Greek)[$if(mathfontoptions)$$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$mathfont$}
130+ \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
132131 \else
133− \setmathfont[$if(mathfontoptions)$$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$mathfont$}
132+ \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
134133 \fi
135134$else$
136− \setmathfont[$if(mathfontoptions)$$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$$else$Scale=MatchLowercase$endif$]{$mathfont$}
135+ \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
137136$endif$
138137$endif$
139138$if(CJKmainfont)$
test/lhs-test.latex+2
@@ -12,6 +12,8 @@
1212 \usepackage{textcomp} % provides euro and other symbols
1313\else % if luatex or xelatex
1414 \usepackage{unicode-math}
15+ \defaultfontfeatures{Scale=MatchLowercase}
16+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
1517\fi
1618% use upquote if available, for straight quotes in verbatim environments
1719\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
test/lhs-test.latex+lhs+2
@@ -12,6 +12,8 @@
1212 \usepackage{textcomp} % provides euro and other symbols
1313\else % if luatex or xelatex
1414 \usepackage{unicode-math}
15+ \defaultfontfeatures{Scale=MatchLowercase}
16+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
1517\fi
1618% use upquote if available, for straight quotes in verbatim environments
1719\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
test/writer.latex+2
@@ -12,6 +12,8 @@
1212 \usepackage{textcomp} % provides euro and other symbols
1313\else % if luatex or xelatex
1414 \usepackage{unicode-math}
15+ \defaultfontfeatures{Scale=MatchLowercase}
16+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
1517\fi
1618% use upquote if available, for straight quotes in verbatim environments
1719\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
test/writers-lang-and-dir.latex+2
@@ -13,6 +13,8 @@
1313 \usepackage{textcomp} % provides euro and other symbols
1414\else % if luatex or xelatex
1515 \usepackage{unicode-math}
16+ \defaultfontfeatures{Scale=MatchLowercase}
17+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
1618\fi
1719% use upquote if available, for straight quotes in verbatim environments
1820\IfFileExists{upquote.sty}{\usepackage{upquote}}{}