Just a small progress report:

I'm able to generate the following font prelude

\directlua{
 luaotfload.add_fallback ("fallback_sans",{
  "Noto Color Emoji:mode=harf",
  "Noto Sans CJK JP:",
 })
 luaotfload.add_fallback ("fallback_main",{
  "Noto Color Emoji:mode=harf",
  "Noto Serif CJK JP:",
 })
}
\setmainfont{CMU Serif}[RawFeature={fallback=fallback_main}]
\setsansfont{Noto Sans}[RawFeature={fallback=fallback_sans}]
\setmathfont{Stix Two Math}
\setmonofont{Noto Sans Mono}

from a document with han and emojis. When either are missing, the fallback
is not included and when both are missing, the whole directlua section is
omitted, together with the RawFeature(s).

The variable I'm using to set the fonts looks like:

(defvar lualatex-font-config
  '(("main". (font "CMU Serif"
                   fallback (("emoji" . "Noto Color Emoji:mode=harf")
                             ("han"   . "Noto Serif CJK JP:")
                             ("kana"  . "Noto Serif CJK JP:"))))
    ("sans" . (font "Noto Sans"
                    fallback (("emoji" . "Noto Color Emoji:mode=harf")
                              ("han"   . "Noto Sans CJK JP:")
                              ("kana"  . "Noto Sans CJK JP:"))))
    ("math" . (font "Stix Two Math"))
    ("mono" . (font "Noto Sans Mono")))
  "This variable holds the font dictionaries for PDF export.
Place your customization in your Emacs initialisation or in .dir-locals.el")

Which in real code would be a defcustom...
There will be a default value (currently doubting between CMU and Noto) and
if your document needs other fallbacks, fonts, etc. you can add them in
your emacs init code or in a
dir-local variable.

 Let's hope that I get (eventually) write access to the git and can create
a feature branch to push experiments and have people play with this, once I
integrate it in org-mode.

Best, /PA

On Tue, 22 Apr 2025 at 21:21, Pedro Andres Aranda Gutierrez <
paag...@gmail.com> wrote:

> Answers inlne
>
> On Tue, 22 Apr 2025 at 18:55, Max Nikulin <maniku...@gmail.com> wrote:
>
>> On 21/04/2025 18:07, Pedro Andres Aranda Gutierrez wrote:
>> > I could try to go for something like:
>> >
>> > (defvar org-latex-font-fallback-alist
>> >    '(("main . '(("emoji" . "Noto Color Emoji:mode-harf")
>> >                 ("han"   . "Noto CJK JP:")
>> >                 ("kana"  . "Noto CJK JP:")))
>> >      ("sans". '(("emoji" . "Noto Color Emoji:mode-harf")
>> >                 ("han"   . "Noto Sans CJK JP:")
>> >                 ("kana"  . "Noto Sans CJK JP:")))
>> >      etc...
>>
>>  From my point of view, complex elisp data structures have advantage
>> over a block of raw LaTeX code only if
>> - elisp code can drop fonts for scripts not used in the current document,
>>
> For that, I have already tested and adapted the code provided a  couple of
> years go by Juan Manuel MacĂ­as.
>
>> - elisp or lua code may skip fonts that are not installed,
>
> - there is defcustom user option and #+options: keyword to switch whole
>> group of fonts (main+sans+mono+math+small caps) at once from e.g. Noto
>> to CMU (Computer Modern Unicode) or to set priorities, e.g. freefont, or
>> noto, or dejavu if some font is missed in higher priority groups.
>>
>
> I'm being a bit more conservative in that I want something that satisfies
> 99% of the use cases and once that is done, check what is missing and
> adding to it. So Something as configurable as pandoc could be a starting
> point.
>
> Preferably code should be able to obtain list of scripts supported by a
>> given font.
>>
>
>
>
>> If list of fonts and fallbacks is not modified during export then I
>> expect that for users it will be easier to adjust raw LaTeX code then to
>> deal with custom DSL.
>>
>
> Is that what happens for pandoc?
>
>
>> >      > (defvar org-latex-font-mapping-alist
>> >      >   '(("main" . "Noto Serif")
>> >      >     ("sans" . "Noto Sans")
>> >      >     ("mono" . "Noto Sans Mono"))
>> ... and math
>
> and roman... so make it as configurable as possible
>
>>  >      >   "Noto Color Emoji:mode-harf",
>
>
>>  From some message of Juan Manuel I expected that it is possible to set
>> harfbuzz mode by default without repeating it for each font. Are there
>> disadvantages or compatibility issues?
>>
> Let the gurus speak.
>
> Once again, let's try to get at the level of pandoc and debate from there.
>
> Best, /PA
> --
> Fragen sind nicht da, um beantwortet zu werden,
> Fragen sind da um gestellt zu werden
> Georg Kreisler
>
> Sagen's Paradeiser, write BE!
> Year 1 of the New Koprocracy
>
>

-- 
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Sagen's Paradeiser, write BE!
Year 1 of the New Koprocracy

Reply via email to