3

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: tex.stackexchange.com/q/323575/8528 – jon Oct 8 '16 at 5: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 8 '16 at 7: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. – user10274 Oct 8 '16 at 7: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 8 '16 at 7:59
3

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{█}}

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.