# Import text outlines from PDF format properly

Bug introduced in 10.0 and persisting through 12.0

I am attempting to implement this: How can I wrap text around a circle?

But I need Unicode support. Unfortunately, in my case, this gives a broken output (some Unicode characters missing replaced by rectangles)

ImportString[ExportString[
Style["ěščřžýáíé", FontFamily -> "Verdana",
FontSize -> 12],
"PDF"
],
"TextMode" -> "Outlines"][[1, 1]] // Graphics


Can this be fixed somehow?

• The characters which do not work ( [SHacek] and [ZHacek ) are from ISOLatin2. So it looks like ISOLatin2 characters are not fully implemented when exporting them. I think this is just another bug and you should report it to Wolfram Research (support@wolfram.com) and then in a couple of days, or weeks, or months, or years, or never, it might get fixed in a future release. – Rolf Mertig Jan 14 '18 at 14:51
• It works as expected with versions 8.0.4 and 9.0.1 but fails starting from version 10.0. So it is a bug introduced in 10.0, adding the tag. Please report it to support@wolfram.com. – Alexey Popkov Jan 14 '18 at 15:52
• The bug seems to be in importing rather than exporting. When I export and save to file, then display the file with another software, it displays OK. – user1747134 Jan 14 '18 at 18:15
• The bug has been reported and I got a confirmation e-mail acknowledging the bug. – user1747134 Jan 19 '18 at 9:27
• Update: The error persist in 11.3. – user1747134 Mar 15 '18 at 14:15

I reproduce the problem with versions 10.0.1, 10.4.1 and 11.2.0 on Windows 7 x64. The problem isn't related to the font used: the same happens when instead of FontFamily -> "Verdana" I set "Times" or "Courier". At the same time, with versions 8.0.4 and 9.0.1 I get the expected output:

Note that in versions 8 and 9 non-ASCII characters are Exported as outlines, not as text. This is the reason why they are always imported as outlines, even with "TextOutlines" -> False.

The new Export produces a correct PDF file:

Export["test.pdf",
Style["ěščřžýáíé", FontFamily -> "Courier", FontSize -> 12]] // SystemOpen


Here is how it is rendered by Acrobat 11 (I intentionally selected a part of text to show that it is selectable text):

The text can be copied and pasted from Acrobat into Notepad correctly, hence there are no problems with encoding in the exported PDF.

This file (created by version 11.2.0) can't be correctly imported by pre-10 Import: the latter is unable to decode correctly any character at all:

So the overall conclusion is that both Import and Export starting from version 10 received Unicode support, but in the case of Import there are bugs with some particular symbols.

Unfortunately I can't suggest any workaround for this problem except downgrading to a pre-10 version of Mathematica. Even new in version 10 BoundaryDiscretizeGraphics function is affected by this bug:

Apart of this, the options "TextMode" -> "Outlines" and "TextOutlines" -> True are ignored by Export, so we can't revert to the old behavior of Export.

Please report it to the tech support.

### UPDATE

According to discussion here, one can use GhostScript for outlining fonts in the exported PDF file. It can be automatized with gsExport function from this answer by Jens. Then Import will correctly import outlines from obtained PDF file (like it was in versions 8 and 9).

It works with Times on my system (Mac 10.11.6, Mathematica 11.1.1):

ImportString[ExportString[
Style["ěščřžýáíé", FontFamily -> "Times", FontSize -> 12], "PDF"],
"TextMode" -> "Outlines"][[1, 1]] // Graphics


• Which version do you use and on which OS? It doesn't work for me with versions 10.0.1, 10.4.1 and 11.2.0 on Windows 7 x64. – Alexey Popkov Jan 14 '18 at 16:12
• Does not work for me. Linux, Mathematica 11.2 – user1747134 Jan 14 '18 at 17:46
• @AlexeyPopkov I should have said that this is on a Mac with OS 10.11.6 and Mathematica 11.11.1. – Themis Jan 14 '18 at 17:54
• @AlexeyPopkov Works for me also (with OSX 10.11.6, mma 11.2) with Times but not Times New Roman, with Courier but not Courier New, with Helvetica but not Arial, ... (Print@{#, ImportString[ ExportString[ Style["ěščřžýáíé", FontFamily -> #, FontSize -> 12], "PDF"], "TextMode" -> "Outlines"][[1, 1]] // Graphics}) & /@ \$FontFamilies[[1 ;;]] (be careful, this completely crashes my mma session when it reaches the font "YuGothic" (ExportString[.., "PDF"]) ...). – SquareOne Jan 16 '18 at 9:53