Re: Fallback fonts in LuaTeX via 'luaotfload.add_fallback' (was "Fontsets")

2022-07-15 Thread Max Nikulin

On 12/07/2022 22:26, Juan Manuel Macías wrote:

Today I discovered that luaotfload included in v. 3.12 a new
experimental function, luaotfload.add_fallback, to be able to add a list
of fallback fonts to a LuaTeX document, at a low level.

...

   \documentclass{article}
   \usepackage{fontspec}
   \directlua{
   luaotfload.add_fallback ("fallbacktest",{
   "oldstandard:mode=harf;script=grek;color=FF;",
   "oldstandard:mode=harf;script=cyrl;color=FF;",
   "freeserif:mode=harf;script=arab;color=FF;",
   "freeserif:mode=harf;script=dev2;color=FF;",
   })}
   \setmainfont{latinmodernroman}[RawFeature={fallback=fallbacktest}]

...

The main drawback I've found to this (at least I don't know how to solve
it at the moment) is that the fallback feature cannot be added via
\defaultfontfeatures. That would avoid having to (re)define all the
main/sans/mono/math families.


I agree that defining fallbacks for each font family is inconvenient. 
Defining font per script resembles specifying fonts per language in 
babel configuration, however fallback should work without explicit 
switching of language. I have seen that babel may determine language 
from character code points, but I have not tried if it works reliable 
and if it affects performance (as it does for fallback fonts).


Maybe I did not read the manual with enough attention, maybe I tried it 
with too old version of LuaTeX, but I had a problem with Emoji. 
Depending on font such symbols either broke compilation or did not 
appear in PDF (accordingly to pdffonts font was embedded, text may be 
copied, but PDF viewers displayed blank space).


https://list.orgmode.org/orgmode/scuirf$m7o$1...@ciao.gmane.io/
Maxim Nikulin. Re: org-mode export to (latex) PDF. Sat, 17 Jul 2021 
19:35:57 +0700





Fallback fonts in LuaTeX via 'luaotfload.add_fallback' (was "Fontsets")

2022-07-12 Thread Juan Manuel Macías
Today I discovered that luaotfload included in v. 3.12 a new
experimental function, luaotfload.add_fallback, to be able to add a list
of fallback fonts to a LuaTeX document, at a low level.

(More info on page 18 of the luaotfload manual, with some examples).

I've been experimenting a bit with this function. For example:

#+begin_src latex
  \documentclass{article}
  \usepackage{fontspec}
  \directlua{
  luaotfload.add_fallback ("fallbacktest",
  {
  "oldstandard:mode=harf;script=grek;color=FF;",
  "oldstandard:mode=harf;script=cyrl;color=FF;",
  "freeserif:mode=harf;script=arab;color=FF;",
  "freeserif:mode=harf;script=dev2;color=FF;",
  }
  )
  }

  \setmainfont{latinmodernroman}[RawFeature={fallback=fallbacktest}]

  \begin{document}

  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
  hendrerit tempor tellus. Donec pretium posuere tellus.

  Δαρείου καὶ Παρυσάτιδος γίγνονται παῖδες δύο, πρεσβύτερος μὲν
  Ἀρταξέρξης, νεώτερος δὲ Κῦρος· ἐπεὶ δὲ ἠσθένει Δαρεῖος καὶ ὑπώπτευε
  τελευτὴν τοῦ βίου, ἐβούλετο τὼ παῖδε ἀμφοτέρω παρεῖναι. ὁ μὲν οὖν
  πρεσβύτερος παρὼν ἐτύγχανε· Κῦρον δὲ μεταπέμπεται ἀπὸ τῆς ἀρχῆς ἧς
  αὐτὸν σατράπην ἐποίησε, καὶ στρατηγὸν δὲ αὐτὸν ἀπέδειξε πάντων ὅσοι ἐς
  Καστωλοῦ πεδίον ἁθροίζονται.

  Emacs написан на двух языках: C и Emacs Lisp (Elisp, диалект Лиспа).
  При этом сам редактор является интерпретатором Elisp. По сути дела,
  большая часть Emacs написана на языке Elisp, и её можно рассматривать
  как расширение к основной программе. Пользователи могут сами создавать
  части Emacs, от отдельных функций до новых основных режимов. При этом
  можно переопределять любые Elisp-функции, в том числе и те, что
  являются частью самого редактора, и модифицировать функциональность
  Emacs, изменив соответствующим образом некоторые функции.

  Native speakers of Arabic generally do not distinguish between Modern
  Standard Arabic and Classical Arabic as separate languages; they refer
  to both as al-ʻArabīyah al-Fuṣḥá (العربية الفصحى) meaning the pure
  Arabic. They consider the two forms to be two registers of one
  language. When the distinction is made, they are referred to as فصحى
  العصر Fuṣḥá al-ʻAṣr (MSA) and فصحى التراث Fuṣḥá al-Turāth (CA)
  respectively.

  उदु ज्योतिरमृतं विश्वजन्यं विश्वानरः सविता देवो अश्रेत् ।\\
  क्रत्वा देवानामजनिष्ट चक्षुराविरकर्भुवनं विश्वमुषाः ॥ १ ॥\\
  प्र मे पन्था देवयाना अदृश्रन्नमर्धन्तो वसुभिरिष्कृतासः ।\\
  अभूदु केतुरुषसः पुरस्तात्प्रतीच्यागादधि हर्म्येभ्यः ॥ २ ॥

  \end{document}
#+end_src

The main drawback I've found to this (at least I don't know how to solve
it at the moment) is that the fallback feature cannot be added via
\defaultfontfeatures. That would avoid having to (re)define all the
main/sans/mono/math families.

Best regards,

Juan Manuel