XeTeX Unicode – How to Insert Glyphs from an OTF Font?

symbolsunicodexetex

I'm trying to figure out how to insert specific pictographic glyphs from a font into my document.

So far I have managed to define a new font family using:

\newfontfamily\icons[
    Path = {"/Users/simontoth/Library/Fonts/"},
    Extension = .otf,
    UprightFont = *-Regular-400,
]{Font Awesome 6 Pro}

But when I try to use it with a Unicode glyph number, I run into an error:

! Missing number, treated as zero.
<to be read again>
                   f
l.11 {\icons \symbol{f1f9}
                          }

What am I doing wrong? Or is there a better way to approach this?

Best Answer

The argument of \symbol expects TeX's number syntax. Normally numbers should be given in decimal, but hexadecimal numbers can be used too by adding a " in front of them. In this case, TeX requires them to be given in uppercase. So you need e.g. \symbol{"F1F9} instead of \symbol{f1f9}.