12
$\begingroup$

I was thinking it would be nice if I could export Mathematica expressions as svg, but I am having some issues. At first blush everything seems to work fine. This piece of code does produce a svg file:

res = Solve[x^2 + a x + 1 == 0, x]
Export["res.svg", res]

The problem with the svg file are the fonts. If I try to open the file in Adobe Illustrator I get this message:

SVGMathematica2Mono:
Font not found on the system; missing font has been substituted.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
SVGCourier:
Font not found on the system; missing font has been substituted.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

The end result looks like this: SVG issues

It looks bad in several other svg viewers as well. Is there some way to either embed the needed fonts in the svg file or convert the expression to a graphic and export it as such?

asked Feb 2, 2013 at 22:17
$\endgroup$
2
  • $\begingroup$ You could copy the fonts into a place where Illustrator can find them... $\endgroup$ Commented Feb 2, 2013 at 22:22
  • $\begingroup$ My hope is to be able to distribute the svg files to other people. $\endgroup$ Commented Feb 2, 2013 at 22:41

1 Answer 1

16
$\begingroup$

Yes, you can indeed convert the output to a graphics object before exporting it. I wrote a function for that in this answer, and it works with SVG too:

outlinedExport[name_, gr_, opts : OptionsPattern[]] := 
 Export[name, 
 First@ImportString[ExportString[gr, "PDF"], "PDF", 
 "TextMode" -> "Outlines"], opts]
res = Solve[x^2 + a x + 1 == 0, x]

$\left\{\left\{x\to \frac{1}{2}\left(-\sqrt{a^2-4}-a\right)\right\},\left\{x\to \frac{1}{2} \left(\sqrt{a^2-4}-a\right)\right\}\right\}$

outlinedExport["res.svg", res]
(* ==> "res.svg" *)

Here is the output of the svg:

pic of svg

The fonts have been replaced by outlines.

answered Feb 2, 2013 at 22:53
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.