Mathematica trick: fixing fonts in plots

There is a way around the hideous bug whereby if you change the fonts in a plot, the symbols (such as minuses) stay in a proprietary Mathematica font that won't display in other programs, or won't print.

Suppose you're doing

Plot[Sin[x], {x, 0, 2Pi}, TextStyle → {FontFamily → Times}]
Export["sin.eps", %, "EPS"]

Before the export, you need to go to the Mathematica "Preferences" Menu, look for FormattingOptions, FontOptions, PrivateFontOptions, and then uncheck "Operator Substitution".

This will let Mathematica export symbols in the Times font.

But there's more to the Mathematica font madness. If graphics is exported using Display[], Mathematica will call the external MathLink program psrender, which can only use the fonts in [mathdir]/SystemFiles/Fonts/Type1 (i.e., the Math fonts, Courier, and the Utopia fonts, but not Times).

If graphics is exported using Export[], Mathematica will try to get its frontend to render the graphics, which seems to allow using more general fonts, at least on OS X and for EPS. In fact, starting with Mathematica v5.0, Export[…, …, "EPS"] has an option IncludeSpecialFonts that defaults to True, which will include the Mathematica fonts in the output files, if they are used in the plot. I have a feeling that this won't preclude the resulting figures from failing in some printers (or when converted to PDF), but at least one could use them after converting the fonts to outlines (with my gs script).

For PDF, even the frontend seems to rely on psrender, so we're back to case one.

Apr 08, 2005

mathminus (/progtricks)
2005-04-08, 13:12 [edit]

  Login:   Password:   [rss] [cc] [w3] [css]

© M. Vallisneri 2012 — last modified on 2010/01/29

Tantum in modicis, quantum in maximis