From e35ca21bd433d168db25fb82306c62f39b69954c Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 7 Jun 2022 22:42:50 +0900 Subject: [PATCH] Fix bug when we use bitmap font. We can use custom bitmap font without using glyph. In this case, glyphBuffer can be RGBA. Current logic assume that glyphBuffer only L8 if isColor is false. This patch it that case works well Change-Id: Ia68bfb4a292cb4bc34f4041b55f2a9d661e58df7 Signed-off-by: Eunki, Hong --- dali-toolkit/internal/text/rendering/text-typesetter.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.cpp b/dali-toolkit/internal/text/rendering/text-typesetter.cpp index 30f76fc..2689ffb 100644 --- a/dali-toolkit/internal/text/rendering/text-typesetter.cpp +++ b/dali-toolkit/internal/text/rendering/text-typesetter.cpp @@ -96,8 +96,9 @@ void TypesetGlyph(GlyphData& data, const int32_t xOffset = data.horizontalOffset + position->x; // Whether the given glyph is a color one. - const bool isColorGlyph = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap; - const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format); + const bool isColorGlyph = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap; + const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format); + const uint32_t glyphAlphaIndex = glyphPixelSize - 1u; // Determinate iterator range. const int32_t lineIndexRangeMin = std::max(0, -yOffset); @@ -204,7 +205,7 @@ void TypesetGlyph(GlyphData& data, for(int32_t index = indexRangeMin; index < indexRangeMax; ++index) { // Update the alpha channel. - const uint8_t alpha = *(glyphBuffer + index); + const uint8_t alpha = *(glyphBuffer + index * glyphPixelSize + glyphAlphaIndex); // Copy non-transparent pixels only if(alpha > 0u) @@ -259,7 +260,7 @@ void TypesetGlyph(GlyphData& data, // Skip basic line. bitmapBuffer += (lineIndexRangeMin + yOffset) * static_cast(data.width); - glyphBuffer += (lineIndexRangeMin) * static_cast(data.glyphBitmap.width); + glyphBuffer += (lineIndexRangeMin) * static_cast(data.glyphBitmap.width) * glyphPixelSize; // Traverse the pixels of the glyph line per line. for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex) @@ -269,7 +270,7 @@ void TypesetGlyph(GlyphData& data, const int32_t xOffsetIndex = xOffset + index; // Update the alpha channel. - const uint8_t alpha = *(glyphBuffer + index); + const uint8_t alpha = *(glyphBuffer + index * glyphPixelSize + glyphAlphaIndex); // Copy non-transparent pixels only if(alpha > 0u) @@ -286,7 +287,7 @@ void TypesetGlyph(GlyphData& data, } bitmapBuffer += data.width; - glyphBuffer += data.glyphBitmap.width; + glyphBuffer += data.glyphBitmap.width * glyphPixelSize; } } } -- 2.7.4