MS RFC 73: Improved SVG symbols support

Authors:Zak James (zjames at
Authors:Yewondwossen Assefa (yassefa at
Last Edited:2011/05/19
Version:MapServer 6.2


The SVG format offers several advantages over existing mapserver symbol types but existing support is limited. We propose the implementation of complete support using the libsvg-cairo library, part of the cairo project.

Technical Solution

All renderers will be extended with an added supports_svg flag, set to 0 for all but the cairo renderer. When an SVG symbol is requested, other renderers will trigger a call to msRenderSVGToPixmap which will parse the referenced svg file (using libsvg-cairo) and render the svg into the symbol’s pixmapbuffer using cairo. After this operation, normal pixmap symbol handling will be used.

For the cairo renderer, the renderSVGSymbolCairo function will use libsvg-cairo to parse the symbol, but will then use the cairo api to render the symbol directly. will be modified to detect the –with-libsvg-cairo configure option and define USE_LIBSVG_CAIRO.

Existing Partial Implementation

If this rfc is adopted the existing SVG symbol code (see would be superceeded and would be removed.

The proposed implementation will reuse the existing changes to the parser but the approach for reading and rendering the symbols would be different. It will use an existing SVG parser which includes a more complete SVG implementation and will pass through the SVG instructions directly in the case of a cairo (pdf or postscript) outputformat to improve quality. Additionally, this version will pre-scale and rotate the SVG before rasterizing with agg to avoid bitmap artifacts.

Usage example

  NAME "svgsymbol"
  IMAGE "/path/to/symbol.svg"

... once defined, the symbol is used within the mapfile like any other.

Backwards Compatibility Issues

There are no compatibility issues with existing mapfiles. The SVG symbol type is already allowed within a SYMBOLSET. SVG Symbol support will be disabled by default. Enabling it will require installation of the libsvg-cairo library available from *

Affected Files

  • mapserver.h
  • mapdraw.c
  • mapdummyrenderer.c
  • maprendering.c
  • mapsymbol.c
  • mapsymbol.h
  • mapcairo.c
  • mapagg.cpp

Voting History

+1 from DanielM, SteveW, ThomasB, SteveL, MichaelS, AssefaY