• 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: Getting glyph from character.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting glyph from character.


  • Subject: Re: Getting glyph from character.
  • From: Brian Webster <email@hidden>
  • Date: Sat, 7 Dec 2002 16:11:07 -0600

On Saturday, December 7, 2002, at 02:15 PM, email@hidden wrote:

I'm looking for a way to return NSGlyph from character. For example I
want to return Glyph from font Arial and character "a". Real thing i
want to return is a glyph for "-" minus sign.

Well, there isn't a simple method (that I know of) that will give you a glyph for a character, but it is possible, just a tad complicated.

The steps:

1. Create an NSTextStorage with the character and the font you want. Use the initWithString:attributes: method (inherited from NSAttributedString), passing in a string with the single character you want and an NSDictionary with a single key/value pair. The key should be NSFontAttributeName and the object should be the font you want (e.g. Arial 12).
2. Create an NSLayoutManager object and call addLayoutManager on the text storage with it.
3. Use numberOfGlyphs to ask how many glyphs are generated by the layout manager. In most cases there will only be one glyph for one character, but it is possible for there to be more than one in some cases. You can then use glyphAtIndex: or getGlyphs:range: to retrieve the glyph(s) you want.

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.

  • Prev by Date: Re: carbon events in cocoa app...
  • Next by Date: key value coding sample code ?
  • Previous by thread: Re: Getting glyph from character.
  • Next by thread: key value coding sample code ?
  • Index(es):
    • Date
    • Thread