• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSGlyph
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Can't bind image cells in a table to file's owner?
  • Next by Date: Re: Can't bind image cells in a table to file's owner?
  • Previous by thread: Re: NSGlyph
  • Next by thread: Can't bind image cells in a table to file's owner?
  • Index(es):
    • Date
    • Thread