Forum Bugs

SVG rendering differences with -i html and -i xml

Investigating the output of MathJax SVG I saw a strange behaviour. If I render the same document with -i html and -i xml the output looks quite different. In the case of -i html it looks like there is an outline applied to every glyph (an SVG <path>) in an equation, which makes it hard to impossible to read the equation at normal zoom levels. This is very prominent in the Preview app of OS X, but also visible, for example, in the PDF viewer of Firefox. In both viewers, if you zoom into the document, it seems that the outline gets thinner and thinner.

I'm not sure if this is really a bug, but in my opinion the rendering of SVG should be independent from -i since not all documents can be rendered with -i xml. I have to say that I'd really prefer the output generated -i xml.

The PDFs were created with the latest alpha build for OS X.
  1. SVG_with_-i_html.pdf20.3 kB
  2. SVG_with_-i_xml.pdf20.3 kB
  3. Test.html7.2 kB
There are several things going on here. Firstly there is a bug in Prince, where it is stroking the path even though you have specified stroke-width="0". You can workaround this by explicitly adding stroke="none", or even doing it with CSS like this:
path[stroke-width="0"] { stroke: none }

Secondly, your <svg> element is not in the SVG namespace, which is why it behaves differently in XML. You need to add xmlns="" to your <svg> element to make it work. This isn't necessary in HTML, which has special rules to recognise SVG elements and infer the namespace.

We will fix the stroke bug in the next release of Prince, thanks for letting us know! :)
OK, thanks!

Adding the namespace alone didn't help with -i html, but with the CSS it works.
Right it's not needed for the HTML, as HTML has rules to automatically add it when it sees <svg>. HTML wants everything to be easy and just work, while XML expects the author to get everything right. :)
We have now released Prince 10, which includes a fix for the SVG stroke-width="0" issue. Thanks again for letting us know!
Yes, it works, thanks very much ! :-)