fontspec icon indicating copy to clipboard operation
fontspec copied to clipboard

LuaLaTeX: Trying to set the Renderer to OpenType with `\defaultfontfeatures` gives inconsistent results

Open callegar opened this issue 2 years ago • 0 comments

Description

I am trying to use \defaultfontfeatures{Renderer=OpenType} before configuring any font to set OpenType as the renderer for all fonts in place of node, that is the LuaLaTeX default.

The motivation is that LuaLaTeX appears to be way faster (twice as fast on small documents) when using HarfBuzz in place of the lua coded renderer. Currently my experiments are targeted at identifying problems and benchmarking. In perspective it would be nice to use \defaultfontfeatures to default to HarfBuzz and ask for the node renderer only in a few fonts where HarfBuzz mode can cause issues.

The problem is that by adding the Renderer=OpenType option to the individual fonts the compilation time is effectively slashed, while using \defaultfontfeatures{Renderer=OpenType} before loading the fonts actually makes the compilation slowlier as if node was still used (or maybe used in addition to HarfBuzz).

The fact that the fonts do not really switch to an HarfBuzz-only management is further confirmed by the fact that OpenType Math fonts have issues with HarfBuzz and cause LuaLaTeX to error out on many documents with them. However, using \defaultfontfeatures{Renderer=OpenType} which should cause all fonts to use OpenType does not trigger the error with the Math fonts.

Check/indicate

  • [ ] Relevant for XeTeX
  • [X] Relevant for LuaTeX
  • [X] Issue tracker has been searched for similar issues?
  • [ ] Links to <tex.stackexchange.com> discussion if appropriate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Renderer=OpenType}
\usepackage{unicode-math}
\setmainfont{Source Serif 4}
\setsansfont{Source Sans 3}[Scale=MatchLowercase]
\setmonofont{Source Code Pro}[Scale=MatchLowercase]
\setmathfont{XITS Math}[Scale=MatchLowercase]
\setmathfont[range=\mathup/{num,latin,Latin,greek,Greek}]{%
  Source Serif 4} 
\setmathfont[range=\mathbfup/{num,latin,Latin,greek,Greek}]{%
  Source Serif 4 Bold} 
\setmathfont[range=\mathit/{latin,Latin,greek,Greek}]{%
  Source Serif 4 Italic} 
\setmathfont[range=\mathbfit/{latin,Latin,greek,Greek}]{%
  Source Serif 4 Bold Italic}
\newfontface{\fontIstituzione}{Cinzel[wght].ttf}[%
  Scale=1.076, FakeStretch=1.038, RawFeature={+axis={wght=428}}]
\newfontfamily{\sansfontlarge}{Source Sans 3}[%
  Scale=MatchUppercase]

\begin{document}
hello \emph{hello}
\end{document}

callegar avatar Oct 31 '23 18:10 callegar