return false;
}
+FontId DefaultFonts::FindFont( TextAbstraction::FontClient& fontClient, PointSize26Dot6 size ) const
+{
+ for( Vector<FontId>::ConstIterator it = mFonts.Begin(),
+ endIt = mFonts.End();
+ it != endIt;
+ ++it )
+ {
+ const FontId fontId = *it;
+ if( size == fontClient.GetPointSize( fontId ) )
+ {
+ return fontId;
+ }
+ }
+
+ return 0u;
+}
+
MultilanguageSupport::MultilanguageSupport()
: mDefaultFontPerScriptCache(),
mValidFontsPerScriptCache()
{
// Initializes the default font cache to zero (invalid font).
// Reserves space to cache the default fonts and access them with the script as an index.
- mDefaultFontPerScriptCache.Resize( TextAbstraction::UNKNOWN, 0u );
+ mDefaultFontPerScriptCache.Resize( TextAbstraction::UNKNOWN, NULL );
// Initializes the valid fonts cache to NULL (no valid fonts).
// Reserves space to cache the valid fonts and access them with the script as an index.
MultilanguageSupport::~MultilanguageSupport()
{
- // Destroy the valid fonts per script cache.
+ // Destroy the default font per script cache.
+ for( Vector<DefaultFonts*>::Iterator it = mDefaultFontPerScriptCache.Begin(),
+ endIt = mDefaultFontPerScriptCache.End();
+ it != endIt;
+ ++it )
+ {
+ delete *it;
+ }
+ // Destroy the valid fonts per script cache.
for( Vector<ValidateFontsPerScript*>::Iterator it = mValidFontsPerScriptCache.Begin(),
endIt = mValidFontsPerScriptCache.End();
it != endIt;
// Traverse the characters and validate/set the fonts.
// Get the caches.
- FontId* defaultFontPerScriptCacheBuffer = mDefaultFontPerScriptCache.Begin();
+ DefaultFonts** defaultFontPerScriptCacheBuffer = mDefaultFontPerScriptCache.Begin();
ValidateFontsPerScript** validFontsPerScriptCacheBuffer = mValidFontsPerScriptCache.Begin();
// Stores the validated font runs.
Vector<ScriptRun>::ConstIterator scriptRunEndIt = scripts.End();
bool isNewParagraphCharacter = false;
+ PointSize26Dot6 currentPointSize = defaultPointSize;
+ FontId currentFontId = 0u;
+
CharacterIndex lastCharacter = startIndex + numberOfCharacters;
for( Length index = startIndex; index < lastCharacter; ++index )
{
scriptRunIt,
scriptRunEndIt );
+ // Get the current point size.
+ if( currentFontId != fontId )
+ {
+ currentPointSize = fontClient.GetPointSize( fontId );
+ currentFontId = fontId;
+ }
+
#ifdef DEBUG_ENABLED
{
Dali::TextAbstraction::FontDescription description;
// Check first in the caches.
+ DefaultFonts* defaultFonts = *( defaultFontPerScriptCacheBuffer + script );
+ FontId cachedDefaultFontId = 0u;
+ if( NULL != defaultFonts )
+ {
+ cachedDefaultFontId = defaultFonts->FindFont( fontClient, currentPointSize );
+ }
+
// The user may have set the default font. Check it. Otherwise check in the valid fonts cache.
- if( fontId != *( defaultFontPerScriptCacheBuffer + script ) )
+ if( fontId != cachedDefaultFontId )
{
// Check in the valid fonts cache.
ValidateFontsPerScript* validateFontsPerScript = *( validFontsPerScriptCacheBuffer + script );
if( 0u == fontId )
{
// The character has no font assigned. Get a default one from the cache
- fontId = *( defaultFontPerScriptCacheBuffer + script );
+ fontId = cachedDefaultFontId;
// If the cache has not a default font, get one from the font client.
if( 0u == fontId )
bool preferColor = ( TextAbstraction::EMOJI == script );
// Find a fallback-font.
- fontId = fontClient.FindFallbackFont( preferredFont, character, defaultPointSize, preferColor );
+ fontId = fontClient.FindFallbackFont( preferredFont, character, currentPointSize, preferColor );
// If the system does not support a suitable font, fallback to Latin
+ DefaultFonts* latinDefaults = NULL;
if( 0u == fontId )
{
- fontId = *( defaultFontPerScriptCacheBuffer + TextAbstraction::LATIN );
+ latinDefaults = *( defaultFontPerScriptCacheBuffer + TextAbstraction::LATIN );
+ if( NULL != latinDefaults )
+ {
+ fontId = latinDefaults->FindFont( fontClient, currentPointSize );
+ }
}
+
if( 0u == fontId )
{
- fontId = fontClient.FindDefaultFont( UTF32_A, defaultPointSize );
+ fontId = fontClient.FindDefaultFont( UTF32_A, currentPointSize );
}
// Cache the font.
- *( defaultFontPerScriptCacheBuffer + script ) = fontId;
+ if( NULL == latinDefaults )
+ {
+ latinDefaults = new DefaultFonts();
+ *( defaultFontPerScriptCacheBuffer + script ) = latinDefaults;
+ }
+ latinDefaults->mFonts.PushBack( fontId );
}
}