From deca4cf3f3125804f83d352a077aa08c6ff95728 Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Thu, 11 Aug 2016 15:56:04 +0100 Subject: [PATCH 1/1] Multilanguage support cache issue fix. * Need to cache the font description used to query a default font instead using the one retrieved from the font id. Change-Id: Iee97a5e09c5e77fb3d24dc32e321d4413cdbbf2b Signed-off-by: Victor Cebollada --- .../internal/text/multi-language-support-impl.cpp | 31 +++++++++++++--------- .../internal/text/multi-language-support-impl.h | 10 ++++++- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 750fab7..ae9a68b 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -67,27 +67,34 @@ FontId DefaultFonts::FindFont( TextAbstraction::FontClient& fontClient, const TextAbstraction::FontDescription& description, PointSize26Dot6 size ) const { - for( Vector::ConstIterator it = mFonts.Begin(), - endIt = mFonts.End(); + for( std::vector::const_iterator it = mFonts.begin(), + endIt = mFonts.end(); it != endIt; ++it ) { - const FontId fontId = *it; - TextAbstraction::FontDescription fontDescription; - fontClient.GetDescription( fontId, fontDescription ); - - if( ( size == fontClient.GetPointSize( fontId ) ) && - ( description.weight == fontDescription.weight ) && - ( description.width == fontDescription.width ) && - ( description.slant == fontDescription.slant ) ) + const CacheItem& item = *it; + + if( ( ( TextAbstraction::FontWeight::NONE == description.weight ) || ( description.weight == item.description.weight ) ) && + ( ( TextAbstraction::FontWidth::NONE == description.width ) || ( description.width == item.description.width ) ) && + ( ( TextAbstraction::FontSlant::NONE == description.slant ) || ( description.slant == item.description.slant ) ) && + ( size == fontClient.GetPointSize( item.fontId ) ) && + ( description.family.empty() || ( description.family == item.description.family ) ) ) { - return fontId; + return item.fontId; } } return 0u; } +void DefaultFonts::Cache( const TextAbstraction::FontDescription& description, FontId fontId ) +{ + CacheItem item; + item.description = description; + item.fontId = fontId; + mFonts.push_back( item ); +} + MultilanguageSupport::MultilanguageSupport() : mDefaultFontPerScriptCache(), mValidFontsPerScriptCache() @@ -654,7 +661,7 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript; } } - defaultFontsPerScript->mFonts.PushBack( fontId ); + defaultFontsPerScript->Cache( currentFontDescription, fontId ); } } // !isValidFont (3) } // !isValidFont (2) diff --git a/dali-toolkit/internal/text/multi-language-support-impl.h b/dali-toolkit/internal/text/multi-language-support-impl.h index 3f568a2..afbeb23 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.h +++ b/dali-toolkit/internal/text/multi-language-support-impl.h @@ -77,6 +77,12 @@ struct ValidateFontsPerScript */ struct DefaultFonts { + struct CacheItem + { + TextAbstraction::FontDescription description; + FontId fontId ; + }; + /** * Default constructor. */ @@ -103,7 +109,9 @@ struct DefaultFonts const TextAbstraction::FontDescription& description, PointSize26Dot6 size ) const; - Vector mFonts; + void Cache( const TextAbstraction::FontDescription& description, FontId fontId ); + + std::vector mFonts; }; /** -- 2.7.4