Bug persists through 12.0

When exporting graphics with annotation in PDF using Export, under some circumstances fonts are not inherited properly. I'll illustrate on the example of fonts containing subscripts, but the problem arises also when some other special characters are present (e.g. i've noticed it with "-" (minus) character as well)

This example illustrates expected behavior.

Graphics@Text[Subscript[ToString@x, ToString@1],BaseStyle -> FontFamily -> "Arial"]
Export["test1.pdf", %, "PDF"]

All characters in the "test1.pdf" file are printed using Arial font, which is expected behavior. However, when the Subscript construct is replaced with

Graphics@Text["\!\(\*SubscriptBox[\(x\), \(1\)]\)",BaseStyle -> FontFamily -> "Arial"]    
Export["test2.pdf", %, "PDF"]

that is, when the input is entered in TraditionalForm, the exported file contains, besides Arial (subscript) also CairoFont-0-0 (upper letter). It seams that everything comes down to how Export interprets the underlying box structure. In the first case, the full form of the expression is

Graphics[Inset[Subscript["x", "1"], List[0, 0],Rule[BaseStyle, Rule[FontFamily, "Arial"]]]]

while in the second example, the underlying expression is

Graphics[Inset["\!\(\*SubscriptBox[\(x\), \(1\)]\)",  
List[0, 0],Rule[BaseStyle, Rule[FontFamily, "Arial"]]]]

Since this is not limited to Subscript (i've noticed it also with Plot when the Ticks contains contains negative values), is this expected behavior or am I missing something?

P.S. Output of $Version is "11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)"


1 Answer 1


I reproduced the issue with version 11.2.0 on Windows 7 x64.

The problem is that Italic text do not inherit FontFamily from the enclosing Text and even Style. Instead of this Mathematica generates and embeds in the PDF a new font "CairoFont 0 0" containing italicized version of the letter from the font specified via FontFamily:


    Style["text", Italic, FontFamily -> "Arial"]], 
   "TextOutlines" -> False][[1]] // InputForm
"11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)"

  Style[{Text["text", {0., 3.}, {Left, Baseline}]},
   FontFamily -> "CairoFont 0 0", FontSize -> Scaled[0.58], Thickness[0.0625]]},
 ImageSize -> {16., 12.}, PlotRange -> {{0., 16.}, {0., 12.}}, AspectRatio -> Automatic]

(note also the absence of FontSlant -> "Italic" in the first Style directive).

The problem does not exist in version 8.0.4:


    Style["text", Italic, FontFamily -> "Arial"]], 
   "TextOutlines" -> False][[1]] // InputForm
"8.0 for Microsoft Windows (64-bit) (October 7, 2011)"

  Style[{Text["text", {0., 4.2}, {Left, Baseline}]}, 
   FontFamily -> "Helvetica,", FontSlant -> "Italic", 
   FontSize -> Scaled[0.6], Thickness[0.07]]}, 
 ImageSize -> {15., 12.}, PlotRange -> {{0., 14.4}, {0., 12.}}, AspectRatio -> Automatic]

I recommend reporting this as an inconsistency or misbehavior. The expected behavior is what we got with version 8.0.4.

In the case of single letters when you don't need Italic one workaround is to switch off SingleLetterItalics:

Graphics@Text[Style["\!\(\*SubscriptBox[\(x\), \(1\)]\)", FontFamily -> "Arial", 
    SingleLetterItalics -> False]];
Import[Export["test2.pdf", %, "PDF"], "TextOutlines" -> False][[1]] // InputForm
  Style[{Text["x", {175.723145, 177.}, {Left, Baseline}]}, 
   FontFamily -> "ArialMT",
   FontSize -> Scaled[0.025], Thickness[0.003]],
  Style[{Text["1", {180.223145, 175.5}, {Left, Baseline}]}, 
   FontFamily -> "ArialMT", 
   FontSize -> Scaled[0.017749022222222226], Thickness[0.003]]}, 
 ImageSize -> {360., 360.}, 
 PlotRange -> {{0., 360.}, {0., 360.}}, AspectRatio -> Automatic]

... or equivalently you can convert the letter into a string:

Graphics@Text[Style["\!\(\*SubscriptBox[\(\"x\"\), \(1\)]\)", FontFamily -> "Arial"]];
Import[Export["test2.pdf", %, "PDF"], "TextOutlines" -> False][[1]] // InputForm

(output is identical).

Another way is to embed styling information directly into the string:

str = ToString[Style[Subscript[ToString@x, ToString@1], 
  FontFamily -> "Arial"], StandardForm];

Import[Export["test2.pdf", %, "PDF"], "TextOutlines" -> False][[1]] // InputForm

(output is identical).

But both workarounds don't solve the underlying problem of Italic text being exported with an artificial font instead of the font specified via the FontFamily option.

  • $\begingroup$ Ok, thank you for reproducing. If you know someone from Wolfram you can just mention him in the comments $\endgroup$
    – ercegovac
    Sep 30, 2017 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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