Right to left text not displaying correctly
Opened this issue · 5 comments
Hi Roy. Thanks for the feedback!
There are some commented out #ifdef DEBUG
statements in CloudLayoutOperation.m and CloudViewController.m. If you uncomment them, bounding boxes will be drawn around individual glyphs as well as words.
The words appear to be spaced properly in the view. I suspect the text is written r-t-l, but the bounding boxes will be l-t-r (mirrored), which will throw off the hasPlacedWord:atRect:
check to determine that the word placement did not intersect with any prior glyphs.
The problem is in addGlyphBoundingRectsToQuadTreeForWord:
CGFloat glyphX = lineOrigin.x + glyphPosition.x + CGRectGetMinX(glyphBounds);
CGFloat glyphY = CGRectGetHeight(horizontalFrame) - (lineOrigin.y + glyphPosition.y + CGRectGetMaxY(glyphBounds));
From the screenshot, X appears to be off by the width of the frame. r-t-l may need to be MaxX - position.x.
Y is also slightly off (by the distance between the highest ascender and the frame?). I believe l-t-r calculated a negative offset up from the bottom, but I don't understand how r-t-l would affect that value.
@PetahChristian I faced the same issue that described in the above. the different between LTR & RTL is character drawing for Example the drawing of "CAR" word is start with first character which is "C" letter but in RTL specifically in Arabic if you write "صالح" the drawing will start with "ح" which is the last character in the word.even if you reverse the word if it's arabic before drawing it's not helping. because the issue with calculation with arabic. I have tried to fix the issue but I couldn't because I didn't fully understand the calculation of glyph Rects.
I have tried this code
let status = CTRunGetStatus(run) switch status { case CTRunStatus.RightToLeft: // determine if the drawing for RTL languages. break default: break }
it might help with calculation because I didn't fully understand it as I mentioned.
@PetahChristian I have new update. I just did some modification for RTL specifically. it seems working fine but in some cases there is some collision between letters because the issue of rendering letters "from last to first".