On Jun 23, 2008, at 5:33 PM, Graham Cox wrote:

[NSLayoutManager_inst characterIndexForGlyphAtIndex:ig];

[NSLayoutManager_inst locationForGlyphAtIndex:ig];



On 24 Jun 2008, at 8:25 am, Yung-Luen Lan wrote:

Is there any way to obtain the position information based on
character, not glyph?


Graham, you're reducing the problem too far. Converting the character index to a glyph index, then getting the location for that glyph index, is probably what the OP is already doing, and as he notes, it won't return an insertion point position within a glyph. In general insertion point positions are not necessarily identical to glyph locations.

The Cocoa text system has a couple of solutions for this: first, you can use rectArrayForCharacterRange:withinSelectedCharacterRange:inTextContainer:rectCount : with a zero-length range to obtain a single insertion point location; second, you can use getLineFragmentInsertionPointsForCharacterAtIndex:alternatePositions:inDisplayOrder:positions:characterIndexes : to obtain insertion points in bulk for an entire line (useful for movement and so on).

However, the OP in the body of the message seems to say that he's using CoreText, while the subject refers to the Cocoa text system. It's not clear which one is intended. In CoreText, I believe the relevant call would be CTLineGetOffsetForStringIndex(), where the index in question is a character index.

Douglas Davidson

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please 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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to