[librsvg: 22/30] Handle cairo errors in draw_text_span




commit a145e56169da627d54e7784b13048d6f5b11d250
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Jun 21 19:59:52 2021 -0500

    Handle cairo errors in draw_text_span
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/516>

 src/drawing_ctx.rs | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index fb8c4a73..a25e5570 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1383,23 +1383,22 @@ impl DrawingCtx {
 
         let stroke_paint = span.stroke_paint.to_user_space(&bbox, &view_params, values);
 
-        self.set_paint_source(&stroke_paint, acquired_nodes)
-            .map(|had_paint_server| {
-                if had_paint_server {
-                    pangocairo::functions::update_layout(&self.cr, &span.layout);
-                    pangocairo::functions::layout_path(&self.cr, &span.layout);
-
-                    let (x0, y0, x1, y1) = self.cr.stroke_extents();
-                    let r = Rect::new(x0, y0, x1, y1);
-                    let ib = BoundingBox::new()
-                        .with_transform(transform)
-                        .with_ink_rect(r);
-                    bbox.insert(&ib);
-                    if span.is_visible {
-                        self.cr.stroke();
-                    }
-                }
-            })?;
+        let had_paint_server = self.set_paint_source(&stroke_paint, acquired_nodes)?;
+
+        if had_paint_server {
+            pangocairo::functions::update_layout(&self.cr, &span.layout);
+            pangocairo::functions::layout_path(&self.cr, &span.layout);
+
+            let (x0, y0, x1, y1) = self.cr.stroke_extents()?;
+            let r = Rect::new(x0, y0, x1, y1);
+            let ib = BoundingBox::new()
+                .with_transform(transform)
+                .with_ink_rect(r);
+            bbox.insert(&ib);
+            if span.is_visible {
+                self.cr.stroke()?;
+            }
+        }
 
         Ok(bbox)
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]