Skip to content

Commit

Permalink
f me
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicHorrorDev committed Nov 23, 2023
1 parent 5b3708a commit 52d752c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 55 deletions.
65 changes: 21 additions & 44 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ html5ever = "0.26.0"
image = "0.24.7"
clap = { version = "4.3.24", features = ["cargo"] }
copypasta = "0.10.0"
resvg = "0.33"
usvg = "0.33"
tiny-skia = "0.9.1"
resvg = "0.34"
usvg = "0.34"
tiny-skia = "0.10"
anyhow = "1.0.75"
dirs = "5.0.1"
serde = { version = "1.0.193", features = ["derive"] }
Expand Down
16 changes: 8 additions & 8 deletions src/image/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::io;
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::time::Instant;
use usvg::{Size as UsvgSize, TreeParsing, TreeTextToPath};
use usvg::{TreeParsing, TreeTextToPath};
use wgpu::util::DeviceExt;
use wgpu::{BindGroup, Device, TextureFormat};

Expand Down Expand Up @@ -212,18 +212,18 @@ impl Image {
fontdb.load_system_fonts();
let mut tree = usvg::Tree::from_data(&image_data, &opt).unwrap();
tree.size = tree.size.scale_to(
UsvgSize::new(
tree.size.width() * hidpi_scale as f64,
tree.size.height() * hidpi_scale as f64,
tiny_skia::Size::from_wh(
tree.size.width() * hidpi_scale,
tree.size.height() * hidpi_scale,
)
.unwrap(),
);
tree.convert_text(&fontdb);
let rtree = resvg::Tree::from_usvg(&tree);
let pixmap_size = resvg::IntSize::from_usvg(rtree.size);
let mut pixmap = tiny_skia::Pixmap::new(pixmap_size.width(), pixmap_size.height())
.context("Couldn't create svg pixmap")
.unwrap();
let mut pixmap =
tiny_skia::Pixmap::new(rtree.size.width() as u32, rtree.size.height() as u32)
.context("Couldn't create svg pixmap")
.unwrap();
rtree.render(tiny_skia::Transform::default(), &mut pixmap.as_mut());
ImageData::new(
ImageBuffer::from_raw(pixmap.width(), pixmap.height(), pixmap.data().into())
Expand Down

0 comments on commit 52d752c

Please sign in to comment.