diff options
author | Stan Iliev <stani@google.com> | 2018-01-10 16:06:04 -0500 |
---|---|---|
committer | Stan Iliev <stani@google.com> | 2018-01-11 14:44:51 -0500 |
commit | c6c96dd86d283e8014a23a49842e70e4ab50f3ac (patch) | |
tree | 7925e581372f31e20ebbb4c7b73c830b677a80e0 /libs/hwui/SkiaCanvas.cpp | |
parent | 3101268dd8d7597e5df61093fce87fa914b2e717 (diff) |
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
Diffstat (limited to 'libs/hwui/SkiaCanvas.cpp')
-rw-r--r-- | libs/hwui/SkiaCanvas.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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); |