+
+ if( 0u == numberOfCharacters )
+ {
+ // TODO: This is a workaround to fix an issue with complex characters in the arabic
+ // script like i.e. رّ or الأَبْجَدِيَّة العَرَبِيَّة
+ // There are characters that are not shaped in one glyph but in combination with
+ // the next one generates two of them.
+ // The visual to logical conversion table have characters in different order than
+ // expected even if all of them are arabic.
+
+ // The workaround doesn't fix the issue completely but it prevents the application
+ // to hang in an infinite loop.
+
+ // Find the number of characters.
+ for( GlyphIndex index = firstLogicalGlyphIndex + 1u;
+ ( 0u == numberOfCharacters ) && ( index < totalNumberOfGlyphs ) ;
+ ++index )
+ {
+ numberOfCharacters = *( charactersPerGlyphBuffer + index );
+ }
+
+ if( 2u > numberOfCharacters )
+ {
+ continue;
+ }
+
+ --numberOfCharacters;
+ }
+