6

I'm writing a document in XeLaTeX which includes some weird unicode characters such as █. The main font I want to use is OpenSans, which I have specified using

\setmainfont{OpenSans}

When I build my document XeLaTeX gives me an error:

Missing character: There is no █ in font Open Sans/OT:script=latn;language=DFLT;mapping=tex-text;!

Is it possible to configure XeLaTeX to use a different font when it encounters characters that aren't present in the main font? This is probably a dumb question, but I'm new to LaTeX.

  • 1
    See this question for more information: http://tex.stackexchange.com/q/323575/8528 – jon Oct 08 '16 at 05:44
  • @jon Thanks for the link, that's interesting. Shame there's no definitive answer, but I think I can probably use \newunicodechar as mentioned in that question. – Joshua Walsh Oct 08 '16 at 07:09
  • If you want to use the black square as an end-of-proof symbol, please have a look at the amslatex bundle, which (BTW) has a much nicer white box for it. –  Oct 08 '16 at 07:31
  • Thanks for the recommendation, I'm not using it as part of any proofs though. I'm importing data from a website and using XeLaTeX as part of my workflow to make it more print-friendly. The data contains special characters at times. – Joshua Walsh Oct 08 '16 at 07:59

1 Answers1

5

Using the information on the question that jon linked to in a comment, I was able to achieve this.

\setmainfont{OpenSans}
\newfontfamily{\fallbackfont}{Arial}
\DeclareTextFontCommand{\textfallback}{\fallbackfont}
\newunicodechar{█}{\textfallback{█}}