diff options
Diffstat (limited to 'font/src/ft/fc/pattern.rs')
-rw-r--r-- | font/src/ft/fc/pattern.rs | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/font/src/ft/fc/pattern.rs b/font/src/ft/fc/pattern.rs index f40cc9c9..da459b6d 100644 --- a/font/src/ft/fc/pattern.rs +++ b/font/src/ft/fc/pattern.rs @@ -21,10 +21,14 @@ use std::str; use foreign_types::{foreign_type, ForeignType, ForeignTypeRef}; use libc::{c_char, c_double, c_int}; +use super::ffi::FcMatrix; use super::ffi::FcResultMatch; use super::ffi::{FcBool, FcFontRenderPrepare, FcPatternGetBool, FcPatternGetDouble}; use super::ffi::{FcChar8, FcConfigSubstitute, FcDefaultSubstitute, FcPattern, FcPatternHash}; -use super::ffi::{FcPatternAddCharSet, FcPatternDestroy, FcPatternDuplicate, FcPatternGetCharSet}; +use super::ffi::{ + FcPatternAddCharSet, FcPatternDestroy, FcPatternDuplicate, FcPatternGetCharSet, + FcPatternGetMatrix, +}; use super::ffi::{FcPatternAddDouble, FcPatternAddString, FcPatternCreate, FcPatternGetString}; use super::ffi::{FcPatternAddInteger, FcPatternGetInteger, FcPatternPrint}; @@ -572,9 +576,10 @@ impl PatternRef { } } + /// Get charset from the pattern. pub fn get_charset(&self) -> Option<&CharSetRef> { unsafe { - let mut charset: *mut _ = ptr::null_mut(); + let mut charset = ptr::null_mut(); let result = FcPatternGetCharSet( self.as_ptr(), @@ -591,6 +596,25 @@ impl PatternRef { } } + /// Get matrix from the pattern. + pub fn get_matrix(&self) -> Option<FcMatrix> { + unsafe { + let mut matrix = ptr::null_mut(); + let result = FcPatternGetMatrix( + self.as_ptr(), + b"matrix\0".as_ptr() as *mut c_char, + 0, + &mut matrix, + ); + + if result == FcResultMatch { + Some(*matrix) + } else { + None + } + } + } + pub fn file(&self, index: usize) -> Option<PathBuf> { unsafe { self.get_string(b"file\0").nth(index) }.map(From::from) } |