diff --git a/Cargo.toml b/Cargo.toml index cc0e6f6..2305818 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,4 +18,4 @@ libc = "0.2" [target.x86_64-apple-darwin.dependencies] core-foundation = "0.4" -core-graphics = "0.9" +core-graphics = "0.11" diff --git a/src/font.rs b/src/font.rs index ae057d3..cf14aee 100644 --- a/src/font.rs +++ b/src/font.rs @@ -22,6 +22,7 @@ use core_graphics::base::CGFloat; use core_graphics::context::CGContext; use core_graphics::font::{CGGlyph, CGFont}; use core_graphics::geometry::{CGAffineTransform, CGPoint, CGRect, CGSize}; +use core_graphics::path::CGPath; use foreign_types::ForeignType; use libc::{self, size_t, c_void}; @@ -350,6 +351,18 @@ impl CTFont { } } } + + pub fn create_path_for_glyph(&self, glyph: CGGlyph, matrix: &CGAffineTransform) + -> Result { + unsafe { + let path = CTFontCreatePathForGlyph(self.obj, glyph, matrix); + if path.is_null() { + Err(()) + } else { + Ok(CGPath::from_ptr(path)) + } + } + } } // Helper methods @@ -502,7 +515,8 @@ extern { fn CTFontGetXHeight(font: CTFontRef) -> CGFloat; /* Getting Glyph Data */ - //fn CTFontCreatePathForGlyph + fn CTFontCreatePathForGlyph(font: CTFontRef, glyph: CGGlyph, matrix: *const CGAffineTransform) + -> CGPathRef; //fn CTFontGetGlyphWithName fn CTFontGetBoundingRectsForGlyphs(font: CTFontRef, orientation: CTFontOrientation,