From: minho.sun Date: Mon, 12 Feb 2018 11:35:33 +0000 (+0900) Subject: [4.0] clear cache when locale is changed X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d62b4611f4b6c4bcb870451759754dc39bc91e0;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [4.0] clear cache when locale is changed When locale is change, font configuration might provide a different font list. In this case, original cached font might not be valid for same script. Therefore, we need to clear caches. Change-Id: I76b2f195be323a87b9076c8b11575f306336225a Signed-off-by: minho.sun --- diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 723a343..df31e56 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -40,6 +40,7 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_MULT #endif const Dali::Toolkit::Text::Character UTF32_A = 0x0041; + } namespace Text @@ -98,7 +99,8 @@ void DefaultFonts::Cache( const TextAbstraction::FontDescription& description, F MultilanguageSupport::MultilanguageSupport() : mDefaultFontPerScriptCache(), - mValidFontsPerScriptCache() + mValidFontsPerScriptCache(), + mSlotDelegate( this ) { // 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. @@ -121,6 +123,22 @@ MultilanguageSupport::MultilanguageSupport() } } + // Connect LanguageChangedSignal to clear caches when locale is changed. + Dali::Adaptor::Get().LanguageChangedSignal().Connect( mSlotDelegate, &Dali::Toolkit::Text::Internal::MultilanguageSupport::OnLanguageChanged ); +} + +void MultilanguageSupport::OnLanguageChanged( Dali::Adaptor& adaptor ) +{ + // When locale is changed, font configuration might provide a different font list. + // In this case, the original cached font might not be valid for same script. + // Therefore, we need to clear caches. + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.ClearCache(); + + mDefaultFontPerScriptCache.Clear(); + mValidFontsPerScriptCache.Clear(); + mDefaultFontPerScriptCache.Resize( TextAbstraction::UNKNOWN + 1, NULL ); + mValidFontsPerScriptCache.Resize( TextAbstraction::UNKNOWN + 1, NULL ); } MultilanguageSupport::~MultilanguageSupport() diff --git a/dali-toolkit/internal/text/multi-language-support-impl.h b/dali-toolkit/internal/text/multi-language-support-impl.h index c9a7d30..7fc88a3 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.h +++ b/dali-toolkit/internal/text/multi-language-support-impl.h @@ -23,6 +23,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -133,6 +134,14 @@ public: */ ~MultilanguageSupport(); + + /** + * Dali::MultilanguageSupport::OnLanguageChanged() + * + * Get notice when system language is changed. + */ + void OnLanguageChanged( Dali::Adaptor& adaptor ); + /** * @copydoc Dali::MultilanguageSupport::Get() */ @@ -159,8 +168,9 @@ public: Vector& fonts ); private: - Vector mDefaultFontPerScriptCache; ///< Caches default fonts for a script. - Vector mValidFontsPerScriptCache; ///< Caches valid fonts for a script. + Vector mDefaultFontPerScriptCache; ///< Caches default fonts for a script. + Vector mValidFontsPerScriptCache; ///< Caches valid fonts for a script. + SlotDelegate< MultilanguageSupport > mSlotDelegate; //< SlotDelegate to listen LanguageChangedSignal. }; } // namespace Internal