Re: -glyphWithName:
Re: -glyphWithName:
- Subject: Re: -glyphWithName:
- From: Holmberg Bertil <email@hidden>
- Date: Sat, 23 Aug 2014 19:12:07 +0200
The first part of this method shows how to get the glyph from any character
Works fine with non-Latin characters such as Japanese too
- (UIBezierPath *)bezierPathFromChar:(NSString *)aChar inFont:(CTFontRef)aFont {
// Buffers
unichar chars[1];
CGGlyph glyphs[1];
// Copy the character into the buffer
chars[0] = [aChar characterAtIndex:0];
// Encode the glyph for the single character into another buffer
CTFontGetGlyphsForCharacters(aFont, chars, glyphs, 1);
// Get the single glyph
CGGlyph aGlyph = glyphs[0];
// Find a reference to the Core Graphics path for the glyph
CGPathRef glyphPath = CTFontCreatePathForGlyph(aFont, aGlyph, NULL);
// Create a bezier path from the CG path
UIBezierPath *glyphBezierPath = [UIBezierPath bezierPath];
[glyphBezierPath moveToPoint:CGPointZero];
[glyphBezierPath appendPath:[UIBezierPath bezierPathWithCGPath:glyphPath]];
CGPathRelease(glyphPath);
return glyphBezierPath;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden