From 170e0949f3c67decaa67d3fcce6a9776268691ff Mon Sep 17 00:00:00 2001 From: Seigo Nonaka Date: Mon, 19 Oct 2020 23:14:04 -0700 Subject: Fix wrong offset of BiDi text by TextShaper This CL includes: - Fix relative offset of BidiRun by reviving width calculation in TextLine. - Fix bidi level buffer offset. It shuold be relative to the substring, but the absolute offset was passed. - Removed paint argument from PositionedGlyph which is not used. Bug: 171275519 Test: atest android.graphics.text.cts.TextRunShaperTest Test: atest android.text.cts.TextShaperTest Change-Id: I36949089d744bdfae61995210b2051866a7510ac --- core/java/android/text/TextShaper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'core/java/android/text/TextShaper.java') diff --git a/core/java/android/text/TextShaper.java b/core/java/android/text/TextShaper.java index dd2570401b3e..02fd7b4470f0 100644 --- a/core/java/android/text/TextShaper.java +++ b/core/java/android/text/TextShaper.java @@ -198,6 +198,10 @@ public class TextShaper { /** * Shape multi-styled text. * + * In the LTR context, the shape result will go from left to right, thus you may want to draw + * glyphs from left most position of the canvas. In the RTL context, the shape result will go + * from right to left, thus you may want to draw glyphs from right most position of the canvas. + * * @param text a styled text. * @param start a start index of shaping target in the text. * @param count a length of shaping target in the text. @@ -215,7 +219,7 @@ public class TextShaper { try { tl.set(paint, text, start, start + count, mp.getParagraphDir(), - mp.getDirections(start, start + count), + mp.getDirections(0, count), false /* tabstop is not supported */, null, -1, -1 // ellipsis is not supported. -- cgit v1.2.3