diff --git a/Cargo.lock b/Cargo.lock index 482cc0093..a8ddf3dfa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -557,8 +557,7 @@ dependencies = [ [[package]] name = "tiny-skia" version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +source = "git+https://github.com/linebender/tiny-skia?rev=68b198a#68b198a7210a6bbf752b43d6bc4db62445730313" dependencies = [ "arrayref", "arrayvec", @@ -572,8 +571,7 @@ dependencies = [ [[package]] name = "tiny-skia-path" version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +source = "git+https://github.com/linebender/tiny-skia?rev=68b198a#68b198a7210a6bbf752b43d6bc4db62445730313" dependencies = [ "arrayref", "bytemuck", diff --git a/crates/resvg/Cargo.toml b/crates/resvg/Cargo.toml index 183edd553..c5059b02b 100644 --- a/crates/resvg/Cargo.toml +++ b/crates/resvg/Cargo.toml @@ -21,7 +21,7 @@ log = "0.4" pico-args = { version = "0.5", features = ["eq-separator"] } rgb = "0.8" svgtypes = "0.15.3" -tiny-skia = "0.11.4" +tiny-skia = { git = "https://github.com/linebender/tiny-skia", rev = "68b198a" } usvg = { path = "../usvg", version = "0.45.1", default-features = false } zune-jpeg = { version = "0.4", optional = true } diff --git a/crates/resvg/src/main.rs b/crates/resvg/src/main.rs index 896d60cc0..f943a7ca5 100644 --- a/crates/resvg/src/main.rs +++ b/crates/resvg/src/main.rs @@ -389,30 +389,29 @@ enum FitTo { /// Keep original size. Original, /// Scale to width. - Width(u32), + Width(f32), /// Scale to height. - Height(u32), + Height(f32), /// Scale to size. - Size(u32, u32), + Size(f32, f32), /// Zoom by factor. Zoom(f32), } impl FitTo { - fn fit_to_size(&self, size: tiny_skia::IntSize) -> Option { + fn fit_to_size(&self, size: tiny_skia::Size) -> Option { match *self { FitTo::Original => Some(size), FitTo::Width(w) => size.scale_to_width(w), FitTo::Height(h) => size.scale_to_height(h), - FitTo::Size(w, h) => tiny_skia::IntSize::from_wh(w, h).map(|s| size.scale_to(s)), + FitTo::Size(w, h) => tiny_skia::Size::from_wh(w, h).map(|s| size.scale_to(s)), FitTo::Zoom(z) => size.scale_by(z), } } - fn fit_to_transform(&self, size: tiny_skia::IntSize) -> tiny_skia::Transform { - let size1 = size.to_size(); - let size2 = match self.fit_to_size(size) { - Some(v) => v.to_size(), + fn fit_to_transform(&self, size1: tiny_skia::Size) -> tiny_skia::Transform { + let size2 = match self.fit_to_size(size1) { + Some(v) => v, None => return tiny_skia::Transform::default(), }; tiny_skia::Transform::from_scale( @@ -526,13 +525,13 @@ fn parse_args() -> Result { let mut default_size = usvg::Size::from_wh(100.0, 100.0).unwrap(); if let (Some(w), Some(h)) = (args.width, args.height) { default_size = usvg::Size::from_wh(w as f32, h as f32).unwrap(); - fit_to = FitTo::Size(w, h); + fit_to = FitTo::Size(w as f32, h as f32); } else if let Some(w) = args.width { default_size = usvg::Size::from_wh(w as f32, 100.0).unwrap(); - fit_to = FitTo::Width(w); + fit_to = FitTo::Width(w as f32); } else if let Some(h) = args.height { default_size = usvg::Size::from_wh(100.0, h as f32).unwrap(); - fit_to = FitTo::Height(h); + fit_to = FitTo::Height(h as f32); } else if let Some(z) = args.zoom { fit_to = FitTo::Zoom(z); } @@ -681,11 +680,13 @@ fn render_svg(args: &Args, tree: &usvg::Tree) -> Result Result Result Result