From f50aadd281c3bc1ef6848ab9af7a21d82882c277 Mon Sep 17 00:00:00 2001 From: Hawkwood Glazier Date: Fri, 12 Aug 2022 13:40:56 +0000 Subject: [PATCH] [DO NOT MERGE] Prevent TextInterpolator from rendering nonprintable newlines This is a smaller piece of a larger cherry-pick which is being taken ahead of the full set to resolve merge conflicts in other work. Test: Manual Bug: 229771520 Change-Id: Ibf1396c4570d891439a73dad0909ab05e6c3119a --- .../com/android/systemui/animation/TextInterpolator.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt index ff64c78911285..d427a57f3b87e 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt @@ -485,7 +485,13 @@ class TextInterpolator( val out = mutableListOf>() for (lineNo in 0 until layout.lineCount) { // Shape all lines. val lineStart = layout.getLineStart(lineNo) - val count = layout.getLineEnd(lineNo) - lineStart + var count = layout.getLineEnd(lineNo) - lineStart + // Do not render the last character in the line if it's a newline and unprintable + val last = lineStart + count - 1 + if (last > lineStart && last < layout.text.length && layout.text[last] == '\n') { + count-- + } + val runs = mutableListOf() TextShaper.shapeText(layout.text, lineStart, count, layout.textDirectionHeuristic, paint) { _, _, glyphs, _ ->