From 28557ccc85f3c8d4a7e71ed33cd6b176a3fb7b69 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sun, 14 Jul 2019 12:07:34 +0300 Subject: [PATCH] Implement CTFontDescriptor::font_format() --- core-text/src/font_descriptor.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core-text/src/font_descriptor.rs b/core-text/src/font_descriptor.rs index c241660..9359d30 100644 --- a/core-text/src/font_descriptor.rs +++ b/core-text/src/font_descriptor.rs @@ -241,6 +241,20 @@ impl CTFontDescriptor { } } + pub fn font_format(&self) -> Option { + unsafe { + let value = CTFontDescriptorCopyAttribute(self.0, kCTFontFormatAttribute); + if value.is_null() { + return None; + } + + let value = CFType::wrap_under_create_rule(value); + assert!(value.instance_of::()); + let format = CFNumber::wrap_under_get_rule(value.as_CFTypeRef() as CFNumberRef); + format.to_i32().map(|x| x as CTFontFormat) + } + } + pub fn font_path(&self) -> Option { unsafe { let value = CTFontDescriptorCopyAttribute(self.0, kCTFontURLAttribute);