On 11/07/2022 03:23, Juan Manuel Macías wrote:
3. A variable (something like 'org-latex-fontspec-default-configuration') would return something like this: (format \\usepackage{iftex} \\ifpdftex
I like the idea of unified preamble suitable for pdflatex and lualatex. For pdftex \usepackage[...]{fontenc} line may be added here.
\\relax \\else
Is it the case of latex as the old engine with tex->dvi->ps workflow besides new XeTeX and LuaTeX? However such engine is not used by Org.
\\usepackage{fontspec} \\usepackage{unicode-math} \\defaultfontfeatures{Scale=MatchLowercase} \\defaultfontfeatures[\\rmfamily]{Ligatures=TeX} \\setmainfont{%s} \\setsansfont{%s} \\setmonofont{%s} \\fi org-latex-fontspec-mainfont org-latex-fontspec-sansfont org-latex-fontspec-monofont)
Too many variables to my taste. It can be single property list. If I remember correctly, changing of mainfont requires setting of a consistent font for mathematics, so more options may be required.
ox-latex has some code searching for e.g. \usepackage[...]{inputenc} in the current configuration to avoid adding of extra copy. It would be great to have something similar for fontspec commands. I guess, it is harder to detect, since per-language font configuration may be required as babel options.
Finally, default value may be language-dependent or alternative font set may be activated when non-latin characters are detected in the document.