Text in nested SVG groups not rendered correctly
Author: SmBe19Created Sep 11, 2026Updated Sep 13, 2026
Labelsbugsvgupstream
Description
When compiling a document with an SVG image which contains text in nested groups, the text is offset vertically.
Minimal example to reproduce
minimal.typ:
#image("minimal.svg")
minimal.svg:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" role="img">
<g font-family="Inter,Arial,sans-serif" font-size="24" font-weight="800" text-anchor="middle" dominant-baseline="central">
<g>
<circle cx="50" cy="50" r="31" fill="#2563eb"/>
<text x="50" y="50" fill="white">A</text>
</g>
</g>
</svg>
When viewing the SVG in an image viewer, the letter 'A' is centered in the circle. This also works correctly in the preview in Tinymist in VSCode. When compiling the document with typst compile minimal.typ, the letter 'A' is offset vertically towards the top.
Operating system
Linux
Typst version
- I am using the latest version of Typst
Source: typst/typst