[DO NOT MERGE] Prevent TextInterpolator from rendering nonprintable newlines am: f50aadd281

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19606003

Change-Id: I6e5dfa0cfca20c570477a1065d2583e5f0ad8773
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Hawkwood Glazier
2022-08-15 20:28:05 +00:00
committed by Automerger Merge Worker

View File

@@ -485,7 +485,13 @@ class TextInterpolator(
val out = mutableListOf<List<PositionedGlyphs>>()
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<PositionedGlyphs>()
TextShaper.shapeText(layout.text, lineStart, count, layout.textDirectionHeuristic,
paint) { _, _, glyphs, _ ->