4

I'm running XeLaTeX on a Mac, and I'm getting into a lot of trouble with finding fonts.

Here's my code (taken from here: Revisiting TIPA and Fontspec)

\documentclass[12pt]{article}

\usepackage{environ}
\usepackage[no-math]{fontspec}

\newfontfamily{\tipacm}{CMU Serif}

\NewEnviron{IPA}{\expandafter\textipa\expandafter{\BODY}}
\renewcommand\useTIPAfont{\tipacm}

\begin{document}

\normalfont
\textipa{k\textscripta T\'{a}}
\textipa{kAT\'{a}}
\begin{IPA}
  kAT\'{a}
\end{IPA}

\end{document}

Whenever I run it, I get the "font-not-found" error. when I search the fc-list for anything that looks like "computer modern" or any variant or abbreviation of that, I find nothing.

But obviously, my computer does have Computer Modern installed, since it's making these default pdfs fine. I would like to be able to make a new font family (e.g. \newfontfamily{\tipacm}) with the default font? If it's using a font to make a pdf, shouldn't I be able to make a renamed copy of it without having to load something externally? In essence, I'd like to make a new font family without having to load anything dependent on file paths.

Theoretically, I'd like something like: \newfontfamily{\tipacm}{\currentdefaultfontfamily}

uberpro
  • 43

2 Answers2

5

The best is if you install CMU also in the /Library/Fonts folder. Otherwise, you can get the same with a slightly more complicated code:

\documentclass[12pt]{article}

\usepackage{environ}
\usepackage[no-math]{fontspec}

\newfontfamily{\tipacm}[
  Extension=.otf,
  UprightFont=*rm,
  %ItalicFont=*ti,% no IPA here
  BoldFont=*bx,
  %BoldItalicFont=*bi,% no IPA here
]
{cmun}

\NewEnviron{IPA}{%
  \expandafter\textipa\expandafter{\BODY}%
}
\renewcommand\useTIPAfont{\tipacm}

\begin{document}

\normalfont
\textipa{k\textscripta T\'{a}}
\textipa{kAT\'{a}}
\begin{IPA}
  kAT\'{a}
\end{IPA}

\textbf{\textipa{A}}

\end{document}

enter image description here

In order to install the font also for the system, open a new Finder window, hit Command-Shift-G and type, in the box that opens,

/usr/local/texlive/2015/texmf-dist/fonts/opentype

Open another Finder window and to the same for /Library/Fonts. Now copy the folder cm-unicode from the first window to the second one.

egreg
  • 1,121,712
1

CMU Serif is not part of Mac OSX system fonts. You have to make the TeXLive (MacTeX) fonts known to your system:

Run kpsewhich --var-value TEXMFLOCAL which shows the directoty of your local tree. This is by default for a Mac ~/Library/texmf/ but can be different on your machine. Then save the font files into ~/Library/texmf/fonts/opentype/ and run texhash after saving the files to update the filename database.

  • I thought XeTeX did not use fontconfig on Mac OS X ? –  Jan 14 '16 at 21:22
  • I am not a MAC user. Maybe that you are right. If it doesn't use fc how does the Mac can scan other directories for fonts than the system one? –  Jan 14 '16 at 21:45
  • It doesn't I think: by default there is system-wide /Library/Fonts and user ~/Library/Fonts. These repertories are special. You just move fonts in there. Application FontBook allows to manage them, for example you can de-activate some of the installed fonts or also define another font repertory for installation. Installing a new font is a simple as double-clicking on it on then "Install", or from inside FontBook.app. There is also the notion of "Font Library" which you can create in "FontBook" and then add to it fonts from arbitrary locations (even network disk). –  Jan 15 '16 at 07:52
  • By the way the fontconfig related instructions like http://tug.org/texlive/doc/texlive-en/texlive-en.html#x1-340003.4.4 and the /etc/fonts/conf.d/09-texlive.conf story are completely inoperant on Mac OS. I have asked the texlive team some months ago to clarify what applies to mac os and what does not. –  Jan 15 '16 at 07:57
  • @jfbu: that would be a good idea to modify the web page –  Jan 15 '16 at 08:05
  • @jfbu: On a Mac a kpsewhich --var-value TEXMFLOCAL should show the local tree which is by default ~/Library/texmf/. Then one can put the fonts into ~/Library/texmf/fonts/opentype/ and run texhash after saving the files. –  Jan 16 '16 at 08:06
  • I don't think ~/Library/texmf/ is the default for TEXMFLOCAL, rather it is the default for TEXMFHOME. It is not recommended to run texhash on TEXMFHOME as you have to recall doing it all the time you modify something there. Adding fonts into ../fonts/opentype will I presume work with XeTeX only if addressing fonts by filenames, else you need ExternalLocation key to \setmainfont. And the fonts will not be known to the system until the user uses FontBook for that. –  Jan 16 '16 at 21:17
  • That is the Same behaviour for all destributions! You have to decide: Do you want the TeX fonts also als system fonts or not. –  Jan 17 '16 at 06:52
  • We are probably not talking about the same things. Your last comment suggests an exclusive disjunction applies, but this is not correct on mac os x as it is possible via FontBook application to tell the system about extra font repertories, for example those from the various texmf hierarchies. When calling the font by font name, xetex will then find it via the mac os services (untested). If you don't need the font to be known by the system, then you can always call them by filenames, with ExternalLocation extra key. –  Jan 17 '16 at 09:04
  • (continued) If you want the system to be aware, the usual advice is to duplicate everything. But as I said there seems to be alternatives (untested). Anyway, the situation on mac os x does have some differences: it doesn't use at all fontconfig. I am not aware of any documentation for TeX mac os x users telling something else than: duplicate the fonts into System repertories. But FontBook opens more possibilities. The problem then is perhaps you also want your set-up to work with LuaLaTeX. Duplicating works, but perhaps what I said in last comment too. No desire nor time to test, though. –  Jan 17 '16 at 09:09