- // If no character is matched, then the last character (in visual order) of the line is used.
- visualIndex = endCharacter;
+ if( isBeforeFirstGlyph )
+ {
+ // If no character is matched, then the first character (in visual order) of the line is used.
+ visualIndex = startCharacter;
+ }
+ else
+ {
+ // If no character is matched, then the last character (in visual order) of the line is used.
+ visualIndex = endCharacter;
+ }