From: Bowon Ryu Date: Thu, 2 Dec 2021 10:03:22 +0000 (+0900) Subject: [Tizen] Fix emoji vertical alignment issue X-Git-Tag: accepted/tizen/6.5/unified/20211213.212425^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3d2ef191d689b9a819f9629d80cee4cb3817c65;hp=48fb5ad1637fdbeafbce32263a17d7b6da14ffd7;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git [Tizen] Fix emoji vertical alignment issue This patch uses ascender, descender, yBearing of font metrics to ensure that the emoji is placed on the proper baseline when it is with a plain text glyphs. Change-Id: I9b80e84820299c95da824eac286b98dbc40ed014 Signed-off-by: Bowon Ryu --- diff --git a/dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.cpp b/dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.cpp index 40d3f32..5668718 100644 --- a/dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.cpp +++ b/dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.cpp @@ -1567,16 +1567,17 @@ FontId FontClient::Plugin::CreateFont(const FontPath& path, } else { + FT_Size_Metrics& ftMetrics = ftFace->size->metrics; + + FontMetrics metrics(static_cast(ftMetrics.ascender) * FROM_266, + static_cast(ftMetrics.descender) * FROM_266, + static_cast(ftMetrics.height) * FROM_266, + static_cast(ftFace->underline_position) * FROM_266, + static_cast(ftFace->underline_thickness) * FROM_266); + const float fixedWidth = static_cast(ftFace->available_sizes[fixedSizeIndex].width); const float fixedHeight = static_cast(ftFace->available_sizes[fixedSizeIndex].height); - // Indicate that the font is a fixed sized bitmap - FontMetrics metrics(fixedHeight, // The ascender in pixels. - 0.0f, - fixedHeight, // The height in pixels. - 0.0f, - 0.0f); - // Create the FreeType font face item to cache. FontFaceCacheItem fontFaceCacheItem(mFreeTypeLibrary, ftFace, path, requestedPointSize, faceIndex, metrics, fixedSizeIndex, fixedWidth, fixedHeight, hasColorTables); diff --git a/dali/internal/text/text-abstraction/plugin/font-face-cache-item.cpp b/dali/internal/text/text-abstraction/plugin/font-face-cache-item.cpp index 894500e..92a1ff2 100644 --- a/dali/internal/text/text-abstraction/plugin/font-face-cache-item.cpp +++ b/dali/internal/text/text-abstraction/plugin/font-face-cache-item.cpp @@ -90,9 +90,9 @@ void FontFaceCacheItem::GetFontMetrics(FontMetrics& metrics, unsigned int dpiVer { const float scaleFactor = desiredFixedSize / mFixedHeightPixels; - metrics.ascender = metrics.ascender * scaleFactor; - metrics.descender = metrics.descender * scaleFactor; - metrics.height = metrics.height * scaleFactor; + metrics.ascender = round(metrics.ascender * scaleFactor); + metrics.descender = round(metrics.descender * scaleFactor); + metrics.height = round(metrics.height * scaleFactor); metrics.underlinePosition = metrics.underlinePosition * scaleFactor; metrics.underlineThickness = metrics.underlineThickness * scaleFactor; } @@ -117,7 +117,15 @@ bool FontFaceCacheItem::GetGlyphMetrics(GlyphInfo& glyph, unsigned int dpiVertic glyph.height = mFixedHeightPixels; glyph.advance = mFixedWidthPixels; glyph.xBearing = 0.0f; - glyph.yBearing = mFixedHeightPixels; + + if(horizontal) + { + glyph.yBearing += static_cast(ftFace->glyph->metrics.horiBearingY) * FROM_266; + } + else + { + glyph.yBearing += static_cast(ftFace->glyph->metrics.vertBearingY) * FROM_266; + } // Adjust the metrics if the fixed-size font should be down-scaled const float desiredFixedSize = static_cast(mRequestedPointSize) * FROM_266 / POINTS_PER_INCH * dpiVertical; @@ -125,12 +133,11 @@ bool FontFaceCacheItem::GetGlyphMetrics(GlyphInfo& glyph, unsigned int dpiVertic if(desiredFixedSize > 0.f) { const float scaleFactor = desiredFixedSize / mFixedHeightPixels; - - glyph.width = glyph.width * scaleFactor; - glyph.height = glyph.height * scaleFactor; - glyph.advance = glyph.advance * scaleFactor; - glyph.xBearing = glyph.xBearing * scaleFactor; - glyph.yBearing = glyph.yBearing * scaleFactor; + glyph.width = round(glyph.width * scaleFactor); + glyph.height = round(glyph.height * scaleFactor); + glyph.advance = round(glyph.advance * scaleFactor); + glyph.xBearing = round(glyph.xBearing * scaleFactor); + glyph.yBearing = round(glyph.yBearing * scaleFactor); glyph.scaleFactor = scaleFactor; }