Add support for SVG covers#751
Conversation
7da8ea9 to
fe70317
Compare
mickael-menu
left a comment
There was a problem hiding this comment.
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
Sources/Shared/Publication/Services/Cover/ResourceCoverService.swift
Outdated
Show resolved
Hide resolved
Sources/Shared/Publication/Services/Cover/ResourceCoverService.swift
Outdated
Show resolved
Hide resolved
5c03f5d to
53e50ec
Compare
There was a problem hiding this comment.
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
ResourceCoverServiceto load SVG covers (explicit.cover, reading order, alternates) and support sizing viacoverFitting(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.
Sources/Shared/Publication/Services/Cover/ResourceCoverService.swift
Outdated
Show resolved
Hide resolved
d708226 to
b902fe4
Compare
…wift-toolkit into feature/svg-cover-support
mickael-menu
left a comment
There was a problem hiding this comment.
Thanks a lot @grighakobian!
Summary
This pull request addresses the SVG covers are not supported issue.
Known limitation
The
SVGrendering usesCGSVGDocumentCoreGraphicsfunctions loaded dynamically viadlsym. 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-partySVGparsing library (e.g.SVGKit) or aWebKitsnapshot approach for full public API compliance.