[librsvg: 31/53] Set up FontMap for testing - work in progress
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 31/53] Set up FontMap for testing - work in progress
- Date: Fri, 23 Oct 2020 02:19:07 +0000 (UTC)
commit 0b703cc48dc30b25a2a8f8ab898edc56faf993f9
Author: Sven Neumann <sven svenfoo org>
Date: Sun Oct 18 12:09:57 2020 +0200
Set up FontMap for testing - work in progress
Attempt to port the test_utils_setup_font_map() code from test-utils.c.
Cargo.lock | 3 +++
tests/Cargo.toml | 3 +++
tests/src/utils.rs | 17 +++++++++++++++++
3 files changed, 23 insertions(+)
---
diff --git a/Cargo.lock b/Cargo.lock
index cf7c52c7..612fc56d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -784,8 +784,11 @@ dependencies = [
"cast",
"chrono",
"float-cmp",
+ "glib",
"librsvg",
"lopdf",
+ "pango",
+ "pangocairo",
"pkg-config",
"png",
"predicates",
diff --git a/tests/Cargo.toml b/tests/Cargo.toml
index 9ebc557c..c482c2be 100644
--- a/tests/Cargo.toml
+++ b/tests/Cargo.toml
@@ -12,8 +12,11 @@ cairo-rs = { version = "0.8.0", features = ["png"] }
cast = "0.2.3"
chrono = "0.4.0"
float-cmp = "0.8.0"
+glib = "0.9.0"
librsvg = { path = "../librsvg_crate" }
lopdf = "0.25.0"
+pango = "0.8.0"
+pangocairo = "0.9.0"
png = "0.16.1"
predicates = "1.0.2"
rsvg_internals = { path = "../rsvg_internals" }
diff --git a/tests/src/utils.rs b/tests/src/utils.rs
index b2cd967f..b009cf5b 100644
--- a/tests/src/utils.rs
+++ b/tests/src/utils.rs
@@ -1,3 +1,5 @@
+#![cfg(test)]
+
use std::env;
use std::path::PathBuf;
@@ -17,3 +19,18 @@ pub fn fixture_path(filename_from_test_resources: &str) -> PathBuf {
workspace_toplevel.join(filename_from_test_resources)
}
+
+#[cfg(have_pangoft2)]
+pub fn setup_font_map() {
+ use glib::prelude::*;
+ use pangocairo::FontMap;
+
+ let font_map = FontMap::new_for_font_type(cairo::FontType::FontTypeFt);
+
+ // TODO: create and apply FontConfig
+
+ FontMap::set_default(font_map.map(|m| m.downcast::<pangocairo::FontMap>().unwrap()));
+}
+
+#[cfg(not(have_pangoft2))]
+pub fn setup_font_map() {}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]