Make CTFontDescriptor Send and Sync and expose attributes()
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user