2

I have a multi-language document and use babel to switch between Standard Average European scripts and other scripts:

\documentclass[english]{minimal}

\usepackage{fontspec}

\usepackage{babel}

\parindent0pt

\babelfont{rm}{Alegreya-Regular.ttf}
\babelfont{sf}{BarlowCondensed-Regular.ttf}
\newfontfamily\sfwide[WordSpace=2.0]{BarlowCondensed-Regular.ttf}

\babelprovide{chinese}
\babelfont[chinese]{rm}{NotoSerifSC-Regular.otf}
\babelfont[chinese]{sf}{NotoSansSC-Regular.otf}


\begin{document}
\rmfamily
Test Test \foreignlanguage{chinese}{中文字} Test Test

\sffamily
Test Test \foreignlanguage{chinese}{中文字} Test Test

\sfwide
Test Test \foreignlanguage{chinese}{中文字} Test Test
\end{document}

The last Chinese snipped is not printed since there is no \sfwide verison provided for this language. Assume that I have a lot of different script systems (arabic, hebrew, armenian, old greek, ...) and a lot of font families, so I need a generic way to create babelfont fallbacks, ideally something like

\babelalias{sfwide}{sf} 

which causes babel to switch to chinese/sf when ever \foreignlanguage{chinese}{...} occurs in an sfwide font family context.

Question How would I need to define \babelalias#1#2?

Alternatively: Is there a way to tell fontspec that \sfwide is a "child" of \sffamily?

Remarks

The fonts used in the example can be downloaded from google: Alegreya, Barlow, Noto Simplified Chinese

Since it makes a difference: I use an early build of texlive2019 (latex.ltx fmtversion 2018-12-01) and, no, I cannot update. If this is possible in a newer verison of LuaLaTeX or babel, i'm going to need a patch.

1 Answer 1

4

I’m not sure I’ve understood the question, but \babelfont has the ability to create font families, in order to extend the LaTeX font scheme to the needs of non-Latin scripts. Here I’ve used different colors, but you can define the fonts as is most convenient for you.

\documentclass[english]{minimal}

\usepackage{fontspec}

\usepackage{babel}

\parindent0pt

\babelfont{rm}{FreeSerif}
\babelfont{sf}{FreeSans}
\babelfont{sfwide}{CMU Bright Bold Extended}

\babelprovide{chinese}
\babelfont[chinese]{rm}[Color=2255cc]{IPAMincho}
\babelfont[chinese]{sf}[Color=55cc22]{IPAMincho}
\babelfont[chinese]{sfwide}[Color=cc5522]{IPAMincho}

\begin{document}
\rmfamily
Test Test \foreignlanguage{chinese}{中文字} Test Test

\sffamily
Test Test \foreignlanguage{chinese}{中文字} Test Test

\sfwidefamily
Test Test \foreignlanguage{chinese}{中文字} Test Test
\end{document}

enter image description here

2
  • Thanks for the answer, but my question was if there is a way to avoid declaring a chinese font for each text font family? I want that babel uses the \sffamily-Version of Chinese when the surrounding context is \sfwidefamily. The background is that i have the fallback fonts for foreign scripts in a common framework that is used in different publisher packages. And those packages use very different fonts and font families. If i do it your way, i would need to re-declare all foreign scripts for every new font family for every new publisher style. And i'd like to avoid that, if possible.
    – Lupino
    Commented Oct 1, 2021 at 9:07
  • Note: I did find a sorta-workaround, i'll post it as an answer when and if i find the time.
    – Lupino
    Commented Oct 6, 2021 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .