X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fmulti-language-support-impl.cpp;h=41ba5acc11e768d0cd6b05b531a4d4dbfe23d1f6;hp=5a5c0d855921ea12b495f3bd024588eede90fb22;hb=HEAD;hpb=95013c942f6d2cf8f62d828569446cd168c8f2cd diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 5a5c0d8..41ba5ac 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include #include @@ -256,7 +257,8 @@ void DefaultFonts::Cache(const TextAbstraction::FontDescription& description, Fo MultilanguageSupport::MultilanguageSupport() : mDefaultFontPerScriptCache(), - mValidFontsPerScriptCache() + mValidFontsPerScriptCache(), + mLocale(std::string()) { // 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. @@ -265,6 +267,11 @@ MultilanguageSupport::MultilanguageSupport() // 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. mValidFontsPerScriptCache.Resize(TextAbstraction::GetNumberOfScripts(), NULL); + + if(Dali::Adaptor::IsAvailable()) + { + Dali::Adaptor::Get().LocaleChangedSignal().Connect(this, &MultilanguageSupport::OnLocaleChanged); + } } MultilanguageSupport::~MultilanguageSupport() @@ -288,6 +295,29 @@ MultilanguageSupport::~MultilanguageSupport() } } +void MultilanguageSupport::OnLocaleChanged(std::string locale) +{ + if(mLocale != locale) + { + mLocale = locale; + ClearCache(); + } +} + +void MultilanguageSupport::ClearCache() +{ + mDefaultFontPerScriptCache.Clear(); + mValidFontsPerScriptCache.Clear(); + + mDefaultFontPerScriptCache.Resize(TextAbstraction::GetNumberOfScripts(), NULL); + mValidFontsPerScriptCache.Resize(TextAbstraction::GetNumberOfScripts(), NULL); +} + +std::string MultilanguageSupport::GetLocale() +{ + return mLocale; +} + Text::MultilanguageSupport MultilanguageSupport::Get() { Text::MultilanguageSupport multilanguageSupportHandle; @@ -633,7 +663,6 @@ void MultilanguageSupport::ValidateFonts(const Vector& Vector::ConstIterator scriptRunEndIt = scripts.End(); bool isNewParagraphCharacter = false; - FontId previousEmojiFontId = 0u; FontId currentFontId = 0u; FontId previousFontId = 0u; TextAbstraction::Script previousScript = TextAbstraction::UNKNOWN; @@ -710,15 +739,16 @@ void MultilanguageSupport::ValidateFonts(const Vector& isValidFont = fontClient.IsCharacterSupportedByFont(fontId, character); } - bool isCommonScript = false; - bool isEmojiScript = TextAbstraction::IsOneOfEmojiScripts(script); + bool isEmojiScript = IsEmojiColorScript(script) || IsEmojiTextScript(script); + bool isZWJ = TextAbstraction::IsZeroWidthJoiner(character); - if(isEmojiScript && (previousScript == script)) + if((previousScript == script) && + (isEmojiScript || isZWJ)) { - // Emoji sequence should use the previous emoji font. - if(0u != previousEmojiFontId) + // This sequence should use the previous font. + if(0u != previousFontId) { - fontId = previousEmojiFontId; + fontId = previousFontId; isValidFont = true; } } @@ -732,6 +762,9 @@ void MultilanguageSupport::ValidateFonts(const Vector& isValidFont = true; } + // This is valid after CheckFontSupportsCharacter(); + bool isCommonScript = false; + // 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, @@ -778,19 +811,6 @@ void MultilanguageSupport::ValidateFonts(const Vector& } } - // Store the font id when the first character is an emoji. - if(isEmojiScript) - { - if(0u != fontId && previousScript != script) - { - previousEmojiFontId = fontId; - } - } - else - { - previousEmojiFontId = 0u; - } - #ifdef DEBUG_ENABLED if(gLogFilter->IsEnabledFor(Debug::Verbose)) { @@ -849,6 +869,7 @@ void MultilanguageSupport::ValidateFonts(const Vector& // Whether the current character is a new paragraph character. isNewParagraphCharacter = TextAbstraction::IsNewParagraph(character); previousScript = script; + currentFontId = fontId; previousFontId = currentFontId; } // end traverse characters.