Add a binding to CTFontCreatePathForGlyph()

This commit is contained in:
Patrick Walton
2017-10-19 20:42:59 -07:00
parent b30db59c0e
commit 5783a1bb75
2 changed files with 16 additions and 2 deletions
+1 -1
View File
@@ -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"
+15 -1
View File
@@ -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<CGPath, ()> {
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,