From c1450887c2e21a4cddfa57c4d3fc4d4eb02da425 Mon Sep 17 00:00:00 2001 From: "Brian J. Burg" Date: Thu, 8 Nov 2012 15:23:01 -0800 Subject: [PATCH] Add font_path(), and debug_descriptor() --- font_descriptor.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/font_descriptor.rs b/font_descriptor.rs index a9d8c4d..a367183 100644 --- a/font_descriptor.rs +++ b/font_descriptor.rs @@ -8,8 +8,9 @@ use cf::base::{ CFGetTypeID, CFRange, CFRelease, - CFTypeRef, CFTypeID, + CFTypeOps, + CFTypeRef, kCFAllocatorDefault, }; use cf::dictionary::CFDictionaryRef; @@ -20,6 +21,11 @@ use cf::string::{ CFStringRef, CFStringGetTypeID, }; +use cf::url::{ + CFURL, + CFURLRef, + CFURLGetTypeID, +}; use cg = core_graphics; use cg::base::CGFloat; @@ -118,6 +124,21 @@ pub impl CTFontDescriptor { let name : CFString = cf::base::wrap(value as CFStringRef); return name.to_str(); } + + fn font_path() -> ~str { + let value = CTFontDescriptorCopyAttribute(self.obj, kCTFontURLAttribute); + assert value.is_not_null(); + assert CFGetTypeID(value) == CFURLGetTypeID(); + + let cfurl : CFURL = cf::base::wrap(value as CFURLRef); + return cfurl.to_str(); + } +} + +pub fn debug_descriptor(desc: &CTFontDescriptor) { + io::println(fmt!("family: %s", desc.family_name())); + io::println(fmt!("path: %s", desc.font_path())); + desc.show(); } extern {