+ // If the given font is not valid, it means either:
+ // - there is no cached font for the current script yet or,
+ // - the user has set a different font than the default one for the current script or,
+ // - the platform default font is different than the default font for the current script.
+
+ // Need to check if the given font supports the current character.
+ if( !isValidFont ) // (1)
+ {
+ // Whether the current character is common for all scripts (i.e. white spaces, ...)
+
+ // Is not desirable to cache fonts for the common script.
+ //
+ // i.e. Consider the text " हिंदी", the 'white space' has assigned the DEVANAGARI script.
+ // The user may have set a font or the platform's default is used.
+ //
+ // As the 'white space' is the first character, no font is cached so the font validation
+ // retrieves a glyph from the given font.
+ //
+ // Many fonts support 'white spaces' so probably the font set by the user or the platform's default
+ // supports the 'white space'. However, that font may not support the DEVANAGARI script.
+ isCommonScript = TextAbstraction::IsCommonScript( character );
+
+ if( isCommonScript )
+ {
+ if( isValidCachedDefaultFont &&
+ ( isDefaultFont || ( currentFontId == previousFontId ) ) &&
+ !isEmojiScript )
+ {
+ // At this point the character common for all scripts has no font assigned.
+ // If there is a valid previously cached default font for it, use that one.
+ fontId = cachedDefaultFontId;
+ isValidFont = true;
+ }
+ }
+ else