Skip to content

Commit 2c4351e

Browse files
committed
Avoid PDF artifacts when drawing 0-width borders
1 parent 61f8bb3 commit 2c4351e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

weasyprint/draw.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,11 @@ def draw_column_border():
465465
colors[i].alpha and box.style[f'border_{side}_style']
466466
for (i, side) in enumerate(SIDES)]
467467

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

0 commit comments

Comments
 (0)