Skip to content

Commit

Permalink
Update resvg
Browse files Browse the repository at this point in the history
  • Loading branch information
jackTabsCode committed Jun 9, 2024
1 parent 139563f commit be8cf63
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
35 changes: 20 additions & 15 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ reqwest = { version = "0.12.4", default-features = false, features = [
"rustls-tls",
"gzip",
] }
resvg = "0.41.0"
resvg = "0.42.0"
serde = { version = "1.0.203", features = ["derive"] }
serde-xml-rs = "0.6.0"
tokio = { version = "1.38.0" }
Expand Down
2 changes: 1 addition & 1 deletion src/commands/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn process_file(
};

if extension == "svg" {
bytes = svg_to_png(&bytes, &state.font_db).await?;
bytes = svg_to_png(&bytes).await?;
extension = "png";
}

Expand Down
3 changes: 0 additions & 3 deletions src/commands/sync/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ pub struct SyncState {
pub style: CodegenStyle,
pub strip_extension: bool,

pub font_db: Database,

pub existing_lockfile: LockFile,
pub new_lockfile: LockFile,

Expand Down Expand Up @@ -122,7 +120,6 @@ impl SyncState {
lua_extension,
style,
strip_extension,
font_db,
existing_lockfile,
new_lockfile,
existing: manual,
Expand Down
6 changes: 3 additions & 3 deletions src/util/svg.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use anyhow::Context;
use resvg::{
tiny_skia::Pixmap,
usvg::{fontdb::Database, Options, Transform, Tree},
usvg::{Options, Transform, Tree},
};

pub async fn svg_to_png(bytes: &[u8], font_db: &Database) -> anyhow::Result<Vec<u8>> {
pub async fn svg_to_png(bytes: &[u8]) -> anyhow::Result<Vec<u8>> {
let opt = Options::default();

let rtree = Tree::from_data(bytes, &opt, font_db).context("Failed to parse SVG file")?;
let rtree = Tree::from_data(bytes, &opt).context("Failed to parse SVG file")?;
let pixmap_size = rtree.size();

let mut pixmap = Pixmap::new(pixmap_size.width() as u32, pixmap_size.height() as u32)
Expand Down

0 comments on commit be8cf63

Please sign in to comment.