Skip to content

Support loading nested embedded images - #958

Merged
LaurenzV merged 2 commits into
mainfrom
embededd_svg
Sep 23, 2025
Merged

LaurenzV merged 2 commits into
mainfrom
embededd_svg

Conversation

@LaurenzV

Copy link
Copy Markdown
Collaborator

@RazrFalcon not sure if that's how you envisioned it, I'm not sure we can easily built a recursion limit for nested SVGs into this without changing the callback API.

@RazrFalcon

Copy link
Copy Markdown
Collaborator

Yes, that's was my proposal.

Not sure about recursion. Can we even trigger it? Afaiu, it's not possible. We're not opening files. We cannot reference other files either. All it does is parses an embedded SVG data.
Should be fine then?

@LaurenzV

Copy link
Copy Markdown
Collaborator Author

Yeah, I don't think it should be possible to recurse here. Just create arbitrarily deep nestings, but I guess that's always possible...

@LaurenzV LaurenzV linked an issue Sep 23, 2025 that may be closed by this pull request
@LaurenzV

Copy link
Copy Markdown
Collaborator Author

Will merge this then.

@LaurenzV
LaurenzV merged commit 93605df into main Sep 23, 2025
@LaurenzV
LaurenzV deleted the embededd_svg branch September 23, 2025 19:51
iskhakovt added a commit to iskhakovt/spreadsheet that referenced this pull request May 3, 2026
…128)

* fix(web): inline og:image background so resvg-js actually renders it

The OG PNGs were rendering fully transparent everywhere outside the
white card. Root cause: the outer SVG referenced the background pattern
via `<image href="./og-bg.svg">`, and resvg-js's `resolveImage` only
accepts PNG/JPEG/GIF magic bytes — it rejects SVG bytes as
`UnsupportedImage` and the area silently rasterizes to (0,0,0,0). The
upstream resvg crate fixed nested embedded images in 0.46
(linebender/resvg#958), but resvg-js is still pinned to 0.34 and the
bump PRs (#379, #293) have been sitting open.

Inline the background rects directly into og-image.svg and
og-invite.svg, delete og-bg.svg, and drop the now-unused
imagesToResolve loop from the rasterize plugin. Two static cards, ~50
lines of decorative tiles — duplication cost is bounded and the diff
is readable end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(web): render og:image text at the requested font weight

Empirical check: rendering the same SVG with font-weight 100, 300, 400,
500, 700, 900 and only Lexend.ttf (variable) registered produces six
byte-for-byte identical PNGs. resvg-js / usvg 0.34 doesn't honor the
wght axis on variable fonts — every weight collapses to the file's
default (Regular 400). So 'Spreadsheet' / 'Your turn' at weight 700
were silently rendering at 400, and the 'SPREADSHEET' kerning row at
500 likewise.

Replace the variable Lexend.ttf with three static instances (Regular
400 / Medium 500 / Bold 700) generated via fontTools.varLib.instancer
with updateFontNames=True so the name table distinguishes the three
faces. Register all three in the rasterize plugin; resvg's font
matcher picks the right face per font-weight in the SVG. Confirmed by
re-running the same probe — weights 400, 500, 700 now produce three
distinct byte streams.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
simartin added a commit to simartin/servo that referenced this pull request May 6, 2026
Since I have a pending patch in resvg to fix issue servo#41273, I figured
it'd be useful to update to using the latest version, which this patch
does.

As a bonus, we can get rid of 3 known failures:
   - /css/filter-effects/svg-feoffset-001.html
   - /svg/embedded/image-embedding-nesteder-data-url.html
   - /svg/pservers/reftests/radialgradient-basic-002.svg

that I believe were respectively fixed by:
   - linebender/resvg#953
   - linebender/resvg#958
   - linebender/resvg#1014

Testing: 3 known-to-fail tests now pass, and the rest in untouched
Signed-off-by: Simon Martin <[email protected]>
simartin added a commit to simartin/servo that referenced this pull request May 9, 2026
Since I have a pending patch in resvg to fix issue servo#41273, I figured
it'd be useful to update to using the latest version, which this patch
does.

As a bonus, we can get rid of 3 known failures:
   - /css/filter-effects/svg-feoffset-001.html
   - /svg/embedded/image-embedding-nesteder-data-url.html
   - /svg/pservers/reftests/radialgradient-basic-002.svg

that I believe were respectively fixed by:
   - linebender/resvg#953
   - linebender/resvg#958
   - linebender/resvg#1014

Testing: 3 known-to-fail tests now pass, and the rest in untouched
Signed-off-by: Simon Martin <[email protected]>
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.

Embedded PNG image in external SVG file is not displayed

2 participants