mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-09-11 20:47:56 +03:00
parent
01c5e972b9
commit
4dfe6079c2
@ -129,3 +129,18 @@ def test_pattern_gradient_stroke_fill_opacity(assert_same_renderings):
|
||||
''',
|
||||
tolerance=1,
|
||||
)
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_translate_opacity(assert_same_renderings):
|
||||
# Regression test for https://github.com/Kozea/WeasyPrint/issues/1976
|
||||
assert_same_renderings(
|
||||
opacity_source % '''
|
||||
<rect transform="translate(2, 2)" width="5" height="5"
|
||||
fill="blue" opacity="0.5" />
|
||||
''',
|
||||
opacity_source % '''
|
||||
<rect x="2" y="2" width="5" height="5"
|
||||
fill="blue" opacity="0.5" />
|
||||
''',
|
||||
)
|
||||
|
@ -394,19 +394,17 @@ class SVG:
|
||||
if filter_:
|
||||
apply_filters(self, node, filter_, font_size)
|
||||
|
||||
# Apply transform attribute
|
||||
self.transform(node.get('transform'), font_size)
|
||||
|
||||
# Create substream for opacity
|
||||
opacity = float(node.get('opacity', 1))
|
||||
if fill_stroke and 0 <= opacity < 1:
|
||||
original_stream = self.stream
|
||||
box = self.calculate_bounding_box(node, font_size)
|
||||
if is_valid_bounding_box(box):
|
||||
coords = (box[0], box[1], box[0] + box[2], box[1] + box[3])
|
||||
else:
|
||||
coords = (0, 0, self.inner_width, self.inner_height)
|
||||
self.stream = self.stream.add_group(*coords)
|
||||
|
||||
# Apply transform attribute
|
||||
self.transform(node.get('transform'), font_size)
|
||||
if not is_valid_bounding_box(box):
|
||||
box = (0, 0, self.inner_width, self.inner_height)
|
||||
self.stream = self.stream.add_group(*box)
|
||||
|
||||
# Clip
|
||||
clip_path = parse_url(node.get('clip-path')).fragment
|
||||
|
Loading…
Reference in New Issue
Block a user