Skip to content

Commit

Permalink
Avoid PDF artifacts when drawing 0-width borders
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Jun 7, 2024
1 parent 61f8bb3 commit 2c4351e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions weasyprint/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,11 @@ def draw_column_border():
colors[i].alpha and box.style[f'border_{side}_style']
for (i, side) in enumerate(SIDES)]

# The 4 sides are solid or double, and they have the same color. Oh yeah!
# We can draw them so easily!
if set(styles) in (set(('solid',)), set(('double',))) and (len(set(colors)) == 1):
simple_style = set(styles) in ({'solid'}, {'double'}) # one style, simple lines
single_color = len(set(colors)) == 1 # one color
four_sides = 0 not in widths # no 0-width border, to avoid PDF artifacts
if simple_style and single_color and four_sides:
# Simple case, we only draw rounded rectangles.
draw_rounded_border(stream, box, styles[0], colors[0])
draw_column_border()
return
Expand Down

0 comments on commit 2c4351e

Please sign in to comment.