Make CTFontDescriptor Send and Sync and expose attributes()

This commit is contained in:
Jeff Muizelaar
2020-10-27 17:37:09 -04:00
parent 20dcdc0970
commit 597a12983a
+11
View File
@@ -194,6 +194,10 @@ declare_TCFType! {
impl_TCFType!(CTFontDescriptor, CTFontDescriptorRef, CTFontDescriptorGetTypeID);
impl_CFTypeDescription!(CTFontDescriptor);
// "Font objects (CTFont, CTFontDescriptor, and associated objects) can be used
// simultaneously by multiple operations, work queues, or threads."
unsafe impl Send for CTFontDescriptor {}
unsafe impl Sync for CTFontDescriptor {}
impl CTFontDescriptor {
fn get_string_attribute(&self, attribute: CFStringRef) -> Option<String> {
@@ -289,6 +293,13 @@ impl CTFontDescriptor {
Ok(CTFontDescriptor::wrap_under_create_rule(desc))
}
}
pub fn attributes(&self) -> CFDictionary<CFString, CFType> {
unsafe {
let attrs = CTFontDescriptorCopyAttributes(self.as_concrete_TypeRef());
CFDictionary::wrap_under_create_rule(attrs)
}
}
}
pub fn new_from_attributes(attributes: &CFDictionary<CFString, CFType>) -> CTFontDescriptor {