Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,10 @@ internal object TextLayoutManager {
paint.letterSpacing = baseTextAttributes.letterSpacing
}

if (baseTextAttributes.isColorSet) {
baseTextAttributes.color?.let { paint.color = it }
}

if (
baseTextAttributes.fontStyle != ReactConstants.UNSET ||
baseTextAttributes.fontWeight != ReactConstants.UNSET ||
Expand Down Expand Up @@ -1200,6 +1204,7 @@ internal object TextLayoutManager {
paint.setTypeface(null)
paint.textSize = textSize
paint.letterSpacing = 0f
paint.color = Color.BLACK
paint.fontFeatureSettings = null
paint.isFakeBoldText = false
paint.textSkewX = 0f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.facebook.react.views.text

import android.graphics.Color
import android.graphics.Paint
import android.graphics.Typeface
import android.os.Build
Expand Down Expand Up @@ -134,6 +135,28 @@ class TextLayoutManagerFontWeightAdjustmentTest {
assertThat(paint.fontFeatureSettings).isNull()
}

@Test
fun `text paint applies base color used to draw generated ellipses`() {
val textAttributes =
TextAttributeProps.fromReadableMap(
ReactStylesDiffMap(JavaOnlyMap.of("foregroundColor", Color.WHITE)),
)

val paint = TextPaint()
TextLayoutManager.updateTextPaint(
paint,
textAttributes,
RuntimeEnvironment.getApplication().assets,
0,
)

assertThat(paint.color).isEqualTo(Color.WHITE)

TextLayoutManager.resetTextPaint(paint, 12f)

assertThat(paint.color).isEqualTo(Color.BLACK)
}

@Test
fun `text paint enables the shaping flags used by custom style spans`() {
val paint = mock<TextPaint>()
Expand Down
Loading