# How to input characters into XeLaTeX

How do I input the non-keyboard characters into TeXShop?

My minimum working example:

\documentclass{book}
% Font Settings
\usepackage{fontspec}
\newfontfamily\myfont{C64 Pro Mono}
\begin{document}
\myfont\huge
Commodore 64 Font\par
\normalfont
Normal Font\par % Book title
\end{document}


The text "Commodore 64 Font" appears in the C64 Pro Mono font like I want, but I can't figure out how to get the other characters (see picture) beyond what I can type on the keyboard.

I'm using a Mac, so I can find the codes for the other characters through the Characters app, but I don't know how to get them into TeXShop. If I cut-and-paste, then I get strange characters.

I'm assuming there is a way to put the Unicode in, but I can't figure out how.

I've seen examples where non-English language is input - CJK, etc. - but TeXShop doesn't seem to allow it for me.

I've found the glyph codes in Character viewer based on the answer below, so I'm adding a picture here in case anyone else is looking for a way to find the glyph numbers for use with \XeTexglyph :

-
Unfortunately this only works with the pre-Lion version of the character viewer. Since Lion, the character viewer no longer allows you to see all the characters for one particular font. –  Alan Munn Aug 13 '13 at 14:03

Another way to enter the characters is to enter them directly with the \XeTeXglyph macro or use their Unicode character code using the \char macro.

For example, the heart symbol is Unicode 2665 so you can enter that using:

\char"2665


It's also possible to use the font specific glyph index number. For a font like the C64 font, which doesn't have a huge character inventory, this might be easiest. The following document creates a full font table for the C64 Pro Mono font (the upper bound was found by trial and error, but you could use FontForge to find the total number of glyphs as well).

% !TEX TS-program = xelatex

\documentclass[12pt]{article}
\usepackage{pgffor}
\usepackage{fontspec}

\newfontfamily\csixtyfour{C64 Pro Mono}

\DeclareTextFontCommand{\textcom}{\csixtyfour}
\begin{document}
\parindent=0pt
\foreach \x in {4,...,312}
{\x\thinspace\textcom{\XeTeXglyph\x} }

\end{document}


-
To use XeTeXglyph, it says to put the "index" number afterward (e.g., \XeTeXglyph 123). Where do I find the index number? I'm using the Character viewer on Mac OS X, but all it shows are the Unicode and UTF-8 codes. –  Kevin P. Kilburn Aug 12 '13 at 10:43
You can create a font table for yourself based on the example I gave; it's also possible to enter the Unicode hex value using the \char command. E.g. \char"2665 will yield the heart character. –  Alan Munn Aug 12 '13 at 12:37