Stroked and filled rectangle created by PyX is rendered incorrectly by Ghostscript

97 Views Asked by At

I created a PDF file using the PyX Python package, showing a black stroked rectangle filled in red. When I preview the PDF file using Evince it looks as expected (Evince screenshot). However when I preview it using Ghostscript either the fill does not extend to the bottom of the rectangle or the bottom line is too thick (Ghostscript screenshot). Why might this be, please?

If I omit the black outline or omit the red fill then Ghostscript previews the image correctly. I'm using PyX 0.15, Python 3.8.6, Ghostscript 9.52 and Evince 3.38.0 under Ubuntu 20.10.

Here's my Python code:

#!/usr/bin/env python3
import pyx
canvas = pyx.canvas.canvas()
canvas.draw(pyx.path.rect(2, 1, .5, 8),
            [pyx.deco.stroked(),
             pyx.deco.filled([pyx.color.rgb(1, 0, 0)]),
             pyx.style.linewidth(0.05)])
page = pyx.document.page(canvas, paperformat = pyx.document.paperformat(10, 10))
doc = pyx.document.document([page])
doc.writePDFfile('rectangle.pdf')
1

There are 1 best solutions below

0
On

Using Ghostscript 9.53.3 solves the problem for me, so as @wobsta says I'm going to assume that this was a Ghostscript bug which has been fixed.