Repository navigation
Open
Description
Description
I'm trying to generate SVG pages that include dot-generated SVG images and embed them into a PDF document.
To generate an SVG page, I do:
#set page(width: auto, height: auto)
#set text(font: "GOST 2.304")
#image("node.svg")node.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.2.1 (0)
-->
<!-- Title: pros_graph Pages: 1 -->
<svg width="74pt" height="44pt"
viewBox="0.00 0.00 73.59 44.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 40)">
<title>pros_graph</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-40 69.59,-40 69.59,4 -4,4"/>
<!-- editor -->
<g id="node1" class="node">
<title>editor</title>
<ellipse fill="none" stroke="black" cx="32.79" cy="-18" rx="32.79" ry="18"/>
<text text-anchor="middle" x="32.79" y="-13.32" font-family="GOST 2.304" font-style="italic" font-size="14.00">Text</text>
</g>
</g>
</svg>This gives me svg.svg.
svg.svg
<svg class="typst-doc" viewBox="0 0 215.7322815572183 185.73228441824125" width="215.7322815572183pt" height="185.73228441824125pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:h5="http://www.w3.org/1999/xhtml">
<path class="typst-shape" fill="#ffffff" fill-rule="nonzero" d="M 0 0 L 0 185.73228 L 215.73228 185.73228 L 215.73228 0 Z "/>
<g>
<g transform="translate(70.86614173228347 70.86614173228347)">
<image xlink:href="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIKICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPgo8IS0tIEdlbmVyYXRlZCBieSBncmFwaHZpeiB2ZXJzaW9uIDEyLjIuMSAoMCkKIC0tPgo8IS0tIFRpdGxlOiBwcm9zX2dyYXBoIFBhZ2VzOiAxIC0tPgo8c3ZnIHdpZHRoPSI3NHB0IiBoZWlnaHQ9IjQ0cHQiCiB2aWV3Qm94PSIwLjAwIDAuMDAgNzMuNTkgNDQuMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgo8ZyBpZD0iZ3JhcGgwIiBjbGFzcz0iZ3JhcGgiIHRyYW5zZm9ybT0ic2NhbGUoMSAxKSByb3RhdGUoMCkgdHJhbnNsYXRlKDQgNDApIj4KPHRpdGxlPnByb3NfZ3JhcGg8L3RpdGxlPgo8cG9seWdvbiBmaWxsPSJ3aGl0ZSIgc3Ryb2tlPSJub25lIiBwb2ludHM9Ii00LDQgLTQsLTQwIDY5LjU5LC00MCA2OS41OSw0IC00LDQiLz4KPCEtLSBlZGl0b3IgLS0+CjxnIGlkPSJub2RlMSIgY2xhc3M9Im5vZGUiPgo8dGl0bGU+ZWRpdG9yPC90aXRsZT4KPGVsbGlwc2UgZmlsbD0ibm9uZSIgc3Ryb2tlPSJibGFjayIgY3g9IjMyLjc5IiBjeT0iLTE4IiByeD0iMzIuNzkiIHJ5PSIxOCIvPgo8dGV4dCB0ZXh0LWFuY2hvcj0ibWlkZGxlIiB4PSIzMi43OSIgeT0iLTEzLjMyIiBmb250LWZhbWlseT0iR09TVCAyLjMwNCIgZm9udC1zdHlsZT0iaXRhbGljIiBmb250LXNpemU9IjE0LjAwIj5UZXh0PC90ZXh0Pgo8L2c+CjwvZz4KPC9zdmc+Cg==" width="73.99999809265137" height="44.000000953674316" preserveAspectRatio="none"/>
</g>
</g>
</svg>To generate a PDF document, I do:
#set document(date: none)
#set page(width: auto, height: auto)
#set text(font: "GOST 2.304")
#image("svg.svg")But it only renders an ellipse, completely ignoring any text.
Reproduction URL
No response
Operating system
Linux
Typst version
- I am using the latest version of Typst
Reacted by Andrew Voynov

Activity
[-]No text is rendered in PDF that inclues SVG with text exported via Typst[/-][+]No text is rendered in PDF that includes SVG with text exported via Typst[/+]Andrew15-5 commentedon Mar 10, 2025
As a workaround, I'm forced to export in PNG that gives out huge page files (+12.41 MiB, compared to all SVG files), resulting in a huge PDF document (+6.35 MiB).
LaurenzV commentedon Mar 10, 2025
I haven't looked into it, I suspect it's similar to linebender/resvg#740, where Typst only loads fonts if it actually detects a text node, but it doesn't check nested SVGs recursively... Just a guess, though.
Andrew15-5 commentedon Mar 10, 2025
I guess it's similar to #4901, but instead of
image/pngit'simage/svg+xml. Though I have no idea what is actually happening.Andrew15-5 commentedon May 19, 2025
I've noticed that the
svg.svgor any SVG in Typst SVG has the<image src="data:image/svg+xml;base64,..."/>, but outside browser it renders that thing as raster image, despite it being SVG. Is this bug or something that SVG viewer software must implement to render it as vector graphics? Botheogandinkscaperender it as raster image.If Typst were to not use
imagebut instead directly embed the image without encoding, then this issue will disappear. There shouldn't be a problem since #6051 is fixed, right? The nested level is either infinite or much higher than those 2 images combined.