Auto merge of #424 - jrmuizel:sync-desc, r=emilio

Make CTFontDescriptor Send and Sync and expose attributes()
This commit is contained in:
bors-servo
2020-10-29 20:34:42 -04:00
committed by GitHub
+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 {