SVG support notes

Coordinate range

Note: To configure Vega to use fixedpoint you need to edit modules/libvega/vegaconfig.h and disable the define VEGA_USE_FLOATS. The comments below only apply to the SVG module.

TWEAK_SVG_DOUBLE_PRECISION_ARITHMETICS = NO

This is the default. It means we use float precision for calculations in the SVG module.

TWEAK_SVG_DOUBLE_PRECISION_ARITHMETICS = YES

This means that we use double precision for calculations in the SVG module.

Events

There is support for listening to any event in the svg module. Some events are not sent by core, for example: activate.

SVG 1.1 doesn't specify a key-event set, and thus the attributes onkeyup, onkeydown and onkeypress don't register a corresponding event listener for those events. Note that the Adobe viewer handles the onkey*-attributes. In Opera it's possible to install listeners for key-events with DOM, for example: element.addEventListener('keydown', keyhandler-function, false).

If key-events are used it's vital to use evt.preventDefault() to prevent any key-event that should be handled only by the script from escaping upwards to the UI which may be listening for shortcut keys. Note that Opera has many single-key shortcuts.

Font selection

Specifying more than one font for fallback purposes is supported, but it should be noted that the font will be chosen at the time it's needed, and the context is lost soon after, which means that a fallback font may not be used if unsupported glyphs are encountered. The list of fallback fonts will be gone through and the first matching font will be chosen when entering a text element. However, Opera will switch the font if it finds glyphs it can't render with the current one, but in doing so it doesn't take into account the specified fallback fonts.

Example:

<text font-family="MySVGFont1, MySVGFont2">ABC</text>
MySVGFont1 only has the glyph 'A' and MySVGFont2 has the glyphs 'B' and 'C'. The SVG engine picks MySVGFont1 and starts drawing text, then encounters 'BC' and those are either drawn using the missing-glyph or by switching to another font. If the font is switched then MySVGFont2 won't be the chosen one, but rather a platform-defined suitable fallback.

Integration

Type of SVG inclusion Requirement(s)
In html:object element FEATURE_SVG = YES
In html:iframe element FEATURE_SVG = YES
In html:embed element FEATURE_SVG_IN_EMBED_ELEMENT = YES
In html:img element FEATURE_SVG_IN_IMG_ELEMENT = YES
In CSS background-image and list-style-image FEATURE_SVG_IN_CSS_BACKGROUND = YES

Interoperability

Some content may fail to render if sent with the wrong mime-type, or if the namespace declarations are missing. The correct mime-type for svg is image/svg+xml. The namespaces to open are svg: http://www.w3.org/2000/svg and xlink: http://www.w3.org/1999/xlink.

For CSS it should be noted that you must specify length values with units. For example:
font-size: 12; in CSS will mean the value is invalid, and thus it will be ignored. This applies to all 'style' elements, 'style' attributes and external stylesheets.

The Adobe getter/setter DOM extensions are not supported. Example: evt.getTarget() is evt.target in Opera.

Performance

We have based our implementation on our vector library Vega, which is the same for all platforms. This means we get the same functionality on all platforms, and that some performance bottlenecks are the same too. Things that are relatively expensive to use, performance-wise:

This is not meant to discourage you to use the functionality, but rather to make it known that your content may render in a way that may feel suboptimal if viewed on a computer that is less powerful than your own. Animating filters is possible, but computationally intensive for example.

Printing

SVG is output as a bitmap image to the printer. It's not sent in vector format, which means that the resulting output is not as crisp as it could have been.