https://github.com/sammycage/plutosvg
Tiny SVG rendering library in C
https://github.com/sammycage/plutosvg
c emoji2png freetype otfsvg plutovg svg svg-hooks svg2png
Last synced: about 1 month ago
JSON representation
Tiny SVG rendering library in C
- Host: GitHub
- URL: https://github.com/sammycage/plutosvg
- Owner: sammycage
- License: mit
- Created: 2020-09-26T10:32:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-06-18T03:44:16.000Z (about 1 year ago)
- Last Synced: 2025-06-18T04:31:41.173Z (about 1 year ago)
- Topics: c, emoji2png, freetype, otfsvg, plutovg, svg, svg-hooks, svg2png
- Language: C
- Homepage:
- Size: 296 KB
- Stars: 334
- Watchers: 11
- Forks: 28
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README

# PlutoSVG
PlutoSVG is a compact and efficient SVG rendering library written in C. It is specifically designed for parsing and rendering SVG documents embedded in OpenType fonts, providing an optimal balance between speed and minimal memory usage. It is also suitable for rendering scalable icons.
## Basic Usage
```c
#include
#include
int main(void)
{
plutosvg_document_t* document = plutosvg_document_load_from_file("camera.svg", -1, -1);
if(document == NULL) {
printf("Unable to load: camera.svg\n");
return -1;
}
plutovg_surface_t* surface = plutosvg_document_render_to_surface(document, NULL, -1, -1, NULL, NULL, NULL);
plutovg_surface_write_to_png(surface, "camera.png");
plutosvg_document_destroy(document);
plutovg_surface_destroy(surface);
return 0;
}
```

## Integrating with FreeType
```c
#include
#include
#include FT_FREETYPE_H
#include FT_MODULE_H
int main(void)
{
FT_Library library;
// Initialize the FreeType library
if(FT_Init_FreeType(&library)) {
// Handle error
return -1;
}
// Set PlutoSVG hooks for the SVG module
if(FT_Property_Set(library, "ot-svg", "svg-hooks", &plutosvg_ft_hooks)) {
// Handle error
return -1;
}
// Your code here
// Clean up
FT_Done_FreeType(library);
return 0;
}
```
## Installation
Follow the steps below to install PlutoSVG using either [Meson](https://mesonbuild.com/) or [CMake](https://cmake.org/).
### Using Meson
```bash
git clone https://github.com/sammycage/plutosvg.git
cd plutosvg
meson setup build
meson compile -C build
meson install -C build
```
### Using CMake
```bash
git clone --recursive https://github.com/sammycage/plutosvg.git
cd plutosvg
cmake -B build .
cmake --build build
cmake --install build
```
### Projects Using PlutoSVG
- [PumpkinOS](https://github.com/migueletto/PumpkinOS)
- [Shell](https://github.com/moudey/Shell)
- [Dear ImGui](https://github.com/ocornut/imgui)
- [SDL_ttf](https://github.com/libsdl-org/SDL_ttf)
- [PCSX2](https://github.com/PCSX2/pcsx2)
- [FastChart](https://github.com/iliaal/fastchart)