How can I ensure graphics exported in WMF format don't have text-spacing problems?

A lot of my work involves manipulating data, drawing a pretty plot of it and then inserting that graphic into a report written in Microsoft Word, under Windows.1 The fun comes with the exporting part. If the audience don't have the Mathematica fonts installed, negative signs, parentheses etc will come up as missing-characters in the WMF graphic and in Word.

You can fix this using the PrivateFontOptions option, either in the notebook or in the Options Inspector.

SetOptions[$FrontEnd, PrivateFontOptions -> {"OperatorSubstitution" -> False}]  But I still find the output a bit disappointing, in that the spacing around parentheses and other characters in the WMF file looks wrong (sorry, I can't show the whole graphic because the data are confidential). The code to produce the graph above rests partly on a package, so here is a minimal example:  test = Grid[{{DisplayForm[ AdjustmentBox[ Style["Source: REDACTED (confidential)", 13, FontFamily -> "Arial", Black], BoxMargins -> {{3, 0}, {0, 0}}]]}}]  This is how it looks in Win7 and Office 2010: the first two are with operator substitution ON, the second pair are with operator substitution OFF. There is still a bit too much space but it is better than in Word 2007. As highlighted, there is just too much space between the text and the closing parenthesis. This is not apparent in the Mathematica notebook, where it looks just fine. It must be something to do with Mathematica's WMF export routine: other applications with WMF export don't do this. Is there any way of automatically ensuring that the spacing around letters in the resulting WMF file is a bit more acceptable? Some kind of auto-kerning option? Ideally it should be something I can set in a package so my colleagues don't have to know the internals of how to do it. 1Actually I have people to do that now, but you get the idea. - Could you please show your complete code (including export) which results in a bad WMF and then convert/screenshot your WMF to PNG/JPG and post it here? I'd be nice if you could also circle in Windows Paint the bad areas of the image. – Vitaliy Kaurov Jan 18 '12 at 3:58 @Verbeia these don't appear to be Mathematica fonts causing this problem. i.e. you are using Arial which is a system font isn't it? If you don't have the private font options set what font is used when others open the WMF? What happens if you do not have an adjustment box (there are other methods to indent if this is the problem). Is there always an adjustment box when these font issues arise? The parts of the plot you cannot show that have problems: are these plot or line labels? – Mike Honeychurch Jan 18 '12 at 6:43 Your SetOptions construction is wrong. It should be either SetOptions[$FrontEnd, PrivateFontOptions -> Append[DeleteCases[ PrivateFontOptions /. Options[$FrontEnd, PrivateFontOptions], _[ "OperatorSubstitution", _]], "OperatorSubstitution" -> False]] or shorter CurrentValue[$FrontEnd, {PrivateFontOptions, "OperatorSubstitution"}] = False –  Sjoerd C. de Vries Jan 18 '12 at 11:12
@Mike Strange, I thought this would overwrite the other options that are also in PrivateFontOptions. Apparently it doesn't. Anyway, \$FrontEnd should have been included. –  Sjoerd C. de Vries Jan 18 '12 at 12:13
Is WMF the best choice for importing graphics into Word? I never used to like anything but EPS or PDF when I was doing it for a living... (I suspect that this doesn't seem like a helpful comment. If so, sorry .) –  cormullion Jan 18 '12 at 15:40

If the missing fonts are the problem, one thing you could do is have your recipients download MMA's fonts from the appropriate support page (windows, unix, macintosh). Installing the CDF-player also installs MMA's fonts.

If this is not feasible a robust option is to export as bitmap. You're guaranteed to have no font problems. Obviously that means it doesn't scale, but I found that quite often you don't need that (like in Powerpoint presentations).

On my computer, copying the text from your example to Word2010 and using paste special / picture (metafile enhanced) doesn't give me this problem. But that may be because the fonts are installed on this PC. I'll try to install a virtual machine with Word to see whether it's the same there.

EDIT

Powerpoint and Word 2010 have the options to embed fonts:

.

BTW, I tried your example in a virtual machine Win7-64 installation without a trace of Mathematica or its fonts and it does look normal, i.e. the parenthesis close without the extra space. So, your problem may be caused by a pre 2010 version of Word.

-
"Install the fonts" would definitely be a part of the answer but (a) I can't rely on the IT staff to get this right and (b) this will fail for PowerPoints shown externally. –  Verbeia Jan 20 '12 at 23:01
@Verbeia AFAIK PowerPoint is able to embed the font into the document (for portability) –  Szabolcs Jan 20 '12 at 23:09
@Szabolcs - if you can construct this as an answer with an example it might be the one I will end up accepting - but I will have to test it next week at work. It's the weekend here and my home machine is a Mac. –  Verbeia Jan 20 '12 at 23:13
@verbeia Please see update. One problem that I see is that the bounding box of the area copied is apparently one pixel too small. It looks like Word slices off the upper part of the letters. –  Sjoerd C. de Vries Jan 22 '12 at 14:31

I can only guess that the following could be a work-around for you (I don't have Windows). Define the following wrapper function for Export:

outlinedExport[name_, gr_, opts : OptionsPattern[]] :=
Export[name,
First@ImportString[ExportString[gr, "PDF"], "PDF",
"TextMode" -> "Outlines"], opts]


On my Mac, I cannot export to WMF so I'll have to trust that it will work the same way it does with SVG which I did try. Assuming your graphics object is g, you would do something like this:

outlinedExport["output.wmf", g, ImageSize -> 600]


There is no need to embed any fonts because they have all been replaced by outlined paths (again, not sure if Mathematica on Windows does this properly). The downside is that the file size increases, but the upside is that you'll never have any font headaches again.

-
Late comment, but this works on Windows too. The final format probably ought to be EMF rather than WMF, though. –  Oleksandr R. Jan 14 '13 at 1:43

I suggest to Magnify the output before exporting it to WMF/EMF or increase the ImageSize because metafiles are sampled at screen resolution fidelity (see examples here). I also advise to use the EMF (Enhanced Metafile Format) format which is much better than the old WMF (Windows Metafile Format) developed originally for Windows 3.11...

-