I found a solution to this problem, or at least a kind
Problem: boundingRectForGlyphRange results are disabled in the case of RTL text.
Thus, in the case of an RTL text, only:
Using the NSLayoutManager locationForGlyphAtIndex method for each letter in the range. These are the starting points of each glyph in the range. Using these points, I am setting boundingRect correctly.
Here is his diagram:
CGPoint endPoint = ((NSValue *)pointsOfGlyps.firstObject).CGPointValue; CGPoint startPoint = ((NSValue *)pointsOfGlyps.lastObject).CGPointValue; boundingRect.origin.x = startPoint.x; boundingRect.size.width = endPoint.x - startPoint.x + letterWidth;
letterWidth is the approximate width of a letter, calculated as a delta between two consecutive starting points.
ugiflezet Aug 21 '14 at 16:36 2014-08-21 16:36
source share