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.

4
  • 1
    See this question for more information: tex.stackexchange.com/q/323575/8528
    – jon
    Oct 8, 2016 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. Oct 8, 2016 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, 2016 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. Oct 8, 2016 at 7:59

1 Answer 1

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

You must log in to answer this question.

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