mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-08-17 16:40:45 +03:00
Use an image directly rather than via a pattern when the background is no-repeat.
This commit is contained in:
parent
8273f652b1
commit
7fe4b06638
@ -262,6 +262,24 @@ def draw_background_image(stream, layer, image_rendering):
|
||||
repeat_x, repeat_y = layer.repeat
|
||||
image_width, image_height = layer.size
|
||||
|
||||
if repeat_x == 'no-repeat' and repeat_y == 'no-repeat':
|
||||
# We don't use a pattern when we don't need to because some viewers
|
||||
# (e.g., Preview on Mac) introduce unnecessary pixelation when vector
|
||||
# images are used in patterns.
|
||||
if not layer.unbounded:
|
||||
stream.rectangle(painting_x, painting_y, painting_width,
|
||||
painting_height)
|
||||
stream.clip()
|
||||
stream.end()
|
||||
# Put the image in a group so that masking outside the image and
|
||||
# masking within the image don't conflict.
|
||||
group = stream.add_group(*stream.page_rectangle)
|
||||
group.transform(e=position_x + positioning_x,
|
||||
f=position_y + positioning_y)
|
||||
layer.image.draw(group, image_width, image_height, image_rendering)
|
||||
stream.draw_x_object(group.id)
|
||||
return
|
||||
|
||||
if repeat_x == 'no-repeat':
|
||||
# We want at least the whole image_width drawn on sub_surface, but we
|
||||
# want to be sure it will not be repeated on the painting_width. We
|
||||
|
Loading…
Reference in New Issue
Block a user