X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fmulti-language-support-impl.cpp;h=6ca96ad284b10a8ed37223829b2a95c2312762f4;hb=0686e6d654472bffc56910890f39031ceac32d3b;hp=e88a28617efb61a2bc88be28cd0440695eb0040b;hpb=d9e73542cfca2591f40ca9ffeefa1e20e0c2bbd0;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 e88a286..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,16 +440,18 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, FontId previousFontId = 0u; bool isPreviousEmojiScript = false; - // Whether it's the first set of characters to be validated. - // Used in case the paragraph starts with characters common to all scripts. - bool isFirstSetToBeValidated = true; + // 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; @@ -494,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; @@ -674,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) @@ -705,15 +695,22 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, } #endif - if( isFirstSetToBeValidated && !isCommonScript ) + if( fontId != currentFontRun.fontId ) { - currentFontRun.fontId = fontId; - isFirstSetToBeValidated = false; + 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. @@ -728,11 +725,8 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters; currentFontRun.characterRun.numberOfCharacters = 0u; currentFontRun.fontId = fontId; - - if( isNewParagraphCharacter ) - { - isFirstSetToBeValidated = true; - } + currentFontRun.softwareItalic = needSoftwareItalic; + currentFontRun.softwareBold = needSoftwareBoldening; } // Add one more character to the run.