From c6c96dd86d283e8014a23a49842e70e4ab50f3ac Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Wed, 10 Jan 2018 16:06:04 -0500 Subject: Improve correctness of SkiaCanvas::drawLayoutOnPath Align glyph to a tangent touching SkPath in the midle of the symbol. Previously wrong tangent crossing the path at the beginning of the glyph was used. Test: Ran the test app attached to the bug Bug: 71525360 Change-Id: I310394d11e185de314f66a6b332f804188e42ed9 --- libs/hwui/SkiaCanvas.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libs/hwui/SkiaCanvas.cpp') diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp index 13e1ebec943e..2e08670a757a 100644 --- a/libs/hwui/SkiaCanvas.cpp +++ b/libs/hwui/SkiaCanvas.cpp @@ -765,7 +765,8 @@ void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, for (size_t i = start; i < end; i++) { glyphs[i - start] = layout.getGlyphId(i); - float x = hOffset + layout.getX(i); + float halfWidth = layout.getCharAdvance(i) * 0.5f; + float x = hOffset + layout.getX(i) + halfWidth; float y = vOffset + layout.getY(i); SkPoint pos; @@ -776,8 +777,8 @@ void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, } xform[i - start].fSCos = tan.x(); xform[i - start].fSSin = tan.y(); - xform[i - start].fTx = pos.x() - tan.y() * y; - xform[i - start].fTy = pos.y() + tan.x() * y; + xform[i - start].fTx = pos.x() - tan.y() * y - halfWidth * tan.x(); + xform[i - start].fTy = pos.y() + tan.x() * y - halfWidth * tan.y(); } this->asSkCanvas()->drawTextRSXform(glyphs, sizeof(uint16_t) * N, xform, nullptr, paint); -- cgit v1.2.3-59-g8ed1b