Skip to content

Commit 5a44b68

Browse files
authored
Don't include stroke in bbox for gradient with opacities on strokes (#49)
1 parent 3571761 commit 5a44b68

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

crates/svg2pdf/src/render/mask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn create(
3838
render(parent, recursive_mask.clone(), chunk, &mut content, ctx);
3939
}
4040

41-
let parent_svg_bbox = plain_bbox(parent, true);
41+
let parent_svg_bbox = plain_bbox(parent, false);
4242

4343
let actual_rect = match mask.units {
4444
Units::ObjectBoundingBox => mask.rect.bbox_transform(parent_svg_bbox),

crates/svg2pdf/src/render/path.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ fn stroke(
103103
) {
104104
if let Some(stroke) = path.stroke.as_ref() {
105105
let paint = &stroke.paint;
106-
let path_bbox_with_stroke = plain_bbox(node, true);
107-
let path_bbox_without_stroke = plain_bbox(node, false);
106+
let path_bbox = plain_bbox(node, false);
108107
let accumulated_transform = accumulated_transform.pre_concat(path.transform);
109108

110109
content.save_state();
@@ -124,7 +123,7 @@ fn stroke(
124123
// the whole pattern itself. This is why we need to handle this case differently.
125124
let pattern_name = pattern::create(
126125
p.clone(),
127-
&path_bbox_without_stroke,
126+
&path_bbox,
128127
chunk,
129128
ctx,
130129
accumulated_transform,
@@ -144,18 +143,15 @@ fn stroke(
144143
Some(stroke.opacity),
145144
);
146145

147-
if let Some(soft_mask) = gradient::create_shading_soft_mask(
148-
paint,
149-
&path_bbox_with_stroke,
150-
chunk,
151-
ctx,
152-
) {
146+
if let Some(soft_mask) =
147+
gradient::create_shading_soft_mask(paint, &path_bbox, chunk, ctx)
148+
{
153149
content.set_parameters(soft_mask.to_pdf_name());
154150
}
155151

156152
let pattern_name = gradient::create_shading_pattern(
157153
paint,
158-
&path_bbox_without_stroke,
154+
&path_bbox,
159155
chunk,
160156
ctx,
161157
&accumulated_transform,
-57 Bytes
Loading

0 commit comments

Comments
 (0)