Merge "DALi Version 1.1.41" into devel/master
authorPaul Wisbey <p.wisbey@samsung.com>
Fri, 1 Jul 2016 13:49:44 +0000 (06:49 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 1 Jul 2016 13:49:44 +0000 (06:49 -0700)
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp
dali-toolkit/internal/text/metrics.h
dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/internal/text/text-controller.cpp

index cd0c19d..63c89d3 100644 (file)
@@ -149,9 +149,9 @@ public:
   bool IsScalable( const FontDescription& fontDescription ){return true;}
   void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes ){}
   void GetFixedSizes( const FontDescription& fontDescription, Dali::Vector< PointSize26Dot6 >& sizes ){}
-  void GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize ){}
+  void GetFontMetrics( FontId fontId, FontMetrics& metrics ){}
   GlyphIndex GetGlyphIndex( FontId fontId, Character charcode ){return 0;}
-  bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal, int desiredFixedSize ){return true;}
+  bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal ){return true;}
   BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex ){return BufferImage();}
   void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob,
                          unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
@@ -447,9 +447,9 @@ void FontClient::GetFixedSizes( const FontDescription& fontDescription,
   GetImplementation(*this).GetFixedSizes( fontDescription, sizes );
 }
 
-void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize )
+void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
 {
-  GetImplementation(*this).GetFontMetrics( fontId, metrics, desiredFixedSize );
+  GetImplementation(*this).GetFontMetrics( fontId, metrics );
 }
 
 GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
@@ -457,9 +457,9 @@ GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
   return GetImplementation(*this).GetGlyphIndex( fontId, charcode );
 }
 
-bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal, int desiredFixedSize )
+bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
 {
-  return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal, desiredFixedSize );
+  return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal );
 }
 
 BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
index 232360e..ad4ed41 100644 (file)
@@ -38,7 +38,7 @@ class Metrics;
 typedef IntrusivePtr<Metrics> MetricsPtr;
 
 /**
- * @brief A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics.
+ * @brief A wrapper around FontClient used to get metrics.
  */
 class Metrics : public RefObject
 {
@@ -63,26 +63,6 @@ public:
   }
 
   /**
-   * @brief Set the maximum Emoji size.
-   *
-   * @param[in] emojiSize Emoticons will be scaled to fit this size in pixels.
-   */
-  void SetMaxEmojiSize( int emojiSize )
-  {
-    mEmojiSize = emojiSize;
-  }
-
-  /**
-   * @brief Get the maximum Emoji size.
-   *
-   * @return The maximum Emoji size.
-   */
-  int GetMaxEmojiSize() const
-  {
-    return mEmojiSize;
-  }
-
-  /**
    * @brief Query the metrics for a font.
    *
    * @param[in] fontId The ID of the font for the required glyph.
@@ -90,7 +70,7 @@ public:
    */
   void GetFontMetrics( FontId fontId, FontMetrics& metrics )
   {
-    mFontClient.GetFontMetrics( fontId, metrics, mEmojiSize ); // inline for performance
+    mFontClient.GetFontMetrics( fontId, metrics ); // inline for performance
   }
 
   /**
@@ -104,7 +84,7 @@ public:
    */
   bool GetGlyphMetrics( GlyphInfo* array, uint32_t size )
   {
-    return mFontClient.GetGlyphMetrics( array, size, mGlyphType, true, mEmojiSize ); // inline for performance
+    return mFontClient.GetGlyphMetrics( array, size, mGlyphType, true ); // inline for performance
   }
 
 protected:
@@ -121,10 +101,8 @@ private:
    */
   Metrics( TextAbstraction::FontClient& fontClient )
   : mFontClient( fontClient ),
-    mGlyphType( TextAbstraction::BITMAP_GLYPH ),
-    mEmojiSize( 0 )
-  {
-  }
+    mGlyphType( TextAbstraction::BITMAP_GLYPH )
+  {}
 
   // Undefined
   Metrics(const Metrics&);
@@ -136,7 +114,6 @@ private:
 
   TextAbstraction::FontClient mFontClient;
   TextAbstraction::GlyphType mGlyphType;
-  int mEmojiSize;
 };
 
 } // namespace Text
index 1e8abf2..1a72243 100644 (file)
@@ -211,6 +211,19 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
     while( !endOfText &&
            ( TextAbstraction::COMMON == script ) )
     {
+      if( TextAbstraction::EMOJI == currentScriptRun.script )
+      {
+        // Emojis doesn't mix well with characters common to all scripts. Insert the emoji run.
+        scripts.Insert( scripts.Begin() + scriptIndex, currentScriptRun );
+        ++scriptIndex;
+
+        // Initialize the new one.
+        currentScriptRun.characterRun.characterIndex = currentScriptRun.characterRun.characterIndex + currentScriptRun.characterRun.numberOfCharacters;
+        currentScriptRun.characterRun.numberOfCharacters = 0u;
+        currentScriptRun.script = TextAbstraction::UNKNOWN;
+        numberOfAllScriptCharacters = 0u;
+      }
+
       // Count all these characters to be added into a script.
       ++numberOfAllScriptCharacters;
 
@@ -248,7 +261,7 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
         character = *( textBuffer + index );
         script = TextAbstraction::GetCharacterScript( character );
       }
-    }
+    } // end while( !endOfText && ( TextAbstraction::COMMON == script ) )
 
     if( endOfText )
     {
@@ -260,7 +273,8 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
     // Check if it is the first character of a paragraph.
     if( isFirstScriptToBeSet &&
         ( TextAbstraction::UNKNOWN != script ) &&
-        ( TextAbstraction::COMMON != script ) )
+        ( TextAbstraction::COMMON != script ) &&
+        ( TextAbstraction::EMOJI != script ) )
     {
       // Sets the direction of the first valid script.
       isParagraphRTL = TextAbstraction::IsRightToLeftScript( script );
@@ -288,6 +302,13 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
         currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
         numberOfAllScriptCharacters = 0u;
       }
+      else if( ( TextAbstraction::UNKNOWN == currentScriptRun.script ) &&
+               ( TextAbstraction::EMOJI == script ) )
+      {
+        currentScriptRun.script = TextAbstraction::LATIN;
+        currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
+        numberOfAllScriptCharacters = 0u;
+      }
 
       if( 0u != currentScriptRun.characterRun.numberOfCharacters )
       {
@@ -435,6 +456,7 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
   PointSize26Dot6 currentPointSize = defaultPointSize;
   FontId currentFontId = 0u;
   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.
@@ -497,6 +519,23 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
     isValidFont = isValidCachedDefaultFont && ( fontId == cachedDefaultFontId );
 
     bool isCommonScript = false;
+    bool isEmojiScript = TextAbstraction::EMOJI == script;
+
+    if( isEmojiScript && !isPreviousEmojiScript )
+    {
+      if( 0u != currentFontRun.characterRun.numberOfCharacters )
+      {
+        // Store the font run.
+        fonts.Insert( fonts.Begin() + fontIndex, currentFontRun );
+        ++fontIndex;
+      }
+
+      // Initialize the new one.
+      currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters;
+      currentFontRun.characterRun.numberOfCharacters = 0u;
+      currentFontRun.fontId = fontId;
+    }
+
 
     // If the given font is not valid, it means either:
     // - there is no cached font for the current script yet or,
@@ -523,7 +562,8 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
       if( isCommonScript )
       {
         if( isValidCachedDefaultFont &&
-            ( isDefault || ( currentFontId == previousFontId ) )  )
+            ( isDefault || ( currentFontId == previousFontId ) ) &&
+            !isEmojiScript )
         {
           // 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.
@@ -551,7 +591,7 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
 
           // Emojis are present in many monochrome fonts; prefer color by default.
           if( isValidFont &&
-              ( TextAbstraction::EMOJI == script ) )
+              isEmojiScript )
           {
             const BufferImage bitmap = fontClient.CreateBitmap( fontId, glyphIndex );
 
@@ -611,8 +651,13 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
               // Cache the font.
               if( NULL == defaultFontsPerScript )
               {
-                defaultFontsPerScript = new DefaultFonts();
-                *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript;
+                defaultFontsPerScript = *( defaultFontPerScriptCacheBuffer + script );
+
+                if( NULL == defaultFontsPerScript )
+                {
+                  defaultFontsPerScript = new DefaultFonts();
+                  *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript;
+                }
               }
               defaultFontsPerScript->mFonts.PushBack( fontId );
             }
@@ -670,6 +715,7 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
     // Whether the current character is a new paragraph character.
     isNewParagraphCharacter = TextAbstraction::IsNewParagraph( character );
     previousFontId = currentFontId;
+    isPreviousEmojiScript = isEmojiScript;
   } // end traverse characters.
 
   if( 0u != currentFontRun.characterRun.numberOfCharacters )
index 96a2dc3..8175be4 100644 (file)
@@ -40,7 +40,6 @@ namespace
 #endif
 
 const float MAX_FLOAT = std::numeric_limits<float>::max();
-const unsigned int POINTS_PER_INCH = 72;
 
 const std::string EMPTY_STRING("");
 
@@ -491,15 +490,6 @@ void Controller::SetDefaultPointSize( float pointSize )
   mImpl->mFontDefaults->mDefaultPointSize = pointSize;
   mImpl->mFontDefaults->sizeDefined = true;
 
-  unsigned int horizontalDpi( 0u );
-  unsigned int verticalDpi( 0u );
-  mImpl->mFontClient.GetDpi( horizontalDpi, verticalDpi );
-
-  // Adjust the metrics if the fixed-size font should be down-scaled
-  int maxEmojiSize( pointSize/POINTS_PER_INCH * verticalDpi );
-  DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultPointSize %p setting MaxEmojiSize %d\n", this, maxEmojiSize );
-  mImpl->mMetrics->SetMaxEmojiSize( maxEmojiSize );
-
   // Clear the font-specific data
   ClearFontData();