Upon exporting a Mathematica graphics expression as a PDF, Mathematica does not seem to embed any nonstandard fonts used. When you open the resulting PDF document with a PDF viewer, all the text items are rendered with standard fonts instead.

Is there a way to make Mathematica embed nonstandard fonts?

Example with Mathematica 8.0.4 under Mac OS X 10.7:

g = Graphics[{ Circle[], 
    BaseStyle -> {FontFamily -> "Papyrus", FontWeight -> "Bold", 
      FontSize -> 24}]}, ImageSize -> Tiny]
f = Export["~/Desktop/Graphics.PDF", g, "PDF"]

The resulting PDF does not use the correct font.

  • 1
    $\begingroup$ Can you give a code example, and instructions for checking that the fonts are embedded? I tried Export["testpdf.pdf", Graphics@Text[Style["asd", FontFamily -> "Candara", FontSize -> 50]]] and Adobe Reader reports that the font is embedded. I used CTRL-D in Adobe Reader, and clicked the Fonts tab. It says, "Candara (Embedded)". $\endgroup$
    – Szabolcs
    Jan 24, 2012 at 20:26
  • 1
    $\begingroup$ See updated question. $\endgroup$
    – sakra
    Jan 24, 2012 at 21:07
  • $\begingroup$ Sakra, what font version of Papyrus and what format is it? You can check this in Fontbook. I think it matters. $\endgroup$
    – Verbeia
    Jan 26, 2012 at 19:01
  • $\begingroup$ Font Book.app says Version 6.1d10e2. $\endgroup$
    – sakra
    Jan 26, 2012 at 19:31
  • $\begingroup$ In Linux (Mathematica version 12.1.0) the embedding does not work as tested with the Export/Import example... $\endgroup$ Aug 25, 2020 at 13:26

3 Answers 3


What Verbeia said in her answer is not entirely correct — Mathematica indeed does embed the font, regardless of whether a particular font weight/slant exists or not. The real culprits are the PDF viewers on Macs, which do not use the base font if the specified weight is not available. It took some digging around to get to the reason though. The clues that led to my reasoning are as follows:

  1. Mathematica knows what font it used when you re-import
    This was the first clue. Executing Import["~/Desktop/Graphics.PDF"] will correctly display the graphics in Papyrus font, albeit without the bold option (which, as Verbeia noted, doesn't exist in all fonts). So the information had to be in the file somewhere.

    enter image description here

  2. The binary file shows Papyrus embedded in it
    Opening the pdf in vim under hex mode, you find the font info embedded in it. What you see in the readable text on the right is the full copyright info, which they'd have to include only if it were embedded.

    enter image description here

  3. It opens correctly on linux systems
    Papyrus is not a font that comes installed by default with linux systems. The above file opens with the correct font (but not weight) on RHEL 6 and Ubuntu 11.10, which can only mean that the font is embedded in the pdf. Below is a screenshot in RHEL 6, with the same file opened in Adobe reader (left) and evince (right).

    enter image description here

  4. Hey, it opens perfectly in Adobe Reader!
    Below is a screenshot of the same file opened in Adobe reader (left) and Preview.app (right). You can see that Adobe sure does know which font to use.

    enter image description here

So you can see here that the problem is most likely with the PDF viewers on macs (other than Adobe reader). My guess is that they don't stay true to Adobe's specifications, and instead rely on OSX's Quartz framework for rendering the file, which is why you don't see the right font.

Either that, or they don't like the fact that Mathematica uses PDF v1.4 to export its files. v1.4 is pretty old (2001), and it is worth mentioning (since you're embedding non-standard fonts) that PDF v1.4 does not support embedding "Open Type" fonts. That was introduced only in v1.6, and if you're working with such fonts, you might want to keep this in mind.

  • $\begingroup$ Thanks for digging that out. I only use Preview.app for PDF viewing under Mac OS X. $\endgroup$
    – sakra
    Jan 25, 2012 at 18:33
  • $\begingroup$ @R.M Aren't you saying, though, that Adobe Reader doesn't so much 'use the correct font' as 'guess correctly what Mathematica got up to when it created the file', and then cover for it? Technically Mathematica specified a font that didn't exist, and just drew a black line around the font to make it look bold. But Preview refused to make a font up this way, and defaulted to something it did have. If you ask for Papyrus Italic, Mathematica can do that too... Perhaps Preview should loosen up and play a little bit more! $\endgroup$
    – cormullion
    Jan 25, 2012 at 20:17
  • $\begingroup$ @R.M this answer is incorrect and misleading. The presence of the font name in the PDF file does not mean that the font itself is embedded in the file, which was the OP's question. Adobe Reader and Mathematica display the re-imported graphic correctly because you have the font installed. If you displayed the graphic on a computer that did not have the font installed, the bold version would not display but the normal weight one would. (Though strangely, now that I check this on my Mac it does embed, even though similar fonts on Windows don't. The format of the font might matter as well.) $\endgroup$
    – Verbeia
    Jan 26, 2012 at 13:10
  • $\begingroup$ @Verbeia I don't follow your comment... you start out saying it isn't embedded, but ultimately agree with me in saying that it is indeed embedded. Which one is it? It is incorrect to say that the font is not embedded just because it doesn't have a bold option. As I said in my answer (but didn't make it explicit) I tested it on ubuntu 11.10 and it opens with the correct font. Papyrus is a font that is shipped only with Windows and OS X, not linux distros, and this can only mean that the font was embedded. $\endgroup$
    – rm -rf
    Jan 26, 2012 at 16:51
  • 2
    $\begingroup$ Ok I have removed the downvote. But I think that both answers contain part of the truth. There clearly are fonts that don't embed properly, even if they exist, or this question would not have come up. And even though Papyrus Bold works in some PDF viewers, it is fair to say that font weights that don't exist can't be relied on. It is not clear to me that Preview's behaviour is incorrect. There seems to be a subtle relationship between font format and how it exports, which needs further investigation. $\endgroup$
    – Verbeia
    Jan 26, 2012 at 22:13

Mathematica will normally embed the fonts correctly in a PDF. But this only works if the font exists. Papyrus does not have a bold weight. Try with FontWeight->"Bold" deleted and see if this works.

I don't have Papyrus on my Windows machine, but I checked that Kristen ITC does not embed if it is bold, and does if the FontWeight option is removed.

enter image description here enter image description here

  • $\begingroup$ By the way @sakra, thank you for this question. I didn't actually know the answer to this, and your question made me find it out. Very useful. $\endgroup$
    – Verbeia
    Jan 24, 2012 at 22:06
  • $\begingroup$ +1 that is interesting that it doesn't embed if the font weight for that font isn't available. $\endgroup$ Jan 24, 2012 at 22:49

In Mathematica 9, (rm -rf)'s comment that fonts with the extension .otf (aka OpenType) can't be embedded still holds. In addition, I've also noticed that not all fonts with the extension .ttf can be embedded.

When choosing a font for your PDF files, it might be best to always test the files in other environments where that font isn't installed.

  • 1
    $\begingroup$ This seems to be the issue in Mathematica 10.2 as well. $\endgroup$
    – shrx
    Jul 27, 2015 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.