"Pedro A. Aranda" <paag...@gmail.com> writes:

> 0001 is a trivial way to clarify the warning about unsupported fonts 
> with a more 'blunt' language. This is what I said could go as a bug fix.

Installed.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=066952da0b
I removed the news entry as this change is not worth global announcement.

> +  (if (or (string= org-latex-compiler "pdflatex")
> +          (not org-latex-add-default-fonts))
> +      ""
> +    (mapconcat #'(lambda (fspec)
> +                   (format "\n\\set%sfont{%s}" (car fspec) (cdr fspec)))
> +               org-latex-default-fonts-alist)))

I am looking and this and wondering if we can do better as long as we
are limiting outselves to lualatex/xelatex.

I just played around with LLM suggestions, and it looks like we can
actually define fallback fonts instead of overriding the default font:

\documentclass{article}
\usepackage{fontspec,unicode-math}

% ===== CORE FALLBACK CONFIGURATION =====
\defaultfontfeatures{
    RawFeature = {fallback=yes}, % Enable automatic glyph substitution
    Ligatures = Common,          % Standard typographic features
    Scale = MatchLowercase       % Maintain consistent sizing
}

% ===== UNIVERSAL FALLBACK STACK =====
% (Only activates when default font lacks glyphs)
\directlua{
luaotfload.add_fallback("global_fallback", {
    "Noto Serif:mode=harf;",       % 1st: Broad Unicode coverage
    "DejaVu Serif:mode=harf;",     % 2nd: Common Linux/Windows font
    "FreeSerif:mode=harf;",        % 3rd: Common TeX Live font
    "Arial Unicode MS:mode=harf;", % 4th: Windows fallback
    "Code2000:mode=harf;"          % 5th: Historic Unicode font
})
}

% ===== SCRIPT-SPECIFIC FALLBACKS =====
% (Only activate for specific scripts)
\newfontfamily\cjkfallback{Noto Sans CJK SC}[Script=Han]
\newfontfamily\arabicfallback{Amiri}[Script=Arabic]
\newfontfamily\symbolfallback{Segoe UI Symbol}[
    Scale=MatchLowercase,
    RawFeature={colr=yes} % For emoji support
]

% ===== MATH FALLBACKS =====
\setmathfont{Latin Modern Math}[
    range={"0000-"1D7FF}, % Basic math ranges
    SizeFeatures={
        {Size={-8.4}, Font=Cambria Math},
        {Size={8.4-}, Font=XITS Math}
    }
]

% ===== DOCUMENT =====
\begin{document}

\section{Portable Unicode Test}
Default font: English 123 \\
CJK: {\cjkfallback 汉语 日本語} \\
Arabic: {\arabicfallback السلام عليكم} \\
Math: \( ∀x∈ℝ \) \\
Symbols: {\symbolfallback ☺ ♞ ♛ ∀} \\
Emoji: {\symbolfallback 😂 👍 🚀}

\end{document}


-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to