Nanosvg

Jul 20, 2023

Simple C++ header-only SVG parser

NanoSVG is a simple stupid single-header-file SVG parse. The output of the parser is a list of cubic bezier shapes.

The library suits well for anything from rendering scalable icons in your editor application to prototyping a game.

NanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request!

The shapes in the SVG images are transformed by the viewBox and converted to specified units. That is, you should get the same looking data as your designed in your favorite app.

NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters.

The units passed to NanoSVG should be one of ‘px’, ‘pt’, ‘pc’ ‘mm’, ‘cm’, or ‘in’. DPI dots-per-inch controls how the unit conversion is done.

If you don’t know or care about the units stuff, “px” and 96 should get you going.



Checkout these related ports:
  • Zphoto - Zooming photo album generator
  • Zint - Barcode generator (library and utilities)
  • Zimg - Image-generator that uses ASCII input files to create PNGs/EDFs
  • Zgv - Graphics viewer for SVGAlib
  • Zbar - ZBar barcode reader
  • Zathura - Customizable lightweight pdf viewer
  • Zathura-ps - PostScript support for Zathura PDF viewer
  • Zathura-pdf-poppler - Poppler render PDF plugin for Zathura PDF viewer
  • Zathura-pdf-mupdf - MuPDF render PDF plugin for Zathura PDF viewer
  • Zathura-djvu - DjVu support for zathura
  • Zathura-cb - Comic book plugin for Zathura PDF viewer
  • Yukon - Real-time capture tool for OpenGL applications
  • Yed - Editor for graphs and diagrams
  • Yafaray - Montecarlo raytracing engine
  • Yacreader - Yet another comic reader