+ Character character = *( textBuffer + index );
+
+ // Get the script of the character.
+ Script script = TextAbstraction::GetCharacterScript( character );
+
+ // Some characters (like white spaces) are valid for many scripts. The rules to set a script
+ // for them are:
+ // - If they are at the begining of a paragraph they get the script of the first character with
+ // a defined script. If they are at the end, they get the script of the last one.
+ // - If they are between two scripts with the same direction, they get the script of the previous
+ // character with a defined script. If the two scripts have different directions, they get the
+ // script of the first character of the paragraph with a defined script.
+
+ // Skip those characters valid for many scripts like white spaces or '\n'.
+ bool endOfText = index == numberOfCharacters;
+ while( !endOfText &&
+ ( TextAbstraction::COMMON == script ) )
+ {
+ // Count all these characters to be added into a script.
+ ++numberOfAllScriptCharacters;