2

I'm trying to print the ✔ symbol using XeLaTeX and directly from the code (i.e. putting the symbol into the source code directly and not using some \macro). I have the following MWE:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Lato}

\begin{document}
This is a test: ✔
\end{document}

But it doesnt work:

xelatex test.tex

enter image description here

However, using Libertine font (with \usepackage{libertine}) works OK.

Is there a way to do it?

Thank you very much in advance.

  • 1
    looks as if your font doesn't contain the symbol, so you will have to switch to another font for it. – Ulrike Fischer Apr 22 at 10:26
  • 2
    The log file says Missing character: There is no ✔ in font Lato Regular/OT, so you'll have to find a font which contains that glyph. – Phelype Oleinik Apr 22 at 10:26
7

The font has no glyph for that character (you can see it from the “missing symbol” glyph or from the message in the log file).

Use a font that provides it. Here I use Libertinus Serif.

\documentclass{article}

\usepackage{fontspec}
\usepackage{newunicodechar}

\setmainfont{Lato}
\newfontfamily{\libertinus}{Libertinus Serif} % a font that has ✔
\newfontfamily{\iosevka}{Iosevka}

\newunicodechar{✔}{%
  \begingroup
  \iffontchar\font`✔ \else \libertinus\fi ✔%
  \endgroup
}

\begin{document}

This is a test: ✔

\iosevka

This is a test: ✔

\end{document}

enter image description here

You might want to have the symbol not to change based on the current conditions. Then use

\documentclass{article}

\usepackage{fontspec}
\usepackage{newunicodechar}

\setmainfont{Lato}
\newfontface{\libertinus}{Libertinus Serif} % a font that has ✔
\newfontfamily{\iosevka}{Iosevka}

\newunicodechar{✔}{%
  \begingroup
  \normalfont\libertinus ✔%
  \endgroup
}

\begin{document}

This is a test: ✔

\iosevka

This is a test: ✔

\end{document}

enter image description here

I use the Iosevka font just to see the difference in the two situations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.