From b7f60a3c9dc87bdcb69fe826c98a0c1458cad087 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Wed, 7 Feb 2018 14:11:21 -0500 Subject: [PATCH] Use stronger types in the CFDictionaries --- core-text/src/font.rs | 2 +- core-text/src/font_collection.rs | 2 +- core-text/src/font_descriptor.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core-text/src/font.rs b/core-text/src/font.rs index 06713da..202c9c4 100644 --- a/core-text/src/font.rs +++ b/core-text/src/font.rs @@ -98,7 +98,7 @@ pub fn new_from_CGFont(cgfont: &CGFont, pt_size: f64) -> CTFont { pub fn new_from_CGFont_with_variations(cgfont: &CGFont, pt_size: f64, - variations: &CFDictionary) + variations: &CFDictionary) -> CTFont { unsafe { let font_desc = font_descriptor::new_from_variations(variations); diff --git a/core-text/src/font_collection.rs b/core-text/src/font_collection.rs index 3e61a23..76da27b 100644 --- a/core-text/src/font_collection.rs +++ b/core-text/src/font_collection.rs @@ -72,7 +72,7 @@ pub fn create_for_family(family: &str) -> Option { let family_attr = CFString::wrap_under_get_rule(kCTFontFamilyNameAttribute); let family_name: CFString = family.parse().unwrap(); let specified_attrs = CFDictionary::from_CFType_pairs(&[ - (family_attr.as_CFType(), family_name.as_CFType()) + (family_attr.clone(), family_name.as_CFType()) ]); let wildcard_desc: CTFontDescriptor = diff --git a/core-text/src/font_descriptor.rs b/core-text/src/font_descriptor.rs index 904e802..36060ff 100644 --- a/core-text/src/font_descriptor.rs +++ b/core-text/src/font_descriptor.rs @@ -265,7 +265,7 @@ impl CTFontDescriptor { } } -pub fn new_from_attributes(attributes: &CFDictionary) -> CTFontDescriptor { +pub fn new_from_attributes(attributes: &CFDictionary) -> CTFontDescriptor { unsafe { let result: CTFontDescriptorRef = CTFontDescriptorCreateWithAttributes(attributes.as_concrete_TypeRef()); @@ -273,9 +273,9 @@ pub fn new_from_attributes(attributes: &CFDictionary) -> CTFontD } } -pub fn new_from_variations(variations: &CFDictionary) -> CTFontDescriptor { +pub fn new_from_variations(variations: &CFDictionary) -> CTFontDescriptor { unsafe { - let var_key = CFType::wrap_under_get_rule(mem::transmute(kCTFontVariationAttribute)); + let var_key = CFString::wrap_under_get_rule(kCTFontVariationAttribute); let var_val = CFType::wrap_under_get_rule(variations.as_CFTypeRef()); let attributes = CFDictionary::from_CFType_pairs(&[(var_key, var_val)]); new_from_attributes(&attributes)