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

Commit bbff6dae authored by chenjean's avatar chenjean
Browse files

fix(HCT): White Outline with white text when text following an emoji

Goal: Ensure the accurate rendering of the background rectangle color(e.g. white text with black background) for text following an emoji, irrespective of any intervening whitespace.

Root Cause:
1. The text color is updated during the emoji character processing in determineContrastingBackgroundColor, but the bgPaint update is skipped due to the 'skip draw background on emoji' condition in onCharacterBounds. Consequently, subsequent text color change checks return "no text color change", resulting in the return of an incorrect bgPaint color.
2. The first text character immediately following an emoji being affected by the emoji's transparency, producing an incorrect background color. (This issue does not occur with 'Emoji + space + text' patterns.)
3. Emojis composed of two characters cause the second character to be incorrectly identified as non-emoji, triggering premature text color updates.

Solution:
1. Implement synchronized updates for both the text color and bgPaint.
2. Update SpanColors.getColorAt() to match Spanned.SPAN_INCLUSIVE_EXCLUSIVE.
3. In emoji processing, consider only the first character for emoji identification.

Bug: 401070918
Flag: com.android.graphics.hwui.flags.high_contrast_text_small_text_rect
Test: manually test on emoji case (e.g. "emoji + space + text", "emoji + text")
Test: atest core/tests/coretests/src/android/text/LayoutTest.java
Test: atest core/tests/coretests/src/android/text/SpanColorsTest.java
Test: atest cts/tests/tests/uirendering/src/android/uirendering/cts/testclasses/TextViewHighContrastTextTests.kt
Change-Id: I096b2e026d6963e8e574e2ae26d9ac5abfc926e7
parent 82a0eeda
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment