Skip to content

Commit

Permalink
Fix panic in SVG rendering (#11196)
Browse files Browse the repository at this point in the history
Release Notes:

- Fixed a panic in SVG rendering
  • Loading branch information
ConradIrwin committed Apr 30, 2024
1 parent bc73626 commit ad44237
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/gpui/src/svg_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ impl SvgRenderer {
};

// Render the SVG to a pixmap with the specified width and height.
let mut pixmap =
resvg::tiny_skia::Pixmap::new(size.width.into(), size.height.into()).unwrap();
let mut pixmap = resvg::tiny_skia::Pixmap::new(size.width.into(), size.height.into())
.ok_or(usvg::Error::InvalidSize)?;

let transform = tree.view_box().to_transform(
resvg::tiny_skia::Size::from_wh(size.width.0 as f32, size.height.0 as f32).unwrap(),
resvg::tiny_skia::Size::from_wh(size.width.0 as f32, size.height.0 as f32)
.ok_or(usvg::Error::InvalidSize)?,
);

resvg::render(&tree, transform, &mut pixmap.as_mut());
Expand Down

0 comments on commit ad44237

Please sign in to comment.