Description
I have some SVG code, and I want to render as image in Typst, but when I output typ file to SVG, I found SVG in file not vector image.
Minimal reproduction:
#let svg = "<svg fill=\"#239DAD\" role=\"img\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><title>Typst</title><path d=\"M12.654 17.846c0 1.114.16 1.861.479 2.242.32.381.901.572 1.743.572.872 0 1.99-.44 3.356-1.319l.871 1.45C16.547 22.931 14.44 24 12.785 24c-1.656 0-2.964-.395-3.922-1.187-.959-.82-1.438-2.256-1.438-4.307V6.989H5.246l-.349-1.626 2.528-.791V2.418L12.654 0v4.835l5.142-.395-.48 2.857-4.662-.176v10.725Z\"/></svg>"
#image(bytes(svg))
#image("typst.svg")
the actual output in SVG format:
<svg class="typst-doc" viewBox="0 0 595.2755905511812 841.8897637795276" width="595.2755905511812pt" height="841.8897637795276pt" 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 841.8898 L 595.2756 841.8898 L 595.2756 0 Z "/>
<g>
<g transform="translate(70.86614173228347 70.86614173228347)">
<image xlink:href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjMjM5REFEIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+VHlwc3Q8L3RpdGxlPjxwYXRoIGQ9Ik0xMi42NTQgMTcuODQ2YzAgMS4xMTQuMTYgMS44NjEuNDc5IDIuMjQyLjMyLjM4MS45MDEuNTcyIDEuNzQzLjU3Mi44NzIgMCAxLjk5LS40NCAzLjM1Ni0xLjMxOWwuODcxIDEuNDVDMTYuNTQ3IDIyLjkzMSAxNC40NCAyNCAxMi43ODUgMjRjLTEuNjU2IDAtMi45NjQtLjM5NS0zLjkyMi0xLjE4Ny0uOTU5LS44Mi0xLjQzOC0yLjI1Ni0xLjQzOC00LjMwN1Y2Ljk4OUg1LjI0NmwtLjM0OS0xLjYyNiAyLjUyOC0uNzkxVjIuNDE4TDEyLjY1NCAwdjQuODM1bDUuMTQyLS4zOTUtLjQ4IDIuODU3LTQuNjYyLS4xNzZ2MTAuNzI1WiIvPjwvc3ZnPg==" width="18" height="18" preserveAspectRatio="none"/>
</g>
<g transform="translate(70.86614173228347 102.06614173228346)">
<image xlink:href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjMjM5REFEIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+VHlwc3Q8L3RpdGxlPjxwYXRoIGQ9Ik0xMi42NTQgMTcuODQ2YzAgMS4xMTQuMTYgMS44NjEuNDc5IDIuMjQyLjMyLjM4MS45MDEuNTcyIDEuNzQzLjU3Mi44NzIgMCAxLjk5LS40NCAzLjM1Ni0xLjMxOWwuODcxIDEuNDVDMTYuNTQ3IDIyLjkzMSAxNC40NCAyNCAxMi43ODUgMjRjLTEuNjU2IDAtMi45NjQtLjM5NS0zLjkyMi0xLjE4Ny0uOTU5LS44Mi0xLjQzOC0yLjI1Ni0xLjQzOC00LjMwN1Y2Ljk4OUg1LjI0NmwtLjM0OS0xLjYyNiAyLjUyOC0uNzkxVjIuNDE4TDEyLjY1NCAwdjQuODM1bDUuMTQyLS4zOTUtLjQ4IDIuODU3LTQuNjYyLS4xNzZ2MTAuNzI1WiIvPjwvc3ZnPgo=" width="18" height="18" preserveAspectRatio="none"/>
</g>
</g>
</svg>
The original SVG element was encoded as Base64. I think embedding the raw SVG code would be a better solution, unless there are other considerations worth discussing?
Reproduction URL
No response
Operating system
Windows
Typst version
Description
I have some SVG code, and I want to render as image in Typst, but when I output typ file to SVG, I found SVG in file not vector image.
Minimal reproduction:
the actual output in SVG format:
The original SVG element was encoded as Base64. I think embedding the raw SVG code would be a better solution, unless there are other considerations worth discussing?
Reproduction URL
No response
Operating system
Windows
Typst version