Skip to content

Add support for SVG covers#751

Merged
mickael-menu merged 18 commits intoreadium:developfrom
grighakobian:feature/svg-cover-support
Apr 2, 2026
Merged

Add support for SVG covers#751
mickael-menu merged 18 commits intoreadium:developfrom
grighakobian:feature/svg-cover-support

Conversation

@grighakobian
Copy link
Copy Markdown
Contributor

Summary

This pull request addresses the SVG covers are not supported issue.

Known limitation

The SVG rendering uses CGSVGDocument CoreGraphics functions loaded dynamically via dlsym. While these are stable since iOS 13 and widely used, they are not part of the public API. A future iteration could replace this with a third-party SVG parsing library (e.g. SVGKit) or a WebKit snapshot approach for full public API compliance.

Copy link
Copy Markdown
Member

@mickael-menu mickael-menu left a comment

Choose a reason for hiding this comment

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

Thank you @grighakobian! Using CoreSVG is smart, I was going to implement it with WebKit. It's a private API but it seems reasonable:
https://github.com/SDWebImage/SDWebImageSVGCoder?tab=readme-ov-file#note-for-coresvg-framework

Copy link
Copy Markdown

Copilot AI left a comment

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 SVG cover support to the publication cover pipeline by rendering SVG resources into UIImage, and extends the default cover selection logic to consider SVG links in the manifest (including reading order and alternates). It also introduces fixture data and tests to validate SVG cover behavior.

Changes:

  • Add UIImage.fromSVG(_:maxSize:) to render SVG data into a bitmap using dynamically-loaded CoreGraphics SVG symbols.
  • Update ResourceCoverService to load SVG covers (explicit .cover, reading order, alternates) and support sizing via coverFitting(maxSize:).
  • Add SVG cover fixtures and extend cover service test coverage for SVG scenarios.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
Sources/Shared/Toolkit/Extensions/UIImage.swift Adds SVG-to-bitmap rendering helper used by cover loading.
Sources/Shared/Publication/Services/Cover/ResourceCoverService.swift Extends cover selection/loading to support SVG and size-aware loading.
Tests/SharedTests/Publication/Services/Cover/CoverServiceTests.swift Adds tests validating SVG cover selection and scaling behavior.
Tests/SharedTests/Fixtures/Publication/Services/cover-svg.svg Adds an SVG fixture used by new tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@mickael-menu mickael-menu left a comment

Choose a reason for hiding this comment

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

Thanks a lot @grighakobian!

@mickael-menu mickael-menu merged commit 73bdd5d into readium:develop Apr 2, 2026
4 checks passed
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.

SVG covers are not supported

3 participants