Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02d8ee41 authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Fix width calculation of TextView

The width of TextView should be drawing left offset to the right
most bounding box or total amount of advance.

Bug: 336410046
Test: atest CtsTextTestCases
Test: atest CtsGraphicsTestCases
Test: atest CtsViewTestCases
Test: atest CtsWidgetTestCases
Change-Id: I09888ca8ac7d8a149c75b129f23ffe034571291a
parent dd3bd465
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -477,7 +477,12 @@ public class TextLine {
            }
            drawBounds.setEmpty();
            float w = measure(mLen, false, fmi, drawBounds, lineInfo);
            float boundsWidth = drawBounds.width();
            float boundsWidth;
            if (w >= 0) {
                boundsWidth = Math.max(drawBounds.right, w) - Math.min(0, drawBounds.left);
            } else {
                boundsWidth = Math.max(drawBounds.right, 0) - Math.min(w, drawBounds.left);
            }
            if (Math.abs(w) > boundsWidth) {
                return w;
            } else {
+4 −2
Original line number Diff line number Diff line
@@ -11254,8 +11254,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                width = des;
            } else {
                if (mUseBoundsForWidth) {
                    width = Math.max(boring.width,
                            (int) Math.ceil(boring.getDrawingBoundingBox().width()));
                    RectF bbox = boring.getDrawingBoundingBox();
                    float rightMax = Math.max(bbox.right, boring.width);
                    float leftMin = Math.min(bbox.left, 0);
                    width = Math.max(boring.width, (int) Math.ceil(rightMax - leftMin));
                } else {
                    width = boring.width;
                }