Build against rust-lopdf 0.29.0 and rust-yeslogic-fontconfig-sys 4.0.1

This commit is contained in:
Kalev Lember 2022-11-25 21:07:57 +01:00
parent 346ba30eeb
commit ec7e41070e
3 changed files with 281 additions and 1 deletions

View File

@ -0,0 +1,134 @@
From d5cc561ffaf9eeef0d5fa2851c28d744e98c13c0 Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Thu, 24 Nov 2022 14:35:26 +0100
Subject: [PATCH 4/5] Update the yeslogic-fontconfig-sys crate to 4.0.1
... and adapt tests/src/utils.rs for changed fontconfig_sys import
paths.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/773>
---
Cargo.lock | 25 +++++++++++++++++++++++--
Cargo.toml | 2 +-
tests/src/utils.rs | 13 +++++++------
3 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 3da93d02..83b3d405 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -357,6 +357,15 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
+[[package]]
+name = "dlib"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794"
+dependencies = [
+ "libloading",
+]
+
[[package]]
name = "doc-comment"
version = "0.3.3"
@@ -799,6 +808,16 @@ version = "0.2.132"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
+[[package]]
+name = "libloading"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
+dependencies = [
+ "cfg-if",
+ "winapi",
+]
+
[[package]]
name = "librsvg"
version = "2.55.1"
@@ -2333,10 +2352,12 @@ dependencies = [
[[package]]
name = "yeslogic-fontconfig-sys"
-version = "2.11.2"
+version = "4.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38e47154248a2dba5ca6965e26b1a59146210736ea9b862362b6d72682e57f8d"
+checksum = "ec657fd32bbcbeaef5c7bc8e10b3db95b143fab8db0a50079773dbf936fd4f73"
dependencies = [
"const-cstr",
+ "dlib",
+ "once_cell",
"pkg-config",
]
diff --git a/Cargo.toml b/Cargo.toml
index d62250df..ae48bbfa 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -98,7 +98,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tempfile = "3"
test-generator = "0.3"
-yeslogic-fontconfig-sys = "2.11.1"
+yeslogic-fontconfig-sys = "4.0.1"
[build-dependencies]
regex = "1.3.9"
diff --git a/tests/src/utils.rs b/tests/src/utils.rs
index fb4ad2de..e70eb04f 100644
--- a/tests/src/utils.rs
+++ b/tests/src/utils.rs
@@ -49,7 +49,6 @@ pub fn render_document<F: FnOnce(&cairo::Context)>(
#[cfg(system_deps_have_pangoft2)]
mod pango_ft2 {
use super::*;
- use fontconfig_sys::fontconfig;
use glib::prelude::*;
use pangocairo::FontMap;
@@ -59,7 +58,7 @@ mod pango_ft2 {
// This is not bound in gtk-rs, and PangoFcFontMap is not even exposed, so we'll bind it by hand.
fn pango_fc_font_map_set_config(
font_map: *mut libc::c_void,
- config: *mut fontconfig::FcConfig,
+ config: *mut fontconfig_sys::FcConfig,
);
}
@@ -73,15 +72,17 @@ mod pango_ft2 {
"tests/resources/Roboto-BoldItalic.ttf",
];
- let config = fontconfig::FcConfigCreate();
- if fontconfig::FcConfigSetCurrent(config) == 0 {
+ let config = fontconfig_sys::FcConfigCreate();
+ if fontconfig_sys::FcConfigSetCurrent(config) == 0 {
panic!("Could not set a fontconfig configuration");
}
for path in &font_paths {
let path_cstring = CString::new(*path).unwrap();
- if fontconfig::FcConfigAppFontAddFile(config, path_cstring.as_ptr() as *const _) == 0 {
+ if fontconfig_sys::FcConfigAppFontAddFile(config, path_cstring.as_ptr() as *const _)
+ == 0
+ {
panic!("Could not load font file {} for tests; aborting", path,);
}
}
@@ -90,7 +91,7 @@ mod pango_ft2 {
let raw_font_map: *mut pango::ffi::PangoFontMap = font_map.to_glib_none().0;
pango_fc_font_map_set_config(raw_font_map as *mut _, config);
- fontconfig::FcConfigDestroy(config);
+ fontconfig_sys::FcConfigDestroy(config);
FontMap::set_default(Some(font_map.downcast::<pangocairo::FontMap>().unwrap()));
}
--
2.38.1

View File

@ -0,0 +1,141 @@
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

View File

@ -15,7 +15,7 @@
Name: librsvg2
Summary: An SVG library based on cairo
Version: 2.55.1
Release: 2%{?dist}
Release: 3%{?dist}
License: LGPLv2+
URL: https://wiki.gnome.org/Projects/LibRsvg
@ -26,6 +26,8 @@ Source0: https://download.gnome.org/sources/librsvg/2.54/librsvg-%{versio
Patch: 0001-Update-the-nalgebra-crate.patch
Patch: 0002-Fedora-Drop-dependencies-required-for-benchmarking.patch
Patch: 0003-Update-the-lopdf-crate.patch
Patch: 0004-Update-the-yeslogic-fontconfig-sys-crate-to-4.0.1.patch
Patch: 0005-Update-the-lopdf-crate-to-0.29.0.patch
%endif
BuildRequires: chrpath
@ -139,6 +141,9 @@ rm -f %{buildroot}%{_pkgdocdir}/COMPILING.md
%{_mandir}/man1/rsvg-convert.1*
%changelog
* Fri Nov 25 2022 Kalev Lember <klember@redhat.com> - 2.55.1-3
- Build against rust-lopdf 0.29.0 and rust-yeslogic-fontconfig-sys 4.0.1
* Mon Nov 21 2022 Kalev Lember <klember@redhat.com> - 2.55.1-2
- Switch to packaged rust deps