cduck/drawsvg

No arrow heads in the png output

Closed this issue · 2 comments

I ran the sample script in https://github.com/cduck/drawSvg/blob/afd0de670850e316d1327de6d92a5b0051b895bd/README.md#basic-drawing-elements directly on Python, and have got the following png output which misses the arrow heads:

example

The svg output does have the arrow heads.

I have cairo@1.16.0 installed via Homebrew and the following in pip freeze:

cairocffi==1.2.0
CairoSVG==2.5.1
cffi==1.14.5
cssselect2==0.4.1
defusedxml==0.6.0
drawSvg==1.8.1
hyperbolic==1.3.1
imageio==2.9.0
numpy==1.20.1
Pillow==8.1.1
pycparser==2.20
tinycss2==1.1.0
webencodings==0.5.1
cduck commented

Thanks for reporting the issue. This appears to be a new bug in CairoSVG 2.5.1. I can reproduce your output after pip install cairosvg==2.5.1 and I get the correct output after pip install cairosvg==2.5.0.

Simplified code to reproduce (drawSvg 1.8.1):

import drawSvg as draw
d = draw.Drawing(200, 100, origin='center', displayInline=False)

# Draw arrows
arrow = draw.Marker(-0.1, -0.5, 0.9, 0.5, scale=4, orient='auto')
arrow.append(draw.Lines(-0.1, -0.5, -0.1, 0.5, 0.9, 0, fill='red', close=True))
d.append(draw.Line(30, -20, 0, -10,
            stroke='red', stroke_width=2, fill='none',
            marker_end=arrow))  # Add an arrow to the end of a line

d.setPixelScale(2)  # Set number of pixels per geometry unit
d.rasterize('out.png')  # Save as PNG
cduck commented

CairoSVG has fixed the bug and published 2.5.2. See the CairoSVG issue linked above for details.

@ThoAppelsin After updating with pip install --upgrade cairosvg you should get the correct output.