typst / svg2pdf

Converts SVG files to PDF.
Apache License 2.0
273 stars 32 forks source link

Fix bug where scaling wasn't properly applied to stroke widths #30

Closed LaurenzV closed 1 year ago

LaurenzV commented 1 year ago

Consider the following svg:

<svg width="100" height="30" version="1.1" xmlns="http://www.w3.org/2000/svg">
    <rect width="100" height="100" fill="white"></rect>
    <g transform="scale(.1 .1)">
        <line x1="0" x2="1000" y1="150" y2="150" stroke="#000" stroke-width="5"/>
    </g>
</svg>

It is currently rendered like this:

image

Even though it should look more like this:

image

The reason for this is that there was no scaling applied to the width of strokes. This PR should fix this. I looked into how it's done in resvg and tried to replicate this behavior in svg2pdf.

laurmaedje commented 1 year ago

Thanks!