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=4c68a74d5bd6613f97bd7aa26d9c06eb468a63b6;hp=f6a9a2293716614dc8b52e820cb9df8930d8faba;hb=3047bf4954ccfd8f4d185dc79fe2128b088315b9;hpb=d83ef802ea8a21da2707c0053267064f6c1e8af7 diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index f6a9a22..4c68a74 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -23,12 +23,12 @@ #include #include #include +#include // INTERNAL INCLUDES -#include -#include -#include -#include +#include +#include +#include namespace Dali { @@ -36,6 +36,15 @@ namespace Dali namespace Toolkit { +namespace +{ +#if defined(DEBUG_ENABLED) +Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_MULTI_LANGUAGE_SUPPORT"); +#endif + +const Dali::Toolkit::Text::Character UTF32_A = 0x0041; +} + namespace Text { @@ -125,13 +134,13 @@ Script GetScript( Length index, */ bool IsValidForAllScripts( Character character ) { - return ( IsWhiteSpace( character ) || - IsZeroWidthNonJoiner( character ) || - IsZeroWidthJoiner( character ) || - IsZeroWidthSpace( character ) || - IsLeftToRightMark( character ) || - IsRightToLeftMark( character ) || - IsThinSpace( character ) ); + return ( TextAbstraction::IsWhiteSpace( character ) || + TextAbstraction::IsZeroWidthNonJoiner( character ) || + TextAbstraction::IsZeroWidthJoiner( character ) || + TextAbstraction::IsZeroWidthSpace( character ) || + TextAbstraction::IsLeftToRightMark( character ) || + TextAbstraction::IsRightToLeftMark( character ) || + TextAbstraction::IsThinSpace( character ) ); } bool ValidateFontsPerScript::FindValidFont( FontId fontId ) const @@ -285,14 +294,14 @@ void MultilanguageSupport::SetScripts( const Vector& text, } // Get the script of the character. - Script script = GetCharacterScript( character ); + Script script = TextAbstraction::GetCharacterScript( character ); // Check if it is the first character of a paragraph. if( firstValidScript && ( TextAbstraction::UNKNOWN != script ) ) { // Sets the direction of the first valid script. - isParagraphRTL = ( TextAbstraction::ARABIC == script ); + isParagraphRTL = TextAbstraction::IsRightToLeftScript( script ); firstValidScript = false; } @@ -300,7 +309,7 @@ void MultilanguageSupport::SetScripts( const Vector& text, { // Current run needs to be stored and a new one initialized. - if( isParagraphRTL != ( TextAbstraction::ARABIC == script ) ) + if( isParagraphRTL != TextAbstraction::IsRightToLeftScript( script ) ) { // Current script has different direction than the first script of the paragraph. // All the previously skipped characters need to be added to the previous script before it's stored. @@ -353,6 +362,13 @@ void MultilanguageSupport::SetScripts( const Vector& text, } } +void MultilanguageSupport::ReplaceScripts( LogicalModel& model, + CharacterIndex characterIndex, + Length numberOfCharactersToRemove, + Length numberOfCharactersToInsert ) +{ +} + void MultilanguageSupport::ValidateFonts( const Vector& text, const Vector& scripts, Vector& fonts ) @@ -489,9 +505,27 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, // If the cache has not a default font, get one from the font client. if( 0u == fontId ) { + // Emojis are present in many monochrome fonts; prefer color by default. + bool preferColor = ( TextAbstraction::EMOJI == script ); + // Find a default font. - fontId = fontClient.FindDefaultFont( character, pointSize ); + fontId = fontClient.FindDefaultFont( character, pointSize, preferColor ); + // If the system does not support a suitable font, fallback to Latin + if( 0u == fontId ) + { + fontId = *( defaultFontPerScriptCacheBuffer + TextAbstraction::LATIN ); + } + if( 0u == fontId ) + { + fontId = fontClient.FindDefaultFont( UTF32_A, pointSize ); + } + +#ifdef DEBUG_ENABLED + Dali::TextAbstraction::FontDescription description; + fontClient.GetDescription( fontId, description ); + DALI_LOG_INFO( gLogFilter, Debug::Concise, "Script: %s; Selected font: %s\n", Dali::TextAbstraction::ScriptName[script], description.path.c_str() ); +#endif // Cache the font. *( defaultFontPerScriptCacheBuffer + script ) = fontId; } @@ -528,6 +562,13 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, } } +void MultilanguageSupport::ValidateFonts( LogicalModel& model, + CharacterIndex characterIndex, + Length numberOfCharactersToRemove, + Length numberOfCharactersToInsert ) +{ +} + } // namespace Internal } // namespace Text