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)"