Bitmap Font support for Toolkit's TextLabel. 61/202261/6
authorVictor Cebollada <v.cebollada@samsung.com>
Tue, 26 Mar 2019 08:31:56 +0000 (08:31 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 9 Apr 2019 12:27:23 +0000 (12:27 +0000)
* Toolkit's TextLabel renderer needs to know if the glyphs
  of a bitmap font use their own color or they are just an
  alpha mask.

Change-Id: I07f2dea3931c5072b84c1ff484b2dee966bb297c
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali/devel-api/text-abstraction/bitmap-font.cpp
dali/devel-api/text-abstraction/bitmap-font.h
dali/devel-api/text-abstraction/font-client.cpp
dali/devel-api/text-abstraction/font-client.h
dali/internal/text/text-abstraction/font-client-plugin-impl.cpp

index 4e17df5..7b9b5d0 100755 (executable)
@@ -47,7 +47,8 @@ BitmapFont::BitmapFont()
   ascender{ 0.f },
   descender{ 0.f },
   underlinePosition{ 0.f },
-  underlineThickness{ 1.f }
+  underlineThickness{ 1.f },
+  isColorFont{ false }
 {}
 
 BitmapFont::~BitmapFont()
index 53bbec2..a3c3272 100755 (executable)
@@ -97,6 +97,7 @@ struct DALI_ADAPTOR_API BitmapFont
   float descender;                 ///< The descender in pixels. Minimum descender of all the glyphs.
   float underlinePosition;         ///< The position in pixels of the underline from the base line.
   float underlineThickness;        ///< The thickness in pixels of the underline.
+  bool isColorFont:1;              ///< Whether the glyphs of this font have their own colors.
 };
 
 } // namespace TextAbstraction
index 30acb9e..4f9172a 100755 (executable)
@@ -31,10 +31,12 @@ const PointSize26Dot6 FontClient::DEFAULT_POINT_SIZE = 768u; // 12*64
 const float FontClient::DEFAULT_ITALIC_ANGLE = 12.f * Dali::Math::PI_OVER_180; // FreeType documentation states the software italic is done by doing a horizontal shear of 12 degrees (file ftsynth.h).
 
 FontClient::GlyphBufferData::GlyphBufferData()
-: buffer( nullptr ),
-  width( 0u ),
-  height( 0u ),
-  format( Pixel::A8 )
+: buffer{ nullptr },
+  width{ 0u },
+  height{ 0u },
+  format{ Pixel::A8 },
+  isColorEmoji{ false },
+  isColorBitmap{ false }
 {
 }
 
index 6197656..2c95f9c 100755 (executable)
@@ -84,10 +84,12 @@ public:
      */
     ~GlyphBufferData();
 
-    unsigned char* buffer; ///< The glyph's bitmap buffer data.
-    unsigned int   width;  ///< The width of the bitmap.
-    unsigned int   height; ///< The height of the bitmap.
-    Pixel::Format  format; ///< The pixel's format of the bitmap.
+    unsigned char* buffer;          ///< The glyph's bitmap buffer data.
+    unsigned int   width;           ///< The width of the bitmap.
+    unsigned int   height;          ///< The height of the bitmap.
+    Pixel::Format  format;          ///< The pixel's format of the bitmap.
+    bool           isColorEmoji:1;  ///< Whether the glyph is an emoji.
+    bool           isColorBitmap:1; ///< Whether the glyph is a color bitmap.
   };
 
   /**
index 41e9a72..a53fd1b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -1376,6 +1376,9 @@ void FontClient::Plugin::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, boo
   if( ( fontId > 0u ) &&
       ( index < mFontIdCache.Count() ) )
   {
+    data.isColorBitmap = false;
+    data.isColorEmoji = false;
+
     const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
 
     switch( fontIdCacheItem.type )
@@ -1466,6 +1469,8 @@ void FontClient::Plugin::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, boo
             ConvertBitmap( data, ftFace->glyph->bitmap, isShearRequired );
           }
 
+          data.isColorEmoji = fontFaceCacheItem.mIsFixedSizeBitmap;
+
           // Created FT_Glyph object must be released with FT_Done_Glyph
           FT_Done_Glyph( glyph );
         }
@@ -1494,6 +1499,8 @@ void FontClient::Plugin::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, boo
           data.width = pixelBuffer.GetWidth();
           data.height = pixelBuffer.GetHeight();
 
+          data.isColorBitmap = bitmapFontCacheItem.font.isColorFont;
+
           ConvertBitmap( data, data.width, data.height, pixelBuffer.GetBuffer() );
 
           // Sets the pixel format.
@@ -1630,7 +1637,6 @@ bool FontClient::Plugin::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
 
   const FontId index = fontId - 1u;
 
-#ifdef FREETYPE_BITMAP_SUPPORT
   if( ( fontId > 0u ) &&
       ( index < mFontIdCache.Count() ) )
   {
@@ -1640,6 +1646,7 @@ bool FontClient::Plugin::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
     {
     case FontDescription::FACE_FONT:
     {
+#ifdef FREETYPE_BITMAP_SUPPORT
       const FontFaceCacheItem& item = mFontFaceCache[fontIdCacheItem.id];
       FT_Face ftFace = item.mFreeTypeFace;
 
@@ -1648,6 +1655,7 @@ bool FontClient::Plugin::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
       {
         error = FT_Load_Glyph( ftFace, glyphIndex, FT_LOAD_COLOR );
       }
+#endif
       break;
     }
     case FontDescription::BITMAP_FONT:
@@ -1661,7 +1669,6 @@ bool FontClient::Plugin::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
     }
     }
   }
-#endif
 
   return FT_Err_Ok == error;
 }