Re: Getting glyphs and their outlines
Re: Getting glyphs and their outlines
- Subject: Re: Getting glyphs and their outlines
- From: John Labovitz <email@hidden>
- Date: Mon, 5 Apr 2004 21:32:22 -0700
On Mar 29, 2004, at 9:01 AM, Steve Sims wrote:
I want to do something that I feel is fairly simple, namely get a
glyph for a character in a particular font, and then grab its outline.
(Sorry to respond late, but I'm behind on the mailing list.)
I just did this yesterday, when I wrote my first screensaver. Here's
more or less what I did (consolidated from several methods, so I may
have typos):
// get the glyph for the "g" character from Helvetica
NSFont *font = [NSFont fontWithName:@"Helvetica" size:100.0];
NSGlyph glyph = [font glyphWithName:@"g"];
// render the glyph into a bezier path
NSBezierPath *path = [NSBezierPath bezierPath];
[path moveToPoint:NSMakePoint(0, 0)];
[path appendBezierPathWithGlyph:glyph inFont:font];
// go through each point in the path (if you need to)
for (i = 0; i < [path elementCount]; i++) {
NSBezierPathElement elemType;
NSPoint points[3];
elemType = [path elementAtIndex:i associatedPoints:points];
// look at the point -- see docs for above call for details
}
Hope this helps.
--
John Labovitz Consulting, LLC
http://mac.johnlabovitz.com
email@hidden
+1 503.949.3492
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.