Skip to content

Commit

Permalink
use resvg to display svg.
Browse files Browse the repository at this point in the history
  • Loading branch information
james-lawrence committed Jan 16, 2023
1 parent d062962 commit 9038cbe
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 492 deletions.
6 changes: 4 additions & 2 deletions druid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples=examples"]
default = ["gtk"]
gtk = ["druid-shell/gtk"]
image = ["druid-shell/image"]
svg = ["usvg"]
svg = ["usvg", "resvg", "tiny-skia"]
x11 = ["druid-shell/x11"]
# **WARNING** not ready for the prime time. Many things don't work yet.
wayland = ["druid-shell/wayland"]
Expand Down Expand Up @@ -71,7 +71,9 @@ instant = { version = "0.1.12", features = ["wasm-bindgen"] }
# Optional dependencies
chrono = { version = "0.4.23", optional = true }
im = { version = "15.1.0", optional = true }
usvg = { version = "0.14.1", optional = true }
resvg = { version = "0.19.0", optional = true }
usvg = { version = "0.19.0", optional = true }
tiny-skia = { version = "0.6.1", optional = true }

[target.'cfg(target_arch="wasm32")'.dependencies]
tracing-wasm = { version = "0.2.1" }
Expand Down
4 changes: 2 additions & 2 deletions druid/examples/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use tracing::error;

use druid::{
widget::{FillStrat, Flex, Svg, SvgData, WidgetExt},
widget::{Flex, Svg, SvgData, WidgetExt},
AppLauncher, LocalizedString, Widget, WindowDesc,
};

Expand All @@ -47,7 +47,7 @@ fn ui_builder() -> impl Widget<u32> {
let mut col = Flex::column();

col.add_flex_child(Svg::new(tiger_svg.clone()).fix_width(60.0).center(), 1.0);
col.add_flex_child(Svg::new(tiger_svg.clone()).fill_mode(FillStrat::Fill), 1.0);
col.add_flex_child(Svg::new(tiger_svg.clone()), 1.0);
col.add_flex_child(Svg::new(tiger_svg), 1.0);
col.debug_paint_layout()
}
Loading

0 comments on commit 9038cbe

Please sign in to comment.