From 2b306ea65aaa348ec3158588fa78779fd4a1629b Mon Sep 17 00:00:00 2001 From: "Brian J. Burg" Date: Fri, 16 Nov 2012 15:18:47 -0800 Subject: [PATCH] Convert to use CGFont binding. --- font.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/font.rs b/font.rs index d2e074d..8a3cd19 100644 --- a/font.rs +++ b/font.rs @@ -46,6 +46,7 @@ use cg::base::{ }; use cg::font::{ CGGlyph, + CGFont, CGFontRef, }; use cg::geometry::{ @@ -111,7 +112,7 @@ pub type CTFont = CFWrapper; pub trait CTFontMethods { // Creation methods (statics below) - fn copy_to_CGFont(&const self) -> CGFontRef; + fn copy_to_CGFont(&const self) -> CGFont; fn clone_with_font_size(&const self, size: float) -> CTFont; // Names @@ -137,16 +138,13 @@ pub trait CTFontMethods { fn get_font_table(tag: u32) -> Option; } -pub fn new_from_CGFont(cgfont: CGFontRef, pt_size: float) -> CTFont { - assert cgfont.is_not_null(); - let result = CTFontCreateWithGraphicsFont(cgfont, pt_size as CGFloat, ptr::null(), ptr::null()); - +pub fn new_from_CGFont(cgfont: &CGFont, pt_size: float) -> CTFont { + let result = CTFontCreateWithGraphicsFont(*cgfont.borrow_ref(), pt_size as CGFloat, ptr::null(), ptr::null()); CFWrapper::wrap_owned(result) } pub fn new_from_descriptor(desc: &CTFontDescriptor, pt_size: float) -> CTFont { let result = CTFontCreateWithFontDescriptor(*desc.borrow_ref(), pt_size as CGFloat, ptr::null()); - CFWrapper::wrap_owned(result) } @@ -160,8 +158,9 @@ pub fn new_from_name(name: ~str, pt_size: float) -> Result { pub impl CTFont : CTFontMethods { // Creation methods - fn copy_to_CGFont(&const self) -> CGFontRef { - CTFontCopyGraphicsFont(self.obj, ptr::null()) + fn copy_to_CGFont(&const self) -> CGFont { + let value = CTFontCopyGraphicsFont(self.obj, ptr::null()); + CFWrapper::wrap_owned(value) } fn clone_with_font_size(&const self, size: float) -> CTFont {