Re: NSGlyph
Re: NSGlyph
- Subject: Re: NSGlyph
- From: Graff <email@hidden>
- Date: Sat, 4 Oct 2008 17:19:09 -0400
On Oct 4, 2008, at 11:59 AM, hatzicware wrote:
I can't figure out how NSGlyph works in methods like this:
[path appendBezierPathWithGlyph:'x' inFont:[NSFont userFontOfSize:
14.0]]
(Of course 'path' is an NSBezierPath.)
What I get on the screen is not an '+', but an upper-case "H" in some
outline font. And when I put in explicit Unicodes, I don't get the
expected symbol either.
NSGlyph is declared as an unsigned int. But how is it connected to
displayed characters?
You need to use the NSFont method -glyphWithName:
NSFont *aFont = [NSFont userFontOfSize:14.0];
[path appendBezierPathWithGlyph:[aFont glyphWithName:@"plus"]
inFont:aFont];
NSGlyph is just an unsigned int that represents the index of the glyph
in that font. In order to get that index you need to use
glyphWithName. However, this requires you to know the actual name of
the glyph, not what character it represents. For example the glyph
name for "+" is "plus".
If you are just trying to draw text then easiest thing to do is use
one of the NSString draw methods. If you really need the text as a
path then you should read this section of the Cocoa Drawing Guide:
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Paths/chapter_6_section_5.html
>
_______________________________________________
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