Closed rodarima closed 2 months ago
One of the main good uses of SVG images is to read Wikipedia equations, which are included as a fallback for non-JS browsers. The equations are all rendered with MathJax, which defines all the glyphs using <defs>
and then places each glyph in the proper position using the <use>
tag.
This is problematic, as both libsvgtiny and nanosvg lack support for them and cannot render Wikipedia equations. I tested librsvg and renders properly those equations, but is by far a very large and complex library:
(We also need to avoid rendering the MathML parts of the Wikipedia)
Ideally we should either implement support for defs/use or find another less complicated library that implements it. The size of librsvg is a wopping 3MiB, without dependencies.
Nanosvg doesn't support text or tspan tags either.
Basic support for SVG added in https://github.com/dillo-browser/dillo/pull/211
This is enough to render Wikipedia equations, but it lacks a lot of other SVG features that should be handled by a more elaborate SVG library. The benefit of using nanosvg is that it is builtin into Dillo without dependencies.
In the future we may want to add an support for other libraries, so that they can be enabled at configure time.
Add support for SVG images, as they are becoming more frequent in the web.
We probably should link or embed a SVG library that performs the rastering, but make it optional so it can be disabled on build time.
Some options from #53 :
In other to test that it works fine, we could have a reference page with a image already rendered to PNG or a similar format, and compare the result with the new library rendering the same SVG image.