From d136270c87d0de5977daea85e1f183f02fdfc7c4 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Sat, 30 Nov 2024 14:39:28 +0100 Subject: [PATCH 1/3] Update dependencies to latest versions --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 55597b2..f691736 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,6 @@ edition = "2018" render = ["dep:cairo-rs"] [dependencies] -cairo-rs = { version = "0.18.5", features = ["png", "pdf"], optional = true } -glib = "0.18.5" -gobject-sys = "0.15" +cairo-rs = { version = "0.20.5", features = ["png", "pdf"], optional = true } +glib = "0.20.6" +gobject-sys = "0.20" From 8cabd0beb77fb5a0d3b694376b944f952998f13f Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Sat, 30 Nov 2024 14:42:44 +0100 Subject: [PATCH 2/3] Fix rendering tests --- .gitignore | 2 +- src/lib.rs | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 7a5a1ea..bd85949 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ .idea/ Cargo.lock output.pdf -out.png +out*.png *.swp diff --git a/src/lib.rs b/src/lib.rs index fda5319..175c6f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -341,37 +341,40 @@ mod tests { for (index, p) in doc.pages().enumerate() { let (w, h) = p.get_size(); - assert!(w == src_w); - assert!(h == src_h); + assert_eq!(w, src_w); + assert_eq!(h, src_h); println!("page {}/{} -- {}x{}", index + 1, total, w, h); count += 1; } - assert!(count == 1); + assert_eq!(count, 1); #[cfg(feature = "render")] - let count = 0; + let mut count = 0; #[cfg(feature = "render")] for (index, p) in doc.pages().enumerate() { let (w, h) = p.get_size(); - assert!(w == src_w); - assert!(h == src_h); + assert_eq!(w, src_w); + assert_eq!(h, src_h); - let surface = ImageSurface::create(Format::ARgb32, w as i32, h as i32).unwrap(); + let surface = ImageSurface::create(Format::ARgb32, w as i32, h as i32).expect("failed to create image surface"); + let context = Context::new(&surface).expect("failed to create cairo context"); (|page: &PopplerPage, ctx: &Context| { ctx.save().unwrap(); page.render(ctx); ctx.restore().unwrap(); ctx.show_page().unwrap(); - })(&page, &ctx); + })(&p, &context); let mut f: File = File::create(format!("out{}.png", index)).unwrap(); surface.write_to_png(&mut f).expect("Unable to write PNG"); + + count += 1; } #[cfg(feature = "render")] - assert!(count == 1) + assert_eq!(count, 1) } } From 18835b7514424e7430d69aa8699c30ee85a59a53 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Sat, 30 Nov 2024 14:43:56 +0100 Subject: [PATCH 3/3] Update GitHub Actions workflow for rendering --- .github/workflows/rust.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ecf466b..028f0f5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -15,13 +15,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install libpoppler-glib-dev - run: sudo apt-get update && sudo apt-get install libpoppler-glib-dev + - uses: actions/checkout@v4 + - name: Install libpoppler-glib-dev libcairo-dev + run: sudo apt-get update && sudo apt-get install libpoppler-glib-dev libcairo-dev - name: Build - run: cargo build --verbose + run: cargo build --verbose --all-features - name: Run tests - run: cargo test --verbose + run: cargo test --verbose --all-features - name: Publish to Cargo Registry if: github.ref == 'refs/heads/master' env: