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

Commit 3e7432f8 authored by Kenny Root's avatar Kenny Root Committed by Android (Google) Code Review
Browse files

Merge "Fix IndexOutOfBoundsException when measuring text."

parents d94e4c50 23241887
Loading
Loading
Loading
Loading
+25 −18
Original line number Diff line number Diff line
@@ -216,8 +216,10 @@ extends Layout

            boolean tab = false;

            int spanEnd;
            for (int spanStart = paraStart; spanStart < paraEnd; spanStart = spanEnd) {
            for (int spanStart = paraStart, spanEnd = spanStart, nextSpanStart;
                    spanStart < paraEnd; spanStart = nextSpanStart) {

                if (spanStart == spanEnd) {
                    if (spanned == null)
                        spanEnd = paraEnd;
                    else
@@ -225,9 +227,6 @@ extends Layout
                                MetricAffectingSpan.class);

                    int spanLen = spanEnd - spanStart;
                int startInPara = spanStart - paraStart;
                int endInPara = spanEnd - paraStart;

                    if (spanned == null) {
                        measured.addStyleRun(paint, spanLen, fm);
                    } else {
@@ -235,6 +234,11 @@ extends Layout
                            spanned.getSpans(spanStart, spanEnd, MetricAffectingSpan.class);
                        measured.addStyleRun(paint, spans, spanLen, fm);
                    }
                }

                nextSpanStart = spanEnd;
                int startInPara = spanStart - paraStart;
                int endInPara = spanEnd - paraStart;

                int fmtop = fm.top;
                int fmbottom = fm.bottom;
@@ -432,7 +436,10 @@ extends Layout
                        }

                        if (here < spanStart) {
                            j = spanEnd = here; // must remeasure
                            // didn't output all the text for this span
                            // we've measured the raw widths, though, so
                            // just reset the start point
                            j = nextSpanStart = here;
                        } else {
                            j = here - 1;    // continue looping
                        }