# [XeTeX] Quick question on font substitutions and the like

Jonathan Kew jonathan_kew at sil.org
Sun Dec 9 07:16:48 CET 2007

On 8 Dec 2007, at 10:36 pm, Michael B. Trausch wrote:

> I cannot seem to find any information on what I want to do here, and
> maybe I just don’t know how to articulate it in a way that the
> search
> engine likes.  All I want to do is have it so that some Unicode
> characters (0x2191 & 0x2192, in my present case) are rendered in a
> different font than the mainline text.  I use a font that doesn’t
> have
> those glyphs, and I have another font that has those glyphs; I would
> like it such that every time XeTeX encounters “→” in the
> document
> source, it switches the currently active font, outputs that character,
> and then switches back to the font that I am using.  Is that possible?

You could do this by making these characters "active" (i.e., single-
character macros) and giving them appropriate definitions:

\catcode"2191 = \active
\def^^^^2191{{\arrowfont\char"2191}}

where \arrowfont is a command you've defined that switches to the
font you want to use. (If you're using xelatex, you can use
fontspec's \newfontfamily to define it; see the fontspec documentation.)

HTH,

JK