0

I have successfully setup a precompiled preamble as described in this Tex-Stackexchange post.

However, one problem remains: If I move fontspec to the preamble the ligatures stop to work.

Currently my tex file for the precompiled-preamble looks like this:

%lualatex.exe -interaction=nonstopmode -ini -jobname="preambleprecompiled" "&lualatex" mylatexformat.ltx "preambleprecompiled.tex"
\documentclass{article}

\usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \setmainfont[Ligatures=TeX]{Minion Pro}

\csname endofdump\endcsname

and my main file like this:

%&preambleprecompiled
\endofdump
\begin{document}
    Test Text   \newline
    --          \newline    
    ---         \newline
    `           \newline    
    ´           \newline
    `'          \newline
    ´'          \newline
    '           \newline
    \textemdash \newline
    \textendash \newline    
\end{document}

The dashes do not get converted in this setup - they just remain, like shown in this screenshot:

The dashes do not get converted in this setup

Once I move the fontspec part to the main file it works, however, that defeats the purpose.

Just to be complete - that is what it looks like then:

%&preambleprecompiled
\endofdump
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont[Ligatures=TeX]{Minion Pro}
\begin{document}
    Test Text   \newline
    --          \newline    
    ---         \newline
    `           \newline    
    ´           \newline
    `'          \newline
    ´'          \newline
    '           \newline
    \textemdash \newline
    \textendash \newline    
\end{document}

fontspec is now no longer part of the precompiled preamble

How could I fix this?

Bernard
  • 271,350
nhck
  • 740
  • 2
    You can not dump opentype fonts or any Lua state into the format. It is just the way it is. – David Carlisle Nov 03 '20 at 10:12
  • Okay - thanks - found your earlier comment about it now.

    One question out of curiosity: Why do the fonts still work? It loads the proper font for the pdf, hence, my surprise about the ligatures.

    – nhck Nov 03 '20 at 10:21
  • 1
    I was wondering about that myself, no time to debug now, Really you need Marcel to pass by and explain the timing of exactly when luaotfload does whatever it does:-) Note that in theory you can byte compile Lua to a text blob and save that in a macro in the format to re-evaluate as Lua in \everyjob but to restructure Luaotfload in a way that makes that usefully possible is not easy without intimate details of luaotfload which I don't have. – David Carlisle Nov 03 '20 at 10:25
  • 3
    @nhck Basically LuaLaTeX's font handling is split into multiple parts. luaotfload loads a font into the structure of a traditional TeX font and additionally some tables (and/or references in tables) representing all the font features, shaping modes etc. When a format is dumped, all the Lua state is dropped but the TeX font remains (because from LuaTeX's PoV it's no different than any traditional font) but after loading the format, luaotfload can no longer access it data and it forgot that it was responsible for the font anyway. So the font is handled as a traditional TeX font. – Marcel Krüger Nov 03 '20 at 11:23
  • 3
    Normally traditional TeX fonts could still have simple ligatures and kerning, but because luaotfload was responsible for the original font and therefore TeX trying to apply such stuff would only interfere and duplicate effects, these TeX font ligatures/kerning tables were never set up and therefore were never dumped and finally never loaded. This leaves you in the position where you only have this minimal font remnant. – Marcel Krüger Nov 03 '20 at 11:27
  • Thanks @MarcelKrüger (sorry to single you out:-) – David Carlisle Nov 03 '20 at 12:26

0 Answers0