Skip to content

Load SVG images, rasterized at a scale - #60

Merged
jdolan merged 4 commits into
mainfrom
svg-images
Sep 7, 2026
Merged

Load SVG images, rasterized at a scale#60
jdolan merged 4 commits into
mainfrom
svg-images

Conversation

@jdolan

@jdolan jdolan commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Two commits:

  1. Fix main: the squash of Add text-transform to Text #59 dropped the for loop's closing brace in applyTransform, so main does not compile. Restored.
  2. SVG images: Image recognizes SVG by declared type or by sniffing (IMG_isSVG) and rasterizes it through SDL_image's bundled nanosvg. Image::imageWithSVG / initWithSVG take a scale (pixels per point, e.g. the window's pixel density) so a vector asset drawn into a frame of its intrinsic size stays sharp on a high density display. Image::scale records it and Image::size reports points, so ImageView::setImage sizing is unaffected. Raster images keep a scale of 1. Plain imageWithBytes/resources load SVG at scale 1.

Tests: Tests/ObjectivelyMVC/Image.c covers intrinsic load, 2x rasterization with point-sized size, raster scale, and a garbage document failing. Added to the autotools suite only, matching the Text tests.

Motivation: Quetoo is re-authoring its HUD item icons as SVG (jdolan/quetoo#1026).

🤖 Generated with Claude Code

jdolan and others added 2 commits September 6, 2026 16:48
The squash of #59 lost the for loop's closing brace, so main did not compile.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Image recognizes SVG by declared type or by sniffing and rasterizes it through SDL_image's
nanosvg. Image::imageWithSVG and initWithSVG take a scale, pixels per point such as the
window's pixel density, so a vector asset drawn into a frame of its intrinsic size stays
sharp on a high density display; Image::scale records it and Image::size reports points, so
views sized to an image are unaffected. Raster images keep a scale of 1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 6, 2026 20:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A generated libtool wrapper script with a hard-coded developer-local path is committed, and the new public initWithSVG input validation relies on assert rather than runtime error handling.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR restores a missing brace in Text::applyTransform to fix compilation, and adds SVG image loading with rasterization at a caller-provided scale so vector assets remain sharp on high-DPI displays while Image::size continues to report point sizes for layout.

Changes:

  • Fix Text.c compilation by restoring a dropped closing brace in applyTransform.
  • Add SVG recognition (declared type or sniffing) and scaled rasterization via new Image::imageWithSVG / initWithSVG, plus Image::scale and point-based Image::size.
  • Add an Image test case to the autotools test suite covering intrinsic SVG load, scaled rasterization, and failure on invalid SVG input.
File summaries
File Description
Tests/ObjectivelyMVC/Makefile.am Adds the new Image test to the autotools TESTS list.
Tests/ObjectivelyMVC/Image.c New Check-based tests for SVG loading/rasterization behavior and scale semantics.
Tests/ObjectivelyMVC/Image Newly added libtool wrapper script (appears to be a generated build artifact).
Sources/ObjectivelyMVC/Text.c Restores missing closing brace in applyTransform loop.
Sources/ObjectivelyMVC/Image.h Documents SVG scaling behavior; adds scale field and SVG-loading API declarations.
Sources/ObjectivelyMVC/Image.c Implements SVG sniffing, rasterization helpers, scale tracking, and point-sized size().
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Sources/ObjectivelyMVC/Image.c Outdated
Comment thread Tests/ObjectivelyMVC/Image Outdated
Comment thread Sources/ObjectivelyMVC/Image.c
@jdolan
jdolan merged commit 945a793 into main Sep 7, 2026
1 of 3 checks passed
@jdolan
jdolan deleted the svg-images branch September 7, 2026 00:14
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