+ if( splitStartGlyph )
+ {
+ // If the first glyph is a ligature that must be broken it may be needed to add only part of the glyph to the highlight box.
+
+ const float glyphAdvance = glyph.advance / static_cast<float>( numberOfCharactersStart );
+ const CharacterIndex interGlyphIndex = selectionStart - *( glyphToCharacterBuffer + glyphStart );
+ // Get the direction of the character.
+ CharacterDirection isCurrentRightToLeft = false;
+ if( NULL != modelCharacterDirectionsBuffer ) // If modelCharacterDirectionsBuffer is NULL, it means the whole text is left to right.
+ {
+ isCurrentRightToLeft = *( modelCharacterDirectionsBuffer + selectionStart );
+ }
+
+ // The end point could be in the middle of the ligature.
+ // Calculate the number of characters selected.
+ const Length numberOfCharacters = ( glyphStart == glyphEnd ) ? ( selectionEnd - selectionStart ) : ( numberOfCharactersStart - interGlyphIndex );
+
+ const float xPosition = position.x - glyph.xBearing + offset.x + glyphAdvance * static_cast<float>( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex );
+
+ mEventData->mDecorator->AddHighlight( xPosition,
+ offset.y,
+ xPosition + static_cast<float>( numberOfCharacters ) * glyphAdvance,
+ height );
+
+ splitStartGlyph = false;
+ continue;
+ }
+
+ if( splitEndGlyph && ( index == glyphEnd ) )
+ {
+ // Equally, if the last glyph is a ligature that must be broken it may be needed to add only part of the glyph to the highlight box.
+
+ const float glyphAdvance = glyph.advance / static_cast<float>( numberOfCharactersEnd );
+ const CharacterIndex interGlyphIndex = selectionEnd - *( glyphToCharacterBuffer + glyphEnd );
+ // Get the direction of the character.
+ CharacterDirection isCurrentRightToLeft = false;
+ if( NULL != modelCharacterDirectionsBuffer ) // If modelCharacterDirectionsBuffer is NULL, it means the whole text is left to right.
+ {
+ isCurrentRightToLeft = *( modelCharacterDirectionsBuffer + selectionEnd );
+ }
+
+ const Length numberOfCharacters = numberOfCharactersEnd - interGlyphIndex;
+
+ const float xPosition = position.x - glyph.xBearing + offset.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast<float>( numberOfCharacters ) ) : 0.f );
+ mEventData->mDecorator->AddHighlight( xPosition,
+ offset.y,
+ xPosition + static_cast<float>( interGlyphIndex ) * glyphAdvance,
+ height );
+
+ splitEndGlyph = false;
+ continue;
+ }
+