Considering some discussions in the parent thread, I think maybe it
wouldn't hurt to ensure a minimal preamble when the output is compiled
with LuaLaTeX or XelaTeX, so that some very basic fontspec configuration
is loaded to be able to read PDFs in non-Latin scripts.
But before proposing the patch directly, I'd like to discuss its
structure. I think (IMHO) that a certain balance should be ensured
between a) users who don't want to mess with fontspec and want something
more out-of-the-box and b) users who prefer to be in control when
compiling with LuaTeX and XeTeX.
I think maybe it would be nice to let LaTeX do the work, via a
conditional from the iftex package (idea taken from pandoc).
The structure of the patch could be this:
1. There could be a defcustom, something like 'org-latex-use-fontspec'
(I would vote for nil by default).
2. There would be three variables for the default fonts: roman, sans and
mono. By default, the FreeSerif, FreeSans and FreeMono fonts could be
set as default value, since they are very ubiquitous and have a very
good coverage for non-Latin scripts.
3. A variable (something like 'org-latex-fontspec-default-configuration') would
return something like this:
(format
\\usepackage{iftex}
\\ifpdftex
\\relax
\\else
\\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)
(and this string would be added at some point to org-latex-make-preamble)
4. Conclusion: I think the good thing about letting LaTeX do the
conditional work with iftex is that it saves us less invasive code on
our end. I also think that other more complex approaches, such as
searching for the fonts present in the system and adding them according
to the document scripts, would lead us to a completely slippery slope.
Of course, a list of recommended free-licensed fonts could be included
in the documentation.
WDYT?
Best regards,
Juan Manuel