I've landed my SVG 2 Fallback code that allows drawing using SVG 2 features to be displayed by browsers that only support SVG 1.1. Fallbacks come in three flavors: The first exports SVG 2 to SVG 1.1. The second adds SVG 1.1 attributes. The third uses JavaScript polyfills to supply missing functionality.

Exporting to SVG 1.1

So far the code handles export to SVG 1.1 of two SVG 2 features, both related to markers. These features are not used in the Inkscape interface yet but I intend to redo the canned markers to take advantage of them. The features are:

  • The 'auto-start-reverse' value of the marker 'orient' property. This value automatically rotates the marker 180 degrees at the start of a path. This means, for example, that a document needs to store just one marker to handle a path with arrowheads on both ends. (This is actually one of the few SVG 2 features supported by browsers, so in practice this fallback should not be widely needed.) 
  • The 'fill' and 'stroke' property values 'context-fill' and 'context-stroke'. These values allow a marker's fill to be automatically set to the stroke color of the path the marker is attached to. Inkscape currently attempts to do this automatically but the code is more of a hack, doesn't always works, and results in needing to store a copy of the marker for each color used.

SVG 2 Text Fallback

SVG 2 auto-wrapped text can include attributes that allows it to be rendered by an SVG 1.1 renderer (a vast improvement over the SVG 1.2 text wrapping Inkscape has used in the past). This works by breaking the text into pieces, each with its own 'x' and 'y' coordinate. An SVG 2 renderer will ignore these coordinates while an SVG 1.1 renderer will use them. The SVG 1.1 rendering may not look as good, especially if the particular font used in laying out the text is missing but it does mean that the content will be visible to the user.

The latest version of trunk now allows one to create SVG 2 text. That will be the topic of another post.

Polyfills

Inkscape includes the ability to insert a polyfill to render mesh gradients. So far only bilinear meshes on fills is supported but I hope to improve the support to strokes and bicubic meshes before Inkscape 1.0 is out the door.

Usage

Use of the fallbacks is controlled by options on the SVG Export tab (under Input/Output) of the Inkscape Preferences dialog. Exporting from SVG 2 to SVG 1.1 will only occur when using the Save As dialog and if the option "Export as SVG 1.1 per settings in Preferences Dialog" is checked. This is do to the lossiness of the conversion. Adding SVG 1.1 text fallback and the mesh gradient polyfill will happen on saving a file (if the options are enabled). 

Future Work

I've got lots of things in my queue. I'm keeping the list on my Inkscape Wiki page.

Thanks for your support! And happy holidays!