diff options
author | 2018-03-14 15:03:13 -0400 | |
---|---|---|
committer | 2018-03-14 15:03:13 -0400 | |
commit | 415a74b565a4d8c8c266706fd2fc1ab4874e6040 (patch) | |
tree | 7e41b1485125d57dfed11e017f4029a8ce519dc5 /libs/hwui/SkiaCanvas.cpp | |
parent | 186ea1218ee5dcb7650d0759a2af4b61af166cbe (diff) |
Update text alignment when using drawTextOnPath.
This is only a partial fix for the bug, but does ensure that Skia
doesn't attempt to realign the text after minikin already has.
Test: CtsGraphicsTestCases and test app in bug.
Bug: 25360203
Change-Id: I6222963b23b910f0261f562f8816604575d540fa
Diffstat (limited to 'libs/hwui/SkiaCanvas.cpp')
-rw-r--r-- | libs/hwui/SkiaCanvas.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp index 2b0b22df7edf..40b811d813fd 100644 --- a/libs/hwui/SkiaCanvas.cpp +++ b/libs/hwui/SkiaCanvas.cpp @@ -764,6 +764,13 @@ void SkiaCanvas::drawGlyphs(ReadGlyphFunc glyphFunc, int count, const SkPaint& p void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset, const SkPaint& paint, const SkPath& path, size_t start, size_t end) { + // Set align to left for drawing, as we don't want individual + // glyphs centered or right-aligned; the offsets take care of + // that portion of the alignment. + SkPaint paintCopy(paint); + paintCopy.setTextAlign(SkPaint::kLeft_Align); + SkASSERT(paintCopy.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); + const int N = end - start; SkAutoSTMalloc<1024, uint8_t> storage(N * (sizeof(uint16_t) + sizeof(SkRSXform))); SkRSXform* xform = (SkRSXform*)storage.get(); @@ -788,7 +795,7 @@ void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, xform[i - start].fTy = pos.y() + tan.x() * y - halfWidth * tan.y(); } - this->asSkCanvas()->drawTextRSXform(glyphs, sizeof(uint16_t) * N, xform, nullptr, paint); + this->asSkCanvas()->drawTextRSXform(glyphs, sizeof(uint16_t) * N, xform, nullptr, paintCopy); } // ---------------------------------------------------------------------------- |