Skip to content

feat(images): add SVG source format with local rasterization via resvg - #13

Merged
alexey1312 merged 6 commits into
mainfrom
alexey1312/libresvg
Dec 19, 2025
Merged

feat(images): add SVG source format with local rasterization via resvg#13
alexey1312 merged 6 commits into
mainfrom
alexey1312/libresvg

Conversation

@alexey1312

Copy link
Copy Markdown
Collaborator

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.

  • Integrate resvg v0.45.1 as pre-built universal binary (arm64 + x86_64)
  • Add sourceFormat: svg config option for images
  • Create SvgRasterizer Swift wrapper for resvg C API
  • Add SvgToPngConverter (iOS) and SvgToWebpConverter (Android)
  • Update release workflow to build resvg for Linux and include dylib in macOS archive
  • Add SvgRasterizerTests (5 tests)

Test Plan

  • Unit tests for SvgRasterizer (5 tests pass)
  • Manual test: export images with sourceFormat: svg for iOS
  • Manual test: export images with sourceFormat: svg for Android

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: svg configuration 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.

Comment thread Sources/Resvg/SvgRasterizer.swift
Comment thread Sources/ExFig/Subcommands/ExportImages.swift
Comment thread Sources/ExFig/Subcommands/ExportImages.swift
Comment thread Sources/ExFig/Subcommands/ExportImages.swift Outdated
Comment thread Sources/ExFig/Subcommands/ExportImages.swift
alexey1312 and others added 2 commits December 19, 2025 01:02
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
alexey1312 merged commit 9541871 into main Dec 19, 2025
3 checks passed
@alexey1312
alexey1312 deleted the alexey1312/libresvg branch December 19, 2025 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants