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

Commit 77b4dc9b authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Fix the inconsitent paragraph

The previous fix was not complete. The previous fix was removing
CR characters from the buffer because Android does not use CR
as a paragraph separator. However there are few more characters
that are used for breaking paragraph in BiDi algorithm.

Use the BiDi properties instead of directly specifying CR code
point.

Bug: 330051215
Test: StaticLayoutTest#testNotCrashByCRCharacter_other_B_properties
Change-Id: I0e209e90eb5ee7ea572188894ff19bc5e27ab5a6
parent dd3bd465
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.text.LineBreakConfig;
import android.graphics.text.MeasuredText;
import android.icu.lang.UCharacter;
import android.icu.lang.UCharacterDirection;
import android.icu.text.Bidi;
import android.text.AutoGrowArray.ByteArray;
import android.text.AutoGrowArray.FloatArray;
@@ -711,7 +713,12 @@ public class MeasuredParagraph {
                // check the paragraph count here and replace the CR letters and re-calculate
                // BiDi again.
                for (int i = 0; i < mTextLength; ++i) {
                    if (mCopiedBuffer[i] == '\r') {
                    if (Character.isSurrogate(mCopiedBuffer[i])) {
                        // All block separators are in BMP.
                        continue;
                    }
                    if (UCharacter.getDirection(mCopiedBuffer[i])
                            == UCharacterDirection.BLOCK_SEPARATOR) {
                        mCopiedBuffer[i] = OBJECT_REPLACEMENT_CHARACTER;
                    }
                }