[librsvg: 33/53] Set the FcConfig on the pango FontMap
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 33/53] Set the FcConfig on the pango FontMap
- Date: Fri, 23 Oct 2020 02:19:07 +0000 (UTC)
commit de3cee5e688ed0a831051a1701dd10a33c33edee
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Oct 21 18:57:08 2020 -0500
Set the FcConfig on the pango FontMap
Cargo.lock | 20 ++++++++++++++++++++
tests/Cargo.toml | 2 ++
tests/src/utils.rs | 19 ++++++++++++++++---
3 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index 612fc56d..4c2687be 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -181,6 +181,12 @@ dependencies = [
"unicode-width",
]
+[[package]]
+name = "const-cstr"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed3d0b5ff30645a68f35ece8cea4556ca14ef8a1651455f789a099a0513532a6"
+
[[package]]
name = "crc32fast"
version = "1.2.0"
@@ -785,9 +791,11 @@ dependencies = [
"chrono",
"float-cmp",
"glib",
+ "libc",
"librsvg",
"lopdf",
"pango",
+ "pango-sys",
"pangocairo",
"pkg-config",
"png",
@@ -795,6 +803,7 @@ dependencies = [
"rsvg_internals",
"tempfile",
"test-generator",
+ "yeslogic-fontconfig-sys",
]
[[package]]
@@ -2100,3 +2109,14 @@ dependencies = [
"markup5ever",
"time",
]
+
+[[package]]
+name = "yeslogic-fontconfig-sys"
+version = "2.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e194a0c5cd1b5c87215eed9d26aca9799fa1b599fe2e178977d6f8ccc812e3d3"
+dependencies = [
+ "const-cstr",
+ "libc",
+ "pkg-config",
+]
diff --git a/tests/Cargo.toml b/tests/Cargo.toml
index 2a45fedb..1dd80146 100644
--- a/tests/Cargo.toml
+++ b/tests/Cargo.toml
@@ -13,9 +13,11 @@ cast = "0.2.3"
chrono = "0.4.0"
float-cmp = "0.8.0"
glib = "0.9.0"
+libc = "0.2"
librsvg = { path = "../librsvg_crate" }
lopdf = "0.25.0"
pango = "0.8.0"
+pango-sys = "0.9.0"
pangocairo = "0.9.0"
png = "0.16.1"
predicates = "1.0.2"
diff --git a/tests/src/utils.rs b/tests/src/utils.rs
index ccb9caf4..91b8d1fb 100644
--- a/tests/src/utils.rs
+++ b/tests/src/utils.rs
@@ -1,5 +1,7 @@
#![cfg(test)]
+use glib::translate::*;
+use libc;
use std::env;
use std::path::PathBuf;
@@ -48,14 +50,25 @@ pub fn setup_font_map() {
};
}
- let font_map = FontMap::new_for_font_type(cairo::FontType::FontTypeFt);
+ let font_map = FontMap::new_for_font_type(cairo::FontType::FontTypeFt).unwrap();
+ let raw_font_map: *mut pango_sys::PangoFontMap = font_map.to_glib_none().0;
+
+ extern "C" {
+ // pango_fc_font_map_set_config (PangoFcFontMap *fcfontmap,
+ // FcConfig *fcconfig);
+ // 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,
+ );
+ }
- // TODO: apply config
unsafe {
+ pango_fc_font_map_set_config (raw_font_map as *mut _, config);
fontconfig::FcConfigDestroy(config);
};
- FontMap::set_default(font_map.map(|m| m.downcast::<pangocairo::FontMap>().unwrap()));
+ FontMap::set_default(Some(font_map.downcast::<pangocairo::FontMap>().unwrap()));
}
#[cfg(not(have_pangoft2))]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]