1 use foreign_types::{foreign_type, ForeignTypeRef}; 2 3 use super::ffi::{FcConfig, FcConfigDestroy, FcConfigGetCurrent, FcConfigGetFonts}; 4 use super::{FontSetRef, SetName}; 5 6 foreign_type! { 7 pub unsafe type Config { 8 type CType = FcConfig; 9 fn drop = FcConfigDestroy; 10 } 11 } 12 13 impl Config { 14 /// Get the current configuration. get_current() -> &'static ConfigRef15 pub fn get_current() -> &'static ConfigRef { 16 unsafe { ConfigRef::from_ptr(FcConfigGetCurrent()) } 17 } 18 } 19 20 impl ConfigRef { 21 /// Returns one of the two sets of fonts from the configuration as 22 /// specified by `set`. get_fonts(&self, set: SetName) -> &FontSetRef23 pub fn get_fonts(&self, set: SetName) -> &FontSetRef { 24 unsafe { 25 let ptr = FcConfigGetFonts(self.as_ptr(), set as u32); 26 FontSetRef::from_ptr(ptr) 27 } 28 } 29 } 30