{"id":21764000,"url":"https://github.com/jwmcglynn/donner","last_synced_at":"2026-03-15T18:34:40.986Z","repository":{"id":247299972,"uuid":"161747980","full_name":"jwmcglynn/donner","owner":"jwmcglynn","description":"Donner SVG, a modern C++20 SVG rendering library supporting the latest SVG2 and CSS3 standards","archived":false,"fork":false,"pushed_at":"2025-04-10T07:30:31.000Z","size":32205,"stargazers_count":19,"open_issues_count":15,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T08:32:31.133Z","etag":null,"topics":["cpp","cpp20","css3","svg","svg2"],"latest_commit_sha":null,"homepage":"https://jwmcglynn.github.io/donner/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwmcglynn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-14T07:29:02.000Z","updated_at":"2025-04-04T11:03:13.000Z","dependencies_parsed_at":"2025-04-03T07:32:13.897Z","dependency_job_id":null,"html_url":"https://github.com/jwmcglynn/donner","commit_stats":null,"previous_names":["jwmcglynn/donner"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwmcglynn%2Fdonner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwmcglynn%2Fdonner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwmcglynn%2Fdonner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwmcglynn%2Fdonner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwmcglynn","download_url":"https://codeload.github.com/jwmcglynn/donner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724405,"owners_count":21151557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp20","css3","svg","svg2"],"created_at":"2024-11-26T12:17:08.497Z","updated_at":"2026-03-15T18:34:35.947Z","avatar_url":"https://github.com/jwmcglynn.png","language":"C++","readme":"# Donner SVG, a modern SVG rendering library in C++\n\n[![Build Status](https://github.com/jwmcglynn/donner/actions/workflows/main.yml/badge.svg)](https://github.com/jwmcglynn/donner/actions/workflows/main.yml) [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC) [![Code coverage %](https://codecov.io/gh/jwmcglynn/donner/branch/main/graph/badge.svg?token=Z3YJZNKGU0)](https://codecov.io/gh/jwmcglynn/donner) ![Product lines of code](https://gist.githubusercontent.com/jwmcglynn/91f7f490a72af9c06506c8176729d218/raw/loc.svg) ![Test lines of code](https://gist.githubusercontent.com/jwmcglynn/91f7f490a72af9c06506c8176729d218/raw/loc-tests.svg)\n![Comments %](https://gist.githubusercontent.com/jwmcglynn/91f7f490a72af9c06506c8176729d218/raw/comments.svg)\n\nDonner SVG is an under-development modern C++20 SVG rendering library which provides full access to the SVG DOM, enabling browser-level functionality without the browser.\n\nDonner's v0.1.0 release provides core static SVG functionality (without text or filter support). Text, filter, and animation support are on the roadmap. [Try it out online!](https://jwmcglynn.github.io/donner-editor/)\n\n![Donner splash image](donner_splash.svg)\n\n```cpp\nParseResult\u003cSVGDocument\u003e maybeDocument = SVGParser::ParseSVG(\n    loadFile(\"donner_splash.svg\"));\n\nif (maybeDocument.hasError()) {\n  std::cerr \u003c\u003c \"Parse Error: \" \u003c\u003c maybeDocument.error() \u003c\u003c \"\\n\";\n  std::abort();\n}\n\nRendererSkia renderer;\nrenderer.draw(maybeDocument.result());\n\nconst bool success = renderer.save(\"output.png\");\n```\n\n## Why Donner?\n\n- It's designed to be embeddable, and provides an exception-free API surface\n- For malformed files, it produces detailed parse errors, which includes file/line information\n- Donner provides an extensive and well-documented SVG API surface, which enables inspecting and modifying the SVG in-memory\n- Donner implements the latest standards, SVG2 and CSS3 and aims for high-conformance\n\nDonner supports:\n\n- SVG2 core functionality, such as shapes, fills, strokes, and gradients\n- CSS3 parsing and cascading support, with a hand-rolled library\n- Detailed validation and diagnostics, errors point to the exact location\n- A game-engine-inspired [EnTT](https://github.com/skypjack/entt) ECS-backed document tree, optimized for performance\n- A SVG DOM-style API to traverse, inspect, and modify documents in memory\n- A two-phase renderer, which builds and caches a rendering tree for efficient frame-based rendering\n\nDonner renders with Skia, which provides the same high-quality rendering used by Chromium.\n\n### Limitations\n\n- `\u003ctext\u003e` support is not yet implemented\n\n## Supported Elements\n\n[`\u003ccircle\u003e`](https://jwmcglynn.github.io/donner/xml_circle.html) [`\u003cclipPath\u003e`](https://jwmcglynn.github.io/donner/xml_clipPath.html) [`\u003cdefs\u003e`](https://jwmcglynn.github.io/donner/xml_defs.html) [`\u003cellipse\u003e`](https://jwmcglynn.github.io/donner/xml_ellipse.html) [`\u003cg\u003e`](https://jwmcglynn.github.io/donner/xml_g.html) [`\u003cimage\u003e`](https://jwmcglynn.github.io/donner/group__xml__image.html) [`\u003cline\u003e`](https://jwmcglynn.github.io/donner/xml_line.html) [`\u003clinearGradient\u003e`](https://jwmcglynn.github.io/donner/xml_linearGradient.html) [`\u003cmarker\u003e`](https://jwmcglynn.github.io/donner/xml_marker.html) [`\u003cmask\u003e`](https://jwmcglynn.github.io/donner/xml_mask.html) [`\u003cpath\u003e`](https://jwmcglynn.github.io/donner/xml_path.html) [`\u003cpattern\u003e`](https://jwmcglynn.github.io/donner/xml_pattern.html) [`\u003cpolygon\u003e`](https://jwmcglynn.github.io/donner/xml_polygon.html) [`\u003cpolyline\u003e`](https://jwmcglynn.github.io/donner/xml_polyline.html) [`\u003cradialGradient\u003e`](https://jwmcglynn.github.io/donner/xml_radialGradient.html) [`\u003crect\u003e`](https://jwmcglynn.github.io/donner/xml_rect.html) [`\u003cstop\u003e`](https://jwmcglynn.github.io/donner/xml_stop.html) [`\u003cstyle\u003e`](https://jwmcglynn.github.io/donner/group__xml__style.html) [`\u003csvg\u003e`](https://jwmcglynn.github.io/donner/xml_svg.html) [`\u003csymbol\u003e`](https://jwmcglynn.github.io/donner/xml_symbol.html) [`\u003cuse\u003e`](https://jwmcglynn.github.io/donner/xml_use.html)\n\n**Not yet supported:** `\u003ca\u003e` `\u003cfilter\u003e` `\u003cswitch\u003e` `\u003ctext\u003e` `\u003ctextPath\u003e` `\u003ctspan\u003e`\n\n## Try it out: Render an SVG to PNG\n\n```sh\nbazel run --run_under=\"cd $PWD \u0026\u0026\" //examples:svg_to_png -- donner_splash.svg\n```\n\n[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/jwmcglynn/donner)\n\nHow it works: [svg_to_png.cc](https://jwmcglynn.github.io/donner/svg_to_png_8cc-example.html)\n\n## API Demo\n\n```cpp\n// This is the base SVG we are loading, a simple path containing a line\nconst std::string_view svgContents(R\"(\n  \u003csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"200\" height=\"200\" viewBox=\"0 0 10 10\"\u003e\n    \u003cpath d=\"M 1 1 L 4 5\" stroke=\"blue\" /\u003e\n  \u003c/svg\u003e\n)\");\n\n// Call ParseSVG to load the SVG file\ndonner::ParseResult\u003cdonner::svg::SVGDocument\u003e maybeResult =\n    donner::svg::parser::SVGParser::ParseSVG(svgContents);\n\nif (maybeResult.hasError()) {\n  std::cerr \u003c\u003c \"Parse Error \" \u003c\u003c maybeResult.error() \u003c\u003c \"\\n\";  // Includes line:column and reason\n  std::abort();\n  // - or - handle the error per your project's conventions\n}\n\ndonner::svg::SVGDocument document = std::move(maybeResult.result());\n\n// querySelector supports standard CSS selectors, anything that's valid when defining a CSS rule\n// works here too, for example querySelector(\"svg \u003e path[fill='blue']\") is also valid and will\n// match the same element.\nstd::optional\u003cdonner::svg::SVGElement\u003e maybePath = document.querySelector(\"path\");\nUTILS_RELEASE_ASSERT_MSG(maybePath, \"Failed to find path element\");\n\n// The result of querySelector is a generic SVGElement, but we know it's a path, so we can cast\n// it. If the cast fails, an assertion will be triggered.\ndonner::svg::SVGPathElement path = maybePath-\u003ecast\u003cdonner::svg::SVGPathElement\u003e();\n\nif (std::optional\u003cdonner::svg::PathSpline\u003e spline = path.computedSpline()) {\n  std::cout \u003c\u003c \"Path: \" \u003c\u003c *spline \u003c\u003c \"\\n\";\n  std::cout \u003c\u003c \"Length: \" \u003c\u003c spline-\u003epathLength() \u003c\u003c \" userspace units\\n\";\n} else {\n  std::cout \u003c\u003c \"Path is empty\\n\";\n}\n```\n\nDetailed docs: [svg_tree_interaction.cc](https://jwmcglynn.github.io/donner/svg_tree_interaction_8cc-example.html)\n\n## API Demo 2: Rendering a SVG to PNG\n\n```cpp\nusing namespace donner;\nusing namespace donner::svg;\nusing namespace donner::svg::parser;\n\nstd::ifstream file(\"test.svg\");\nif (!file) {\n  std::cerr \u003c\u003c \"Could not open file\\n\";\n  std::abort();\n}\n\nstd::string fileData;\nfile.seekg(0, std::ios::end);\nconst std::streamsize fileLength = file.tellg();\nfile.seekg(0);\n\nfileData.resize(fileLength);  \nfile.read(fileData.data(), fileLength);\n\nParseResult\u003cSVGDocument\u003e maybeDocument = SVGParser::ParseSVG(fileData);\nif (maybeDocument.hasError()) {\n  std::cerr \u003c\u003c \"Parse Error: \" \u003c\u003c maybeDocument.error() \u003c\u003c \"\\n\";\n  std::abort();\n}\n\nRendererSkia renderer;\nrenderer.draw(maybeDocument.result());\n\nconst bool success = renderer.save(\"output.png\");\n```\n\nDetailed docs: [svg_to_png.cc](https://jwmcglynn.github.io/donner/svg_to_png_8cc-example.html)\n\n## API Demo 3: Interactive SVG Viewer using ImGui\n\n```sh\nbazel run --run_under=\"cd $PWD \u0026\u0026\" //experimental/viewer:svg_viewer -- donner_icon.svg\n```\n\nThis example demonstrates how to create an interactive SVG viewer using ImGui. The viewer allows you to load and display SVG files, and interact with SVG elements using ImGui.\n\nSee the source at: [experimental/viewer/svg_viewer.cc](./experimental/viewer/svg_viewer.cc)\n\n## Documentation\n\n- [Getting started](https://jwmcglynn.github.io/donner/GettingStarted.html)\n- [API Documentation](https://jwmcglynn.github.io/donner/DonnerAPI.html)\n- [System architecture](https://jwmcglynn.github.io/donner/SystemArchitecture.html)\n- [Building Donner](https://jwmcglynn.github.io/donner/BuildingDonner.html)\n- [Examples](https://jwmcglynn.github.io/donner/examples.html)\n\n## Status\n\n- [Project status](https://github.com/jwmcglynn/donner/issues/149)\n- [Build report](docs/build_report.md)\n\n## CMake Support\n\nCMake support is available, but experimental. It is intended for users who want to integrate Donner into their CMake-based projects. The CMake build fetches dependencies and builds the library.\n\nSee the [CMake documentation](https://jwmcglynn.github.io/donner/BuildingDonner.html#cmake-build-experimental) for more details.\n\n## Other Libraries\n\n- C++ | **[LunaSVG](https://github.com/sammycage/lunasvg)**: A lightweight library with an embedded renderer, suitable for embedded applications\n- Rust | **[librsvg](https://gitlab.gnome.org/GNOME/librsvg)**: Provides a simple way to render SVGs one-shot, does not provide a DOM or animation\n- Rust | **[resvg](https://github.com/RazrFalcon/resvg)**: Library that focuses on correctness, safety, and portability for static SVGs\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwmcglynn%2Fdonner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwmcglynn%2Fdonner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwmcglynn%2Fdonner/lists"}