4

Is it possible to tell fontspec to fall back to another font when the main font is missing some glyphs? In the example below, TeX Gyre Termes is missing the SUBSCRIPT ONE glyph (though there doesn't seem to be any warning in the log file!) and I would like to tell luatex to use the glyph from another font such as Libertine.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}
\begin{document}
onesub₁ onesup¹
\end{document}

(I realize that I could use a math subscript in this case, but my content is extracted from a bibliographic database, where it shouldn't be using TeX-specific encodings.)

1 Answer 1

4

The log file shows a warning:

Missing character: There is no ₁ (U+2081) in font TeXGyreTermes:mode=node;script=latn;language=DFLT;+tlig;!

You can define an action for the subscript digits:

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}
\setmainfont{TeX Gyre Termes}
\newfontfamily{\fallback}{Libertinus Serif}

\newunicodechar{₁}{%
  {\iffontchar\font`₁ \else\fallback\fi₁}%
}

\begin{document}

onesub₁ onesup¹

\end{document}

enter image description here

Alternatively, use \textsubscript:

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}
\setmainfont{TeX Gyre Termes}

\newunicodechar{₁}{%
  {\iffontchar\font`₁ ₁\else\textsubscript{1}\fi}%
}

\begin{document}

onesub₁ onesup¹

\end{document}

enter image description here

1
  • That works well, thanks. Perhaps it would be useful to distribute "font fixup" classes that work around defects in common fonts and version track updates, since it seems that many users would benefit. Commented Aug 27, 2018 at 11:09

You must log in to answer this question.

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