- if( bidirectionalParagraph &&
- ( bidirectionalParagraph->characterRun.characterIndex + bidirectionalParagraph->characterRun.numberOfCharacters == index ) )
+ // Find the bidi line where the character is laid-out.
+
+ const BidirectionalLineInfoRun* const bidirectionalLineInfoBuffer = mBidirectionalLineInfo.Begin();
+
+ // Check first if the character is in the previously fetched line.
+
+ BidirectionalLineRunIndex bidiLineIndex = 0u;
+ CharacterIndex lastCharacterOfRightToLeftRun = 0u;
+ if( mBidirectionalLineIndex < numberOfBidirectionalLines )
+ {
+ const BidirectionalLineInfoRun& bidiLineRun = *( bidirectionalLineInfoBuffer + mBidirectionalLineIndex );
+
+ const CharacterIndex lastCharacterOfRunPlusOne = bidiLineRun.characterRun.characterIndex + bidiLineRun.characterRun.numberOfCharacters;
+ if( ( bidiLineRun.characterRun.characterIndex <= characterIndex ) &&
+ ( characterIndex < lastCharacterOfRunPlusOne ) )