Skip to content
forked from sammycage/lunasvg

lunasvg is a standalone SVG rendering library in C++

License

Notifications You must be signed in to change notification settings

mensong/lunasvg

 
 

Repository files navigation

Releases License Build Status

LunaSVG

LunaSVG is an SVG rendering library in C++, designed to be lightweight and portable, offering efficient rendering and manipulation of Scalable Vector Graphics (SVG) files.

Basic Usage

#include <lunasvg.h>

using namespace lunasvg;

int main()
{
    auto document = Document::loadFromFile("tiger.svg");
    if(document == nullptr)
        return -1;
    auto bitmap = document->renderToBitmap();
    if(bitmap.isNull())
        return -1;
    bitmap.writeToPng("tiger.png");
    return 0;
}

tiger.png

Features

LunaSVG supports nearly all graphical features outlined in the SVG 1.1 and SVG 1.2 Tiny specifications. The primary exceptions are animation, filters, and scripts. As LunaSVG is designed for static rendering, animation is unlikely to be supported in the future. However, support for filters may be added. It currently handles a wide variety of elements, including:

<a> <circle> <clipPath> <defs> <ellipse> <g> <image> <line> <linearGradient> <marker> <mask> <path> <pattern> <polygon> <polyline> <radialGradient> <rect> <stop> <style> <svg> <symbol> <text> <tspan> <use>

Installation

Follow the steps below to install LunaSVG using either Meson or CMake.

Using Meson

git clone https://github.com/sammycage/lunasvg.git
cd lunasvg
meson setup build
meson compile -C build
meson install -C build

Using CMake

git clone https://github.com/sammycage/lunasvg.git
cd lunasvg
cmake -B build .
cmake --build build
cmake --install build

Demo

LunaSVG provides a command-line tool svg2png for converting SVG files to PNG format.

Usage:

svg2png [filename] [resolution] [bgColor]

Examples:

$ svg2png input.svg
$ svg2png input.svg 512x512
$ svg2png input.svg 512x512 0xff00ffff

Projects Using LunaSVG

About

lunasvg is a standalone SVG rendering library in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.2%
  • CMake 1.2%
  • Meson 0.6%