librsvg2/0005-Update-the-lopdf-crate-to-0.29.0.patch

142 lines
4.2 KiB
Diff

From 3805ec26ffb2d8362bc762d4421115064cba7a39 Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Thu, 24 Nov 2022 14:37:39 +0100
Subject: [PATCH 5/5] Update the lopdf crate to 0.29.0
... and adapt tests/src/predicates/pdf.rs for lopdf API change from f64
floats to f32.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/774>
---
Cargo.lock | 8 +++-----
Cargo.toml | 2 +-
tests/src/predicates/pdf.rs | 32 ++++++++++++++++----------------
3 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 83b3d405..1da0ddc5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -908,16 +908,14 @@ dependencies = [
[[package]]
name = "lopdf"
-version = "0.27.0"
+version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8146695b97752d9c66da0092c6364f8f3ca683f5ea34341db21e5550c3b8c4f4"
+checksum = "de0f69c40d6dbc68ebac4bf5aec3d9978e094e22e29fcabd045acd9cec74a9dc"
dependencies = [
"chrono",
- "dtoa",
"encoding",
"flate2",
- "itoa 0.4.8",
- "lazy_static",
+ "itoa 1.0.4",
"linked-hash-map",
"log",
"pom",
diff --git a/Cargo.toml b/Cargo.toml
index ae48bbfa..514b1c69 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -87,7 +87,7 @@ cast = "0.3.0"
chrono = "0.4.0"
glib = "0.15"
libc = "0.2"
-lopdf = "0.27.0"
+lopdf = "0.29.0"
matches = "0.1"
pango = "0.15"
pangocairo = "0.15"
diff --git a/tests/src/predicates/pdf.rs b/tests/src/predicates/pdf.rs
index 62a3da4b..f7872d71 100644
--- a/tests/src/predicates/pdf.rs
+++ b/tests/src/predicates/pdf.rs
@@ -21,8 +21,8 @@ impl PdfPredicate {
pub fn with_page_size(
self: Self,
idx: usize,
- width_in_points: f64,
- height_in_points: f64,
+ width_in_points: f32,
+ height_in_points: f32,
) -> DetailPredicate<Self> {
DetailPredicate::<Self> {
p: self,
@@ -101,13 +101,13 @@ enum Detail {
/// Note that `w` and `h` given in `UserUnit`, which is by default 1.0 = 1/72 inch.
#[derive(Debug)]
struct Dimensions {
- w: f64,
- h: f64,
- unit: f64, // UserUnit, in points (1/72 of an inch)
+ w: f32,
+ h: f32,
+ unit: f32, // UserUnit, in points (1/72 of an inch)
}
impl Dimensions {
- pub fn from_media_box(obj: &lopdf::Object, unit: Option<f64>) -> lopdf::Result<Dimensions> {
+ pub fn from_media_box(obj: &lopdf::Object, unit: Option<f32>) -> lopdf::Result<Dimensions> {
let a = obj.as_array()?;
Ok(Dimensions {
w: a[2].as_float()?,
@@ -116,11 +116,11 @@ impl Dimensions {
})
}
- pub fn width_in_pt(self: &Self) -> f64 {
+ pub fn width_in_pt(self: &Self) -> f32 {
self.w * self.unit
}
- pub fn height_in_pt(self: &Self) -> f64 {
+ pub fn height_in_pt(self: &Self) -> f32 {
self.h * self.unit
}
}
@@ -134,15 +134,15 @@ impl fmt::Display for Dimensions {
impl cmp::PartialEq for Dimensions {
fn eq(&self, other: &Self) -> bool {
approx_eq!(
- f64,
+ f32,
self.width_in_pt(),
other.width_in_pt(),
- epsilon = 0.000_001
+ epsilon = 0.0001
) && approx_eq!(
- f64,
+ f32,
self.height_in_pt(),
other.height_in_pt(),
- epsilon = 0.000_001
+ epsilon = 0.0001
)
}
}
@@ -212,14 +212,14 @@ impl DetailPredicate<PdfPredicate> {
// Extensions to lopdf::Object; can be removed after lopdf 0.26
trait ObjExt {
/// Get the object value as a float.
- /// Unlike as_f64() this will also cast an Integer to a Real.
- fn as_float(&self) -> lopdf::Result<f64>;
+ /// Unlike as_f32() this will also cast an Integer to a Real.
+ fn as_float(&self) -> lopdf::Result<f32>;
}
impl ObjExt for lopdf::Object {
- fn as_float(&self) -> lopdf::Result<f64> {
+ fn as_float(&self) -> lopdf::Result<f32> {
match *self {
- lopdf::Object::Integer(ref value) => Ok(*value as f64),
+ lopdf::Object::Integer(ref value) => Ok(*value as f32),
lopdf::Object::Real(ref value) => Ok(*value),
_ => Err(lopdf::Error::Type),
}
--
2.38.1