Bug: SurfacePattern is rasterized when using EXTEND_REPEAT on PDF.

Simon Sapin <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Hi,

I have a bug in WeasyPrint (converts web documents to PDF): repeated SVG 
backgrounds are rasterized. (They appear as pixels instead of vectors.)

The source of the bug is in cairo or Pycairo. When a vector-type surface 
(PDFSurface or SVGSurface) is used as a source through a SurfacePattern 
and that pattern has EXTEND_REPEAT, the pattern is rasterized.

Attached is a test case that uses Pycairo to create an 'output.pdf' file 
in the current directory. When zoomed in a PDF viewer, the line on the 
left (not repeated) is in nice crips vectors, while the one on the right 
(with EXTEND_REPEAT) is in blurry pixels.

I had a quick look I’m not very familiar with cairo’s code base. In 
which file is EXTEND_REPEAT implemented? Would this be hard to solve?

Regards,
-- 
Simon Sapin

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
surfacepattern_test.py (text/x-python, 462 B)
import cairo

# Draw something on an abstract surface
s1 = cairo.PDFSurface(None, 100, 100)
c = cairo.Context(s1)
c.set_line_width(3)
c.move_to(10, 10)
c.line_to(20, 90)
c.stroke()

s2 = cairo.PDFSurface('output.pdf', 100, 100)
c = cairo.Context(s2)
# Non-repeated SurfacePattern
c.set_source_surface(s1, 10)
c.move_to(10, 10)
c.paint()

c.set_source_surface(s1, 20)
# Repeated SurfacePattern, rasterized
c.get_source().set_extend(cairo.EXTEND_REPEAT)
c.paint()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.