[librsvg/rustify-rsvg-convert] Fix for #601 from master
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustify-rsvg-convert] Fix for #601 from master
- Date: Wed, 3 Feb 2021 01:22:44 +0000 (UTC)
commit ce24756dcd317682bd92aef33452ba631ae45acf
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Jan 27 20:04:31 2021 -0600
Fix for #601 from master
src/drawing_ctx.rs | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index dc8d62e8..5a2d7a3f 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1271,14 +1271,17 @@ impl DrawingCtx {
let mut bounding_box: Option<BoundingBox> = None;
path_helper.unset();
+ let params = dc.get_view_params();
+
for &target in &values.paint_order().targets {
// fill and stroke operations will preserve the path.
// markers operation will clear the path.
match target {
PaintTarget::Fill | PaintTarget::Stroke => {
path_helper.set()?;
- let bbox = bounding_box
- .get_or_insert_with(|| compute_stroke_and_fill_box(&cr, &values));
+ let bbox = bounding_box.get_or_insert_with(|| {
+ compute_stroke_and_fill_box(&cr, &values, ¶ms)
+ });
if values.is_visible() {
if target == PaintTarget::Stroke {
@@ -1749,7 +1752,11 @@ fn get_clip_in_user_and_object_space(
.unwrap_or((None, None))
}
-fn compute_stroke_and_fill_box(cr: &cairo::Context, values: &ComputedValues) -> BoundingBox {
+fn compute_stroke_and_fill_box(
+ cr: &cairo::Context,
+ values: &ComputedValues,
+ params: &ViewParams,
+) -> BoundingBox {
let affine = Transform::from(cr.get_matrix());
let mut bbox = BoundingBox::new().with_transform(affine);
@@ -1775,8 +1782,19 @@ fn compute_stroke_and_fill_box(cr: &cairo::Context, values: &ComputedValues) ->
bbox.insert(&fb);
// Bounding box for stroke
+ //
+ // When presented with a line width of 0, Cairo returns a
+ // stroke_extents rectangle of (0, 0, 0, 0). This would cause the
+ // bbox to include a lone point at the origin, which is wrong, as a
+ // stroke of zero width should not be painted, per
+ // https://www.w3.org/TR/SVG2/painting.html#StrokeWidth
+ //
+ // So, see if the stroke width is 0 and just not include the stroke in the
+ // bounding box if so.
+
+ let stroke_width = values.stroke_width().0.normalize(values, ¶ms);
- if values.stroke().0 != PaintServer::None {
+ if !stroke_width.approx_eq_cairo(0.0) && values.stroke().0 != PaintServer::None {
let (x0, y0, x1, y1) = cr.stroke_extents();
let sb = BoundingBox::new()
.with_transform(affine)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]