To add custom glyphs in PDFTeX on macOS Catalina, you must use XeLaTeX or LuaLaTeX with Unicode-capable font engines, as standard PDFTeX relies on legacy 8-bit encoding maps that cannot handle arbitrary Unicode characters directly. The most reliable solution is to switch your compiler to XeLaTeX, which allows direct input of any glyph present in a system font via the fontspec package, eliminating the need for complex TeX encoding configurations.
Understanding the Limitation of Standard PDFTeX
The core issue arises from how traditional PDFLaTeX processes text. It uses an 8-bit character encoding scheme, typically T1 (EC) or OT1, where only 256 slots are available per font. To include a specific glyph, you must define exactly which slot it occupies in a mapping file. This process is notoriously difficult because it requires precise knowledge of the font's internal structure and often involves creating custom .enc files or using obsolete packages likeucs, which are incompatible with modern TeX Live distributions.
On macOS Catalina, the default TeX distribution (TeX Live) has moved away from these legacy methods. Attempting to force standard PDFTeX to render arbitrary Unicode characters often leads to compilation errors or missing glyph warnings. Instead of fighting this limitation, it is more efficient to use a compiler that natively supports Unicode input.
Switching to XeLaTeX for Direct Glyph Input
XeLaTeX is the recommended compiler for handling non-standard glyphs on macOS. It interfaces directly with the operating system’s font rendering engine, allowing you to use any font installed on your Mac without needing to convert them into TeX-specific formats. This approach bypasses the encoding map restrictions entirely. To implement this, you do not need to modify your existing font files. You simply change the compiler and load thefontspec package. This package provides a high-level interface for selecting fonts and setting up the document environment.
Here is the minimal setup required to enable Unicode glyph input:
\documentclass{article}
\usepackage{fontspec}
% Set your main font to one that contains the desired glyph
\setmainfont{Arial Unicode MS}
\begin{document}
This is a test with a custom glyph: ☃
\end{document}
In this example, the snowman symbol is inserted directly using its Unicode escape sequence. If you have a specific glyph from a specialized font, ensure that font is installed in your /Library/Fonts or ~/Library/Fonts directory.
Configuring System Fonts
macOS Catalina stores fonts in three primary locations. To make a font available to XeLaTeX, place the.ttf or .otf file in one of these directories:
- User Level:
~/Library/Fonts– Best for personal projects. - System Level:
/Library/Fonts– Available to all users on the machine. - Local Level:
/System/Library/Fonts– Reserved for Apple’s core fonts; do not modify.
fc-cache -fv to ensure the system recognizes the new font immediately.
Alternative: Using LuaLaTeX
LuaLaTeX is another powerful alternative that supports Unicode and OpenType features. It is particularly useful if you need advanced typographic control or are working with complex scripts. Like XeLaTeX, it requires thefontspec package and a compatible font installation.
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\begin{document}
Direct Unicode input: é
\end{document}
Choose LuaLaTeX if you prefer a single-pass compilation engine or need to integrate Lua scripting for dynamic content generation. Both compilers offer superior glyph support compared to traditional PDFTeX.
Troubleshooting Missing Glyphs
If a glyph still does not appear after switching compilers, verify that the selected font actually contains the character. Not all fonts include every Unicode code point. You can check font contents using the Font Book app on macOS. Additionally, ensure that your editor is saving the source file in UTF-8 encoding. Most modern editors default to this, but older configurations might use ASCII or Latin-1, causing character corruption during compilation. For related troubleshooting on macOS, such as resolving network issues that might affect package updates, see our guide on Getting ERR_NETWORK_CHANGED in Chromium with both Wifi and Ethernet connected on macOS. If you encounter command-line issues while managing font caches, refer to Tool Hang Issue with xargs --zip-r and xargs --format=zip in MacOS.Frequently Asked Questions
Can I use standard PDFTeX with custom fonts?
Yes, but it requires generating custom encoding files and mapping files, which is highly complex and prone to errors. It is generally discouraged in favor of Unicode-aware compilers.Why does my glyph show as a box even in XeLaTeX?
The font you specified likely does not contain that specific Unicode character. Check the font’s character map in Font Book to confirm its availability before compiling.Do I need to install TeX Live separately on Catalina?
No, macOS Catalina includes basic LaTeX tools, but for full functionality includingfontspec, you should install the complete TeX Live distribution from the official website or use MacTeX.
How do I specify a local font file in fontspec?
You can use thePath option in \setmainfont, such as \setmainfont[Path=/path/to/fonts/]{MyFont.otf}, to load fonts from a specific directory without installing them globally.