I use TeXWorks with XeLaTex. I want to load multiple fonts in my document. When a character doesn't exist in the main font, XeTeX should search the other fonts.

Non-working example:

Holá hello 们 們 안녕 𦮙

That should produce something like this mock-up from MS Word:

Must be

Currently I get:

I Get

I can't mark up each part of the text because this needs to be dynamic. So, as in Word, I need LaTeX to recognize which font contains the character.


1 Answer 1


The literal answer to the question you asked is that \iffontchar checks whether a font contains the specified glyph, and can be used to implement a fallback. However, I think that is an XY problem.

You can almost do this with ucharclasses. For this MCVE, I used the Noto Sans font family, except for one rare ideograph that I took from Babelstone Han.

\usepackage[Latin, Arabic, CJK, Greek, Korean,

\defaultfontfeatures{Scale = MatchLowercase, Ligatures = TeX}
\setmainfont{Noto Sans}[Scale = 1.0]
\setsansfont{Noto Sans}

\newfontfamily\koreanfont{Noto Sans CJK KR}[
  Language=Korean, Script=CJK]
\newfontfamily\tradchinesefont{Noto Sans CJK TC}[
  % CJKShape = Traditional,
  Language=Chinese Traditional, Script = CJK]
\newfontfamily\simpchinesefont{Noto Sans CJK SC}[
  % CJKShape = Simplified,
  Language=Chinese Simplified, Script = CJK]
\newfontfamily\oldchinesefont{BabelStone Han}[
\newfontfamily\greekfont{Noto Sans}[
  % Language = Greek,
  Script = Greek]
% WARNING: RTL scripts require polyglossia or babel to work correctly!
\newfontfamily\arabfont{Noto Sans Arabic}[
  Script = Arabic]

\setTransitionTo{CJKUnifiedIdeographsExtensionB}{\oldchinesefont} % For U+26B99

Holá hello 们 們 안녕 𦮙

Multilingual Text Sample

It doesn’t quite work out of the box for all those languages you requested. First, Simplified Chinese, Traditional Chinese and Korean share many of the same Unicode codepoints, so without further markup, you cannot tell how to render them. Second, it has some problems with right-to-left scripts such as Arabic.

If you wanted to write non-trivial amounts of all those languages in the same document, you would use a package such as Babel and write things like \foreignlanguage{korean}{韓國語} and \DeclareRobustCommand\oldchinese[1]{{\oldchinesefont #1}}.

You could declare individual glyphs with newunicodechar, as in:

\usepackage{fontspec, newunicodechar}
\newfontfamily\oldchinesefont{BabelStone Han}[
  Scale = MatchLowercase,

\newunicodechar{𦮙}{{\oldchinesefont 𦮙}}

This does not play well with ucharclasses, however.

You must log in to answer this question.

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