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-helper-functions.cpp;h=731b89d6643c0b3b46b53a6921d9c64cde696063;hp=a5feaefdd692299b080e212f44c887ce98e727bd;hb=3e30971f9884dc48e80ef82de4ef85fc9dba1229;hpb=cdefdbdee1cb3fd4051e220bb185d97b6000a037 diff --git a/dali-toolkit/internal/text/multi-language-helper-functions.cpp b/dali-toolkit/internal/text/multi-language-helper-functions.cpp index a5feaef..731b89d 100644 --- a/dali-toolkit/internal/text/multi-language-helper-functions.cpp +++ b/dali-toolkit/internal/text/multi-language-helper-functions.cpp @@ -32,6 +32,7 @@ namespace Text void MergeFontDescriptions( const Vector& fontDescriptions, Vector& fontIds, + Vector& isDefaultFont, const TextAbstraction::FontDescription& defaultFontDescription, TextAbstraction::PointSize26Dot6 defaultPointSize, CharacterIndex startIndex, @@ -43,19 +44,39 @@ void MergeFontDescriptions( const Vector& fontDescriptions, // Pointer to the font id buffer. FontId* fontIdsBuffer = fontIds.Begin(); + // Pointer to the 'is default' font buffer. + bool* isDefaultFontBuffer = isDefaultFont.Begin(); + + // Used to temporarily store the style per character. + TextAbstraction::FontDescription fontDescription; + TextAbstraction::PointSize26Dot6 fontSize; + + Length familyIndex = 0u; + Length weightIndex = 0u; + Length widthIndex = 0u; + Length slantIndex = 0u; + Length sizeIndex = 0u; + // Traverse all the characters. - for( CharacterIndex index = startIndex; index < numberOfCharacters; ++index ) + const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters; + for( CharacterIndex index = startIndex; index < lastCharacterPlusOne; ++index ) { - // The default font description and font point size. - TextAbstraction::FontDescription fontDescription = defaultFontDescription; - TextAbstraction::PointSize26Dot6 fontSize = defaultPointSize; - bool defaultFont = true; + bool& defaultFont = *(isDefaultFontBuffer + index - startIndex ); + + Length runIndex = 0u; + + bool familyOverriden = false; + bool weightOverriden = false; + bool widthOverriden = false; + bool slantOverriden = false; + bool sizeOverriden = false; // Traverse all the font descriptions. - for( Vector::ConstIterator it = fontDescriptions.Begin(), + const FontDescriptionRun* const fontDescriptionsBuffer = fontDescriptions.Begin(); + for( Vector::ConstIterator it = fontDescriptionsBuffer, endIt = fontDescriptions.End(); it != endIt; - ++it ) + ++it, ++runIndex ) { // Check whether the character's font is modified by the current font description. const FontDescriptionRun& fontRun = *it; @@ -64,28 +85,33 @@ void MergeFontDescriptions( const Vector& fontDescriptions, { if( fontRun.familyDefined ) { - fontDescription.family = std::string( fontRun.familyName, fontRun.familyLength ); defaultFont = false; + familyOverriden = true; + familyIndex = runIndex; } if( fontRun.weightDefined ) { - fontDescription.weight = fontRun.weight; defaultFont = false; + weightOverriden = true; + weightIndex = runIndex; } if( fontRun.widthDefined ) { - fontDescription.width = fontRun.width; defaultFont = false; + widthOverriden = true; + widthIndex = runIndex; } if( fontRun.slantDefined ) { - fontDescription.slant = fontRun.slant; defaultFont = false; + slantOverriden = true; + slantIndex = runIndex; } if( fontRun.sizeDefined ) { - fontSize = fontRun.size; defaultFont = false; + sizeOverriden = true; + sizeIndex = runIndex; } } } @@ -93,6 +119,56 @@ void MergeFontDescriptions( const Vector& fontDescriptions, // Get the font id if is not the default font. if( !defaultFont ) { + if( familyOverriden ) + { + const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + familyIndex ); + fontDescription.family = std::string( fontRun.familyName, fontRun.familyLength ); // TODO Could use move constructor when switch to c++11. + } + else + { + fontDescription.family = defaultFontDescription.family; + } + + if( weightOverriden ) + { + const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + weightIndex ); + fontDescription.weight = fontRun.weight; + } + else + { + fontDescription.weight = defaultFontDescription.weight; + } + + if( widthOverriden ) + { + const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + widthIndex ); + fontDescription.width = fontRun.width; + } + else + { + fontDescription.width = defaultFontDescription.width; + } + + if( slantOverriden ) + { + const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + slantIndex ); + fontDescription.slant = fontRun.slant; + } + else + { + fontDescription.slant = defaultFontDescription.slant; + } + + if( sizeOverriden ) + { + const FontDescriptionRun& fontRun = *( fontDescriptionsBuffer + sizeIndex ); + fontSize = fontRun.size; + } + else + { + fontSize = defaultPointSize; + } + *( fontIdsBuffer + index - startIndex ) = fontClient.GetFontId( fontDescription, fontSize ); } }