summaryrefslogtreecommitdiff
path: root/font/src/ft/fc/pattern.rs
diff options
context:
space:
mode:
Diffstat (limited to 'font/src/ft/fc/pattern.rs')
-rw-r--r--font/src/ft/fc/pattern.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/font/src/ft/fc/pattern.rs b/font/src/ft/fc/pattern.rs
index d7e824ed..53641f67 100644
--- a/font/src/ft/fc/pattern.rs
+++ b/font/src/ft/fc/pattern.rs
@@ -356,6 +356,18 @@ macro_rules! string_accessor {
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub struct PatternHash(pub u32);
+#[derive(Hash, Eq, PartialEq, Debug)]
+pub struct FTFaceLocation {
+ pub path: PathBuf,
+ pub index: isize,
+}
+
+impl FTFaceLocation {
+ pub fn new(path: PathBuf, index: isize) -> Self {
+ Self { path, index }
+ }
+}
+
impl Pattern {
pub fn new() -> Self {
Self::default()
@@ -583,6 +595,13 @@ impl PatternRef {
unsafe { self.get_string(b"file\0").nth(index) }.map(From::from)
}
+ pub fn ft_face_location(&self, index: usize) -> Option<FTFaceLocation> {
+ match (self.file(index), self.index().next()) {
+ (Some(path), Some(index)) => Some(FTFaceLocation::new(path, index)),
+ _ => None,
+ }
+ }
+
pub fn config_substitute(&mut self, config: &ConfigRef, kind: MatchKind) {
unsafe {
FcConfigSubstitute(config.as_ptr(), self.as_ptr(), kind as u32);