# Easiest way to create TeX macro/code to access symbols from particular font?

I would like to use CASIO fonts here.

1 - I would like to create a way to use LaTeX to get these "icon"s. For example, use \On for the ON button, and ect. Assuming we have to do some more work here to find the mapping of those icons here...

2 - As you can see that target computers (final PDF verwiers) may not have the font installed. I know that we can embed font into PDF. Can this be done using latex too?

3 - I don't mind using a normal .tex to enable me to do so, or creating a package. But I have minimal experience in creating one, so quick-and-easy would be the best.

• Have a look at fontspec. You can easily define a new font family with the fonts (assuming they are TTF/OTF). Then just use your font family as in {\myfontfamily\char"...} where ... is the unicode code point of the symbol you want to use. And then you can create macros for every shorthand you need. – TeXnician May 31 '18 at 15:52

You can call the glyphs by number rather than “by character”. With the following code we can gather the number of each glyph in the font:

\documentclass{article}
\usepackage[a4paper,margin=2cm,heightrounded]{geometry}
\usepackage{fontspec}
\usepackage{multicol}

\newfontface{\casio}{CASIO ClassWiz}[
Extension=.ttf,
Path=./ClassWizSeriesFontSet/,
]

\begin{document}

{\casio\xdef\casiofont{\the\font}}

\begin{multicols}{4}
\count255=32

\loop\ifnum\count255<"10FFFF
\iffontchar\casiofont\count255 \the\count255\ {\casio\char\count255}\endgraf\fi
\repeat

\end{multicols}

\end{document}


For your document you can look up the characters you need and define

\newfontface{\casio}{CASIO ClassWiz}[
Extension=.ttf,
Path=./ClassWizSeriesFontSet/,
]


(if you install the font system wide, you don't need those options, of course; otherwise, adjust the path).

Next, assign macros to the glyphs you need:

\newcommand{\casiosymbol}[1]{{\normalfont\casio\symbol{#1}}
\newcommand{\CLeft}{\casiosymbol{33}}
\newcommand{\CEquiv}{\casiosymbol{34}}
\newcommand{\CFactorial}{\casiosymbol{37}}


You can improve the list at any time.

• Thanks. I think that's what I meant by "mapping the icons". I will explore more using this method. – Chen Stats Yu May 31 '18 at 17:00
• Is there any advantage of doing it this way? – Alan Munn May 31 '18 at 18:58
• @AlanMunn I see no advantage in using characters. – egreg May 31 '18 at 19:42
• @egreg The advantage for me was that I could simply use the character map provided with the font to assign names. – Alan Munn May 31 '18 at 20:53

It's really not hard to do, but it would make sense to make it a package.

## Update

I've now packaged this as a package with command names for all the keys. It is now on CTAN. Since I don't use the calculator, suggestions are welcome for more appropriate names for some of the keys. You can submit them at https://github.com/amunn/casiofont/.

## Sample document

Here's a sample document. Fonts are embedded by default so any viewer should be able to view the resultant file.

\documentclass{article}
\usepackage{casiofont}
\begin{document}
{\casio \Shift\Alpha\UpArrow\DownArrow\LeftArrow\RightArrow}

\textcasio{\UpArrow}
\end{document}


• I would wrap \casioinside the \newcommand* macros, within an extra set of braces. That way, you can write \shift instead of \textcasio{\shift} and not get q. – Davislor May 31 '18 at 19:12
• Additionally, you should probably load CASIO ClassWiz with Scale=MatchUppercase. – Davislor May 31 '18 at 19:14
• @Davislor Yes, that's a good idea. I'll update shortly. – Alan Munn May 31 '18 at 19:19
• Oh, and having the internal macros you define in your packages include an @ makes it less likely that they’ll clash with user-defined commands. – Davislor May 31 '18 at 19:38
• @Davislor Of course. But this package has none. :) – Alan Munn May 31 '18 at 20:51