6

I want to declare more than one font so XeTeX can use other fonts when first font did not have a specific glyph. How can I do that? In windows when the current font does not have a glyph, other font are used to show that glyph.(e.g. I want insert tick (✓) directly, not with \Checkmark)

I know that I can use a Unicode font like code2000 but as you know this kind of fonts generally are not pretty enough.

\documentclass{article}
\usepackage{bbding}
\begin{document}
\section{NOK}
 (✓)  (✗)
\section{OK}
(\Checkmark )  (\XSolidBrush)
\end{document}

enter image description here

\documentclass{article}
\usepackage{bbding}
\usepackage{fontspec}
\setmainfont{Arial Unicode MS}

\begin{document}
\section{OK}
 (✓)  (✗)
\section{OK}
(\Checkmark )  (\XSolidBrush)
\end{document}

enter image description here

At least I want to specify two fonts (e.g.\setfont{Arial,Code200}) ,a main font and a Unicode one so it can be used for missed glyphs.

8

Using two (or more) fonts in XeLaTeX (or LuaLaTeX) is very easy, since the fontspec package which handles fonts for those engines provides commands for loading new fonts and assigning macro names to them.

What you cannot do is have automatic switching from one font to another if XeTeX fails to find a glyph in a particular font.

Here's an example of font switching used for inserting phonetic characters (which many fonts don't have). The standard font that linguists use for phonetics is Doulos SIL. You can use it in XeLaTeX in the following way:

\documentclass{article}
\usepackage{fontspec}
% We are using Linux Libertine O as our main serifed font
\setmainfont{Linux Libertine O}
% now declare a command \doulos to load the Doulos SIL font
\newfontfamily\doulos{Doulos SIL}
% now create a \textIPA{} command
\DeclareTextFontCommand{\textIPA}{\doulos}
\begin{document}
Here is some text in the main font.
% We now have two ways to enter IPA characters directly in the document:
% Use the \doulos command inside a group
{\doulos [ðɪsɪzsəmfənɛtɪks]}
% or use the \textIPA command
\textIPA{[ðɪsɪzsəmfənɛtɪks]}
\end{document}

In your new example using checkmarks and crosses, you can do things similarly. Here I've used Arial Unicode MS and Zapf Dingbats to show two different versions of these characters (I don't have the Code2000 font). But the principle is exactly the same.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Arial Unicode MS}
\newfontfamily\dingbats{Zapf Dingbats}
\DeclareTextFontCommand{\textding}{\dingbats}
\begin{document}
\section{In the main font}
 (✓)  (✗)
\section{In the Dingbats font}
{ (\textding{✓})  (\textding{✗})}
\end{document}

output of code

  • Can you please update your answer according to updated question? – PHPst Feb 14 '13 at 8:19

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.