feat(images): add SVG source format with local rasterization via resvg - #13
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for fetching SVG from Figma API and rasterizing locally using the resvg library (v0.45.1) for higher quality image output. The implementation integrates resvg as a pre-built universal binary for macOS and static library for Linux, with support for both iOS (PNG output) and Android (WebP output) platforms.
Key Changes
- Integrated resvg v0.45.1 with Swift C API bindings (CResvg module) and Swift wrapper (SvgRasterizer)
- Added
sourceFormat: svgconfiguration option enabling SVG download from Figma with local rasterization instead of server-side PNG rendering - Created platform-specific converters (SvgToPngConverter for iOS, SvgToWebpConverter for Android) with native encoding support
- Updated build configuration with multiple rpath settings for different build scenarios and CI/CD workflow to build resvg for Linux
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
Sources/Resvg/SvgRasterizer.swift |
Swift wrapper for resvg C API providing SVG to RGBA rasterization with scaling support |
Sources/Resvg/ResvgError.swift |
Error types mapping resvg C error codes to Swift errors with descriptive messages |
Sources/ExFig/Output/SvgToPngConverter.swift |
Converts SVG to PNG for iOS using SvgRasterizer and NativePngEncoder |
Sources/ExFig/Output/SvgToWebpConverter.swift |
Converts SVG to WebP for Android with configurable lossy/lossless encoding |
Sources/ExFig/Output/NativePngEncoder.swift |
Cross-platform PNG encoder using CoreGraphics (macOS/iOS) or libpng (Linux) |
Sources/ExFig/Subcommands/ExportImages.swift |
Adds iOS and Android SVG source export flows with local rasterization at multiple scales |
Sources/ExFig/Loaders/ImagesLoader.swift |
Extends loader configuration to support SVG source format selection |
Sources/XcodeExport/XcodeImagesExporter.swift |
Adds method to export Swift extensions separately from asset catalogs |
Sources/ExFig/Input/Params.swift |
Adds SourceFormat enum and sourceFormat properties to images configuration |
Sources/CResvg/include/resvg.h |
C API header for resvg v0.45.1 library |
Sources/CResvg/module.modulemap |
Module map for CResvg C bindings |
Sources/CResvg/shim.c |
Empty shim file for SPM build system |
Package.swift |
Adds CResvg and Resvg targets with linker settings for macOS dylib and Linux static lib |
mise.toml |
Updates test tasks to copy libresvg.dylib to build directory for test bundle rpath |
.github/workflows/release.yml |
Adds Rust installation and resvg build steps for Linux, includes dylib in macOS archive |
CLAUDE.md |
Documents SVG source format feature with configuration examples and architecture |
Tests/ExFigTests/SvgRasterizerTests.swift |
Unit tests for SvgRasterizer covering basic rasterization, scaling, and error cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Dark variants must share the same .imageset directory as their light counterparts. Also fix URL construction using fileURLWithPath instead of URL(string:) to handle filenames properly.
alexey1312
force-pushed
the
alexey1312/libresvg
branch
from
December 19, 2025 05:37
66c946b to
c1fcbf8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds support for fetching SVG from Figma API and rasterizing locally using resvg library for higher quality image output. Supports iOS (PNG) and Android (WebP) with configurable scales.
sourceFormat: svgconfig option for imagesTest Plan
sourceFormat: svgfor iOSsourceFormat: svgfor Android