From 597a12983a3dd2dcf5f39abb88d67ab6afbc0ec2 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 27 Oct 2020 17:37:09 -0400 Subject: [PATCH] Make CTFontDescriptor Send and Sync and expose attributes() --- core-text/src/font_descriptor.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core-text/src/font_descriptor.rs b/core-text/src/font_descriptor.rs index a6995f7..c70495c 100644 --- a/core-text/src/font_descriptor.rs +++ b/core-text/src/font_descriptor.rs @@ -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 { @@ -289,6 +293,13 @@ impl CTFontDescriptor { Ok(CTFontDescriptor::wrap_under_create_rule(desc)) } } + + pub fn attributes(&self) -> CFDictionary { + unsafe { + let attrs = CTFontDescriptorCopyAttributes(self.as_concrete_TypeRef()); + CFDictionary::wrap_under_create_rule(attrs) + } + } } pub fn new_from_attributes(attributes: &CFDictionary) -> CTFontDescriptor {