SVG icon indicating copy to clipboard operation
SVG copied to clipboard

Stroke-Width incorrectly applied if between 0 and 1 or if using percentage

Open RMY1 opened this issue 8 years ago • 7 comments

Hi guys.

It seems stroke-width is ignored when it has value between 0 and 1. Stroke-width value, in that case, is taken by default and is equal to 1.

Does anyone else experience that behavour ? Thanks.

RMY1 avatar Aug 28 '17 14:08 RMY1

I was not able to reproduce this. My test image shows with stroke-width="0.5" half the width (second circle) as with stroke-width="1" (default) - first circle. Although a stroke-width with percentage seems to be calculated wrong (3rd circle): output

Testfiles: __issue-338-01_stroke_width.zip

Output png IE: __issue-338-01_stroke_width

heindlalex avatar Dec 29 '18 21:12 heindlalex

Thanks, @heindlalex - I updated the title accordingly.

mrbean-bremen avatar Dec 30 '18 18:12 mrbean-bremen

Just noticed that the original issue is still there for paths. This can be seen in the test image __issue-323-01.svg after the crash is fixed (will do that in a moment).

mrbean-bremen avatar Jan 06 '19 19:01 mrbean-bremen

Looks like the problem occurs if the physical line width is between 0 and 1 due to missing anti-aliasing. I found a reference to a respective bug in GDI+ - so the only viable option seems to be to adapt the color (make it more transparent?). I tried this, and the result looks better, though not perfect, but I'm unsure if this is the way to go... Any ideas are welcome.

mrbean-bremen avatar Jan 06 '19 21:01 mrbean-bremen

Anti-aliasing also causes the following issue.

simple stroke-width one line.

<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" width="300" height="80">
<line x1="5" y1="20" x2="220" y2="20" stroke="red" stroke-width="1" />
</svg>

Enable Anti-aliasing:

output

Disable Anti-aliasing: output_no

FYI ...

Edge:

Edge

H1Gdev avatar May 25 '19 07:05 H1Gdev

@H1Gdev - this is to be expected - anti-aliasing "smears" the lines a bit by design. The problem here is with lines with a width less than 1 pixel. This can be seen in the mentioned example image (Bolivian flag). This is the expected image: grafik And this is rendered by the SVG lib: grafik Note the black lines, which all have a width of less than a pixel. Anti-aliasing doesn't help here.

mrbean-bremen avatar May 25 '19 16:05 mrbean-bremen

This issue still persists on Ubuntu with libgdiplus. I use SVG.Net to render SVGs to PNG files. The images below display a path with stroke-width="0.2" as seen in Chrome, rasterized on Windows and rasterized on Ubuntu:

Chrome:

Windows:

Ubuntu:

Seb-Eck avatar Jan 15 '21 10:01 Seb-Eck