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

Commit d27b2f20 authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Remove unnecessary letter spaceing from the left and right of line

This CL is a groundwork for the inter character justification.
The letter spacing should not be added to the left most character
and right most character.

Bug: 283193133
Test: atest FrameworksCoreTests:android.text.TextLineLetterSpacingTest
Test: atest CtsTextTestCases
Change-Id: I28ac4f9f3b7520d7518d34f06ea9c05907cad9a6
parent 6b2c10db
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -16400,6 +16400,8 @@ package android.graphics {
    field public static final int START_HYPHEN_EDIT_NO_EDIT = 0; // 0x0
    field public static final int STRIKE_THRU_TEXT_FLAG = 16; // 0x10
    field public static final int SUBPIXEL_TEXT_FLAG = 128; // 0x80
    field @FlaggedApi("com.android.text.flags.inter_character_justification") public static final int TEXT_RUN_FLAG_LEFT_EDGE = 8192; // 0x2000
    field @FlaggedApi("com.android.text.flags.inter_character_justification") public static final int TEXT_RUN_FLAG_RIGHT_EDGE = 16384; // 0x4000
    field public static final int UNDERLINE_TEXT_FLAG = 8; // 0x8
  }
+22 −6
Original line number Diff line number Diff line
@@ -671,9 +671,18 @@ public class MeasuredParagraph {
        if (mLtrWithoutBidi) {
            // If the whole text is LTR direction, just apply whole region.
            if (builder == null) {
                // For the compatibility reasons, the letter spacing should not be dropped at the
                // left and right edge.
                int oldFlag = paint.getFlags();
                paint.setFlags(paint.getFlags()
                        | (Paint.TEXT_RUN_FLAG_LEFT_EDGE | Paint.TEXT_RUN_FLAG_RIGHT_EDGE));
                try {
                    mWholeWidth += paint.getTextRunAdvances(
                        mCopiedBuffer, start, end - start, start, end - start, false /* isRtl */,
                        mWidths.getRawArray(), start);
                            mCopiedBuffer, start, end - start, start, end - start,
                            false /* isRtl */, mWidths.getRawArray(), start);
                } finally {
                    paint.setFlags(oldFlag);
                }
            } else {
                builder.appendStyleRun(paint, config, end - start, false /* isRtl */);
            }
@@ -690,9 +699,16 @@ public class MeasuredParagraph {
                    final boolean isRtl = (level & 0x1) != 0;
                    if (builder == null) {
                        final int levelLength = levelEnd - levelStart;
                        int oldFlag = paint.getFlags();
                        paint.setFlags(paint.getFlags()
                                | (Paint.TEXT_RUN_FLAG_LEFT_EDGE | Paint.TEXT_RUN_FLAG_RIGHT_EDGE));
                        try {
                            mWholeWidth += paint.getTextRunAdvances(
                                    mCopiedBuffer, levelStart, levelLength, levelStart, levelLength,
                                    isRtl, mWidths.getRawArray(), levelStart);
                        } finally {
                            paint.setFlags(oldFlag);
                        }
                    } else {
                        builder.appendStyleRun(paint, config, levelEnd - levelStart, isRtl);
                    }
+153 −31

File changed.

Preview size limit exceeded, changes collapsed.

+224 −0

File added.

Preview size limit exceeded, changes collapsed.

+129 −40

File changed.

Preview size limit exceeded, changes collapsed.

Loading