Skip to content

Commit

Permalink
Update to 0.40
Browse files Browse the repository at this point in the history
  • Loading branch information
AldaronLau committed Feb 19, 2024
1 parent 561e46e commit bedcbc9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ log = "0.4"
open = "5.0"
pico-args = "0.5"
rand = "0.8"
resvg = "0.39"
resvg = "0.40"
serde = { version = "1.0.159", features = ["derive"] }
sys-info = "0.9"
thiserror = "1.0"
tiny-skia = "0.11"
toml = "0.8"
trash = { version = "3.0", default-features = false }
typed-builder = "0.18"
usvg = "0.39"
usvg = "0.40"
winit = "0.28"

[dependencies.libavif-image]
Expand Down
10 changes: 7 additions & 3 deletions src/image_cache/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use image::{
};
use resvg::{
tiny_skia::{Pixmap, Transform},
usvg,
usvg::{self, fontdb::Database},
};

pub mod errors {
Expand Down Expand Up @@ -180,8 +180,12 @@ pub fn load_gif(
pub fn load_svg(path: &std::path::Path) -> Result<image::RgbaImage> {
let opt = usvg::Options::default();
let data = std::fs::read(path)?;
let tree = usvg::Tree::from_data(&data, &opt)?;
let size = tree.size;
let mut font_db = Database::new();

font_db.load_system_fonts();

let tree = usvg::Tree::from_data(&data, &opt, &font_db)?;
let size = tree.size();
let (width, height) = (size.width(), size.height());
// Scale to fit 4096
let zoom = 4096.0 / width.max(height);
Expand Down

0 comments on commit bedcbc9

Please sign in to comment.