From b33d3d25a946300a4ab66a59a75916d53951fc8d Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Tue, 26 Mar 2019 08:31:56 +0000 Subject: [PATCH] Bitmap Font support for Toolkit's TextLabel. * 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 --- dali/devel-api/text-abstraction/bitmap-font.cpp | 3 ++- dali/devel-api/text-abstraction/bitmap-font.h | 1 + dali/devel-api/text-abstraction/font-client.cpp | 10 ++++++---- dali/devel-api/text-abstraction/font-client.h | 10 ++++++---- .../text/text-abstraction/font-client-plugin-impl.cpp | 13 ++++++++++--- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/dali/devel-api/text-abstraction/bitmap-font.cpp b/dali/devel-api/text-abstraction/bitmap-font.cpp index 4e17df5..7b9b5d0 100755 --- a/dali/devel-api/text-abstraction/bitmap-font.cpp +++ b/dali/devel-api/text-abstraction/bitmap-font.cpp @@ -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() diff --git a/dali/devel-api/text-abstraction/bitmap-font.h b/dali/devel-api/text-abstraction/bitmap-font.h index 53bbec2..a3c3272 100755 --- a/dali/devel-api/text-abstraction/bitmap-font.h +++ b/dali/devel-api/text-abstraction/bitmap-font.h @@ -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 diff --git a/dali/devel-api/text-abstraction/font-client.cpp b/dali/devel-api/text-abstraction/font-client.cpp index 30acb9e..4f9172a 100755 --- a/dali/devel-api/text-abstraction/font-client.cpp +++ b/dali/devel-api/text-abstraction/font-client.cpp @@ -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 } { } diff --git a/dali/devel-api/text-abstraction/font-client.h b/dali/devel-api/text-abstraction/font-client.h index 6197656..2c95f9c 100755 --- a/dali/devel-api/text-abstraction/font-client.h +++ b/dali/devel-api/text-abstraction/font-client.h @@ -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. }; /** diff --git a/dali/internal/text/text-abstraction/font-client-plugin-impl.cpp b/dali/internal/text/text-abstraction/font-client-plugin-impl.cpp index 41e9a72..a53fd1b 100755 --- a/dali/internal/text/text-abstraction/font-client-plugin-impl.cpp +++ b/dali/internal/text/text-abstraction/font-client-plugin-impl.cpp @@ -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; } -- 2.7.4