Scalable Vector Graphics (SVG)

Views supports Scalable Vector Graphics (SVG). SVG is an XML-based vector image format for defining two-dimensional graphics.

Currently supported SVG features listed below:

  • Basic Shapes

  • Basic transformations

  • Units

  • Solid colors filling and stroking

  • Linear gradient

  • Radial gradient

  • Pattern

  • Mask

  • Clip path

  • Style sheet

  • Basic Image support

  • Basic Text support

Packaging

SVG core library (ilvsvgcore) and SVG bitmap streamer (ilvsvg).

API

Current SVG API:

  • IlvSVGStreamer class (ilviews/bitmaps/svg.h)

  • IlvSVGImporter class (ilviews/svg/IlvSVGImporter.h)

SVG Renderer

ilsvg library provides IlvSVGStreamer class for rendering SVG images so that SVG images can be used in the same way as PNGs or JPGs in Views applications.

SVG images used in scaling contexts, for example IlvZoomableTransparentIcon or CSS background), are rendered without loss of quality.

ilvsvg library depends on Cairo rendering library on Linux and GDI+ rendering library on Windows.

SVG Importer

ilsvgcore library provides IlvSVGImporter class for importing SVG shapes to Views graphics objects. The table below describes importing rules:

SVG element stroke fill
<rect> IlvRectangle IlvFilledRectangle
<rect> with round corners IlvRoundRectangle IlvFilledRoundRectangle
<circle> IlvEllipse IlvFilledEllipse
<ellipse> IlvEllipse IlvFilledEllipse
<line> IlvLine  
<polyline> IlvPolyline IlvPolygon
<polygon> IlvPolyline IlvPolygon
<path> IlvSpline/IlvClosedSpline IlvFilledSpline
<text> IlvZoomableLabel  
<image> IlvZoomableTransparentIcon  

 

Note <rect> <circle> and <ellipse> are converted to a path if they cannot be represented as the corresponding graphical Views elements (for example, the rotation transformation was applied to SVG elements).

Imported Views elements are grouped in an IlvGraphicSet if the SVG element is a complex path or SVG element has both a stroke and a fill.

Limitation

The ilvsvg library is shipped only in shared library mode (dll_mda on Windows and shared on Linux).

Sample application

Refer to the SVG sample application in $ILVHOME/samples/foundation/svg

Security notes

Views SVG lib has checks to prevent freezes (endless loops) and stack overflows caused due to recursion.

However, as processing SVG files can involve interpreting user-supplied code, it is recommended to use only trusted SVG files as input.