Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Size of substring




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Size of substring (From: Masha Kachalova <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.