Re: Size of substring
Re: Size of substring
- Subject: Re: Size of substring
- From: Douglas Davidson <email@hidden>
- Date: Wed, 2 May 2007 12:50:52 -0700
On May 2, 2007, at 10:24 AM, Masha Kachalova wrote:
How I can find a size of substring of the given string using the
given font?
If I get substring of my string using substringWithRange: and then
find a size
of this new string, I'll get wrong size, because some languages
(like arabic)
uses various forms for letters, so substring may contain another
forms of letters.
NSLayoutManager is the class of choice for these sorts of detailed
measurements. It has low-level information about layout--for
example, the location of each glyph in the laid-out text--and it also
has higher-level methods. For example, it has a method
rectArrayForCharacterRange:withinSelectedCharacterRange:inTextContainer:
rectCount: that will return a C array of rects enclosing the range of
text specified--essentially the set of rects that would be required
to draw the selection highlight, if the specified range were
selected. Keep in mind that even for a single range of text within a
single line, there may be more than one rect, due to bidi and other
complex layout. The method
boundingRectForGlyphRange:inTextContainer: condenses this to a single
union rect for convenience.
Douglas Davidson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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