+ // Count the number of characters which are valid for all scripts. i.e. white spaces or '\n'.
+ Length numberOfAllScriptCharacters = 0u;
+
+ // Pointers to the text and break info buffers.
+ const Character* const textBuffer = text.Begin();
+
+ // Traverse all characters and set the scripts.
+ for( Length index = 0u; index < numberOfCharacters; ++index )
+ {
+ 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 ) )