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=020a5cbe38d9a2b9385029c6d694d4d62b8b6606;hp=750fab78dd24baa0c8b7f0df0f63abd6521f965b;hb=efb94d8c348a12264e102ccf085ab5d707c85826;hpb=a632f8445619b331bc1cf1ae95b14d84a024a281 diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 750fab7..020a5cb 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,27 +67,34 @@ FontId DefaultFonts::FindFont( TextAbstraction::FontClient& fontClient, const TextAbstraction::FontDescription& description, PointSize26Dot6 size ) const { - for( Vector::ConstIterator it = mFonts.Begin(), - endIt = mFonts.End(); + for( std::vector::const_iterator it = mFonts.begin(), + endIt = mFonts.end(); it != endIt; ++it ) { - const FontId fontId = *it; - TextAbstraction::FontDescription fontDescription; - fontClient.GetDescription( fontId, fontDescription ); - - if( ( size == fontClient.GetPointSize( fontId ) ) && - ( description.weight == fontDescription.weight ) && - ( description.width == fontDescription.width ) && - ( description.slant == fontDescription.slant ) ) + const CacheItem& item = *it; + + if( ( ( TextAbstraction::FontWeight::NONE == description.weight ) || ( description.weight == item.description.weight ) ) && + ( ( TextAbstraction::FontWidth::NONE == description.width ) || ( description.width == item.description.width ) ) && + ( ( TextAbstraction::FontSlant::NONE == description.slant ) || ( description.slant == item.description.slant ) ) && + ( size == fontClient.GetPointSize( item.fontId ) ) && + ( description.family.empty() || ( description.family == item.description.family ) ) ) { - return fontId; + return item.fontId; } } return 0u; } +void DefaultFonts::Cache( const TextAbstraction::FontDescription& description, FontId fontId ) +{ + CacheItem item; + item.description = description; + item.fontId = fontId; + mFonts.push_back( item ); +} + MultilanguageSupport::MultilanguageSupport() : mDefaultFontPerScriptCache(), mValidFontsPerScriptCache() @@ -470,9 +477,9 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, currentFontId = fontId; // Get the script for the current character. - const Script script = GetScript( index, - scriptRunIt, - scriptRunEndIt ); + Script script = GetScript( index, + scriptRunIt, + scriptRunEndIt ); #ifdef DEBUG_ENABLED { @@ -487,6 +494,10 @@ 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; @@ -558,7 +569,6 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, // At this point the character common for all scripts has no font assigned. // If there is a valid previously cached default font for it, use that one. fontId = cachedDefaultFontId; - isValidFont = true; } } else @@ -583,10 +593,8 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, if( isValidFont && isEmojiScript ) { - const PixelData bitmap = fontClient.CreateBitmap( fontId, glyphIndex ); - - // For color emojis, the font is valid if the bitmap is RGBA. - isValidFont = bitmap && ( Pixel::BGRA8888 == bitmap.GetPixelFormat() ); + // For color emojis, the font is valid if the glyph is a color glyph (the bitmap is RGBA). + isValidFont = fontClient.IsColorGlyph( fontId, glyphIndex ); } // If there is a valid font, cache it. @@ -605,8 +613,9 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, if( !isValidFont ) // (3) { // The given font has not been validated. + int validCharacterIndex = fontClient.GetGlyphIndex(cachedDefaultFontId, character ); - if( isValidCachedDefaultFont ) + if( isValidCachedDefaultFont && validCharacterIndex != 0u ) { // Use the cached default font for the script if there is one. fontId = cachedDefaultFontId; @@ -654,7 +663,7 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript; } } - defaultFontsPerScript->mFonts.PushBack( fontId ); + defaultFontsPerScript->Cache( currentFontDescription, fontId ); } } // !isValidFont (3) } // !isValidFont (2)