X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fmulti-language-support-impl.cpp;h=6ca96ad284b10a8ed37223829b2a95c2312762f4;hb=85c7065a159374bac65ff799a0a977f930b8e694;hp=990d0cee26f06657e5df27b3fe02bfa21f2e7956;hpb=149fa4a2bd6765eef1601be6957c6f608876be38;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 990d0ce..6ca96ad 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -101,11 +101,11 @@ MultilanguageSupport::MultilanguageSupport() { // 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, NULL ); + mDefaultFontPerScriptCache.Resize( TextAbstraction::UNKNOWN + 1, 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. - mValidFontsPerScriptCache.Resize( TextAbstraction::UNKNOWN, NULL ); + mValidFontsPerScriptCache.Resize( TextAbstraction::UNKNOWN + 1, NULL ); } MultilanguageSupport::~MultilanguageSupport() @@ -254,10 +254,6 @@ void MultilanguageSupport::SetScripts( const Vector& text, currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters; // Store the script run. - if( TextAbstraction::UNKNOWN == currentScriptRun.script ) - { - currentScriptRun.script = TextAbstraction::LATIN; - } scripts.Insert( scripts.Begin() + scriptIndex, currentScriptRun ); ++scriptIndex; @@ -320,7 +316,6 @@ void MultilanguageSupport::SetScripts( const Vector& text, else if( ( TextAbstraction::UNKNOWN == currentScriptRun.script ) && ( TextAbstraction::EMOJI == script ) ) { - currentScriptRun.script = TextAbstraction::LATIN; currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters; numberOfAllScriptCharacters = 0u; } @@ -357,12 +352,6 @@ void MultilanguageSupport::SetScripts( const Vector& text, if( 0u != currentScriptRun.characterRun.numberOfCharacters ) { - if( TextAbstraction::UNKNOWN == currentScriptRun.script ) - { - // There are only white spaces in the last script. Set the latin script. - currentScriptRun.script = TextAbstraction::LATIN; - } - // Store the last run. scripts.Insert( scripts.Begin() + scriptIndex, currentScriptRun ); ++scriptIndex; @@ -451,12 +440,18 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, FontId previousFontId = 0u; bool isPreviousEmojiScript = false; + // Description of fallback font which is selected at current iteration. + TextAbstraction::FontDescription selectedFontDescription; + CharacterIndex lastCharacter = startIndex + numberOfCharacters; for( Length index = startIndex; index < lastCharacter; ++index ) { // Get the current character. const Character character = *( textBuffer + index ); + bool needSoftwareBoldening = false; + bool needSoftwareItalic = false; + // new description for current character TextAbstraction::FontDescription currentFontDescription; TextAbstraction::PointSize26Dot6 currentFontPointSize = defaultFontPointSize; bool isDefaultFont = true; @@ -490,10 +485,6 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, description.path.c_str() ); } #endif - if( script == TextAbstraction::UNKNOWN ) - { - script = TextAbstraction::LATIN; - } // Validate whether the current character is supported by the given font. bool isValidFont = false; @@ -670,18 +661,21 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, fontId = fontClient.FindDefaultFont( UTF32_A, currentFontPointSize ); } - // Cache the font. - if( NULL == defaultFontsPerScript ) + if ( script != TextAbstraction::UNKNOWN ) { - defaultFontsPerScript = *( defaultFontPerScriptCacheBuffer + script ); - + // Cache the font if it is not an unknown script if( NULL == defaultFontsPerScript ) { - defaultFontsPerScript = new DefaultFonts(); - *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript; + defaultFontsPerScript = *( defaultFontPerScriptCacheBuffer + script ); + + if( NULL == defaultFontsPerScript ) + { + defaultFontsPerScript = new DefaultFonts(); + *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript; + } } + defaultFontsPerScript->Cache( currentFontDescription, fontId ); } - defaultFontsPerScript->Cache( currentFontDescription, fontId ); } } // !isValidFont (3) } // !isValidFont (2) @@ -701,9 +695,22 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, } #endif + if( fontId != currentFontRun.fontId ) + { + fontClient.GetDescription(fontId,selectedFontDescription); + } + + // Developer sets bold to character but selected font cannot support it + needSoftwareBoldening = ( currentFontDescription.weight >= TextAbstraction::FontWeight::BOLD ) && ( selectedFontDescription.weight < TextAbstraction::FontWeight::BOLD ); + + // Developer sets italic to character but selected font cannot support it + needSoftwareItalic = ( currentFontDescription.slant == TextAbstraction::FontSlant::ITALIC ) && ( selectedFontDescription.slant < TextAbstraction::FontSlant::ITALIC ); + // The font is now validated. if( ( fontId != currentFontRun.fontId ) || - isNewParagraphCharacter ) + isNewParagraphCharacter || + // If font id is same as previous but style is diffrent, initialize new one + ( ( fontId == currentFontRun.fontId ) && ( ( needSoftwareBoldening != currentFontRun.softwareBold ) || ( needSoftwareItalic != currentFontRun.softwareItalic ) ) ) ) { // Current run needs to be stored and a new one initialized. @@ -718,6 +725,8 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters; currentFontRun.characterRun.numberOfCharacters = 0u; currentFontRun.fontId = fontId; + currentFontRun.softwareItalic = needSoftwareItalic; + currentFontRun.softwareBold = needSoftwareBoldening; } // Add one more character to the run.