- // The user may have set the default font. Check it. Otherwise check in the valid fonts cache.
- if( fontId != *( defaultFontPerScriptCacheBuffer + 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;
+ }
+ }
+ else