Add font_path(), and debug_descriptor()

This commit is contained in:
Brian J. Burg
2012-11-08 15:23:01 -08:00
parent 03050d5d81
commit c1450887c2
+22 -1
View File
@@ -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 {