dillo-browser / dillo

Dillo, a multi-platform graphical web browser
https://dillo-browser.github.io/
GNU General Public License v3.0
548 stars 27 forks source link

Add support for SVG images #70

Closed rodarima closed 2 months ago

rodarima commented 8 months ago

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.

rodarima commented 4 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:

fractal

maxwell

maxwell2

(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.

rodarima commented 2 months ago

Nanosvg doesn't support text or tspan tags either.

rodarima commented 2 months ago

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.