• 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 from Unicode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSGlyph from Unicode


  • Subject: Re: NSGlyph from Unicode
  • From: Douglas Davidson <email@hidden>
  • Date: Wed, 13 Sep 2006 09:27:15 -0700


On Sep 13, 2006, at 3:51 AM, Pascal Goguey wrote:

I also have messed a lot with the NSLayoutManager without success,
My second example shows the use of NSLayoutManager, etc.
It's extremely slow (I don't know if the path calculation or the drawing is slow...).

If you don't know what part is slow, Sampler or Shark will tell you. If you are creating and destroying a new layout manager every time, that will definitely be slow; try keeping the text system objects around and changing the text only when necessary. The process of glyph generation is fairly fast; if you need glyph generation without NSLayoutManager, you can use NSGlyphGenerator.


However, there are a number of things that you are missing. In general there is not a one-to-one mapping between Unicode characters and glyphs in a given font. There may be multiple glyphs required to represent a given character, or multiple characters may be represented by a single glyph, or there may be more complicated situations. The proper glyph to use may depend on context--that is, on the surrounding characters. Furthermore, the positioning of the glyphs is not always one after another; their positions may need adjusting, or they may need reordering.

Using the glyph generation facilities of NSLayoutManager without layout, or using NSGlyphGenerator, will give you a first-pass minimal translation of characters to glyphs. It may not be one-to-one, and there may be NSNullGlyphs inserted as padding in cases where multiple characters would otherwise be represented by a single glyph. For the full proper contextual glyphs, however, you must do layout as well; this is also required for positioning and reordering.

Another issue is font substitution. A single font may not suffice to represent all of the characters in a given string, so NSAttributedString goes through a process known as font fixing, whereby a new suitable font is substituted whenever characters cannot be represented in the specified font. When you examine the glyphs in the layout manager, you should remember that they are glyphs in the font given by the font attribute on the attributed string after font fixing, not necessarily the font originally specified. You will need to use the layout manager to convert back from glyph indexes to character indexes and examine the text storage's font attribute at the relevant character index.

See the conceptual documentation on the Cocoa text system for more information.

Douglas Davidson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSGlyph from Unicode (From: Pascal Goguey <email@hidden>)

  • Prev by Date: Re: how do I hide other running applications?
  • Next by Date: NSTableView drag and drop too smart for its own good
  • Previous by thread: NSGlyph from Unicode
  • Next by thread: Re: NSGlyph from Unicode
  • Index(es):
    • Date
    • Thread