• 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: Finding Glyphs for String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding Glyphs for String


  • Subject: Re: Finding Glyphs for String
  • From: Charles Jolley <email@hidden>
  • Date: Tue, 27 Nov 2001 18:23:47 -0600

Hi Douglas:
Thanks for the information on converting characters to glyphs. This is very helpful! I can use this approach.

Would you (or anyone) happen to know if there is a way to do this that does not require the full machinery of the LayoutManager? The text I have to convert is quite small and it is for insertion into another layout manager anyway, so using another layout manager seems like a bit overkill.

Thanks again,
-Charles

Charles Jolley
Okito Software

On Tuesday, November 27, 2001, at 11:00 AM, Douglas Davidson wrote:

On Monday, November 26, 2001, at 04:55 PM, Charles Jolley wrote:

Does anyone know how to find the corresponding glyphs for
characters in a string? It appears that the mechanism used by the text
system and even ATSUI is all internal...

Here is a copy of one of my earlier posts on this:

Certainly there is public API for getting NSGlyphs. NSLayoutManager
defines

- (NSGlyph)glyphAtIndex:(unsigned)glyphIndex;
- (NSGlyph)glyphAtIndex:(unsigned)glyphIndex isValidIndex:(BOOL
*)isValidIndex;
- (unsigned)getGlyphs:(NSGlyph *)glyphArray range:(NSRange)glyphRange;

To be sure, it is necessary to set up an NSLayoutManager instance in
order to use these; there is no way, for example, to convert a single
character into a glyph. That is because, as you note, glyph management
is quite complex; the mapping from characters to glyphs is
many-to-many, and in general requires access to the whole string,
rather than a single character, for correctness. The NSLayoutManager
will also cache the glyphs for you.

For an example of using NSLayoutManager without an NSTextView, see the
CircleView example. That example uses the layout manager for both
glyph generation and layout; to perform glyph generation without
layout, you would simply call some of the methods listed above rather
than the methods glyphRangeForTextContainer:,
usedRectForTextContainer:, and drawGlyphsForGlyphRange:atPoint: used in
the example.

Remember that the font that should be used to display the glyph is not
necessarily the font you supplied in your text storage. If the font
you supply does not have a glyph for a particular character, the text
system will find an appropriate font during font fixing. You will need
to inspect the text storage to find the fonts actually used.

Douglas Davidson
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


  • Follow-Ups:
    • Re: Finding Glyphs for String
      • From: Douglas Davidson <email@hidden>
References: 
 >Re: Finding Glyphs for String (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: NSPortTimeoutException??
  • Next by Date: Re: Finding Glyphs for String
  • Previous by thread: Re: Finding Glyphs for String
  • Next by thread: Re: Finding Glyphs for String
  • Index(es):
    • Date
    • Thread