Skip to content

Commit

Permalink
Merge pull request #1541 from aschmitz/patch-1
Browse files Browse the repository at this point in the history
fix: space out no-repeat patterns more
  • Loading branch information
liZe authored Jan 17, 2022
2 parents 6cce297 + 35386ab commit 274c230
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions weasyprint/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,10 @@ def draw_background_image(stream, layer, image_rendering):

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.
repeat_width = max(image_width, painting_width)
# want to be sure it will not be repeated on the painting_width. We
# double the painting width to ensure viewers don't incorrectly bleed
# the edge of the pattern into the painting area. (See #1539.)
repeat_width = max(image_width, 2 * painting_width)
elif repeat_x in ('repeat', 'round'):
# We repeat the image each image_width.
repeat_width = image_width
Expand All @@ -399,7 +401,7 @@ def draw_background_image(stream, layer, image_rendering):

# Comments above apply here too.
if repeat_y == 'no-repeat':
repeat_height = max(image_height, painting_height)
repeat_height = max(image_height, 2 * painting_height)
elif repeat_y in ('repeat', 'round'):
repeat_height = image_height
else:
Expand All @@ -412,11 +414,6 @@ def draw_background_image(stream, layer, image_rendering):
else:
repeat_height = image_height

if repeat_x == repeat_y == 'no-repeat':
# PDF patterns always repeat, use a big number to hide repetition
repeat_width = 2 * stream.page_rectangle[2]
repeat_height = 2 * stream.page_rectangle[3]

matrix = Matrix(e=position_x + positioning_x, f=position_y + positioning_y)
matrix @= stream.ctm
pattern = stream.add_pattern(
Expand Down

0 comments on commit 274c230

Please sign in to comment.