Fixed
Status Update
Comments
si...@google.com <si...@google.com>
lp...@google.com <lp...@google.com> #2
I was exploring this a bit, one thing that I think would be interesting is considering how to make it possible to animate the brush (e.g, gradient) in a performant way. We may want to consider a () -> Brush
API or similar, as just a raw Brush
parameter would be worse for performance
ha...@google.com <ha...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 06becffa44774a7dc732d55c084d21c31c3bcb46
Author: Halil Ozercan <halilibo@google.com>
Date: Wed Apr 13 01:38:27 2022
Add Brush to TextStyle and SpanStyle.
Brush is a more capable way of drawing shapes, geometry, and text in Compose, a superset of Color. This change brings Brush as a first class property to TextStyle and SpanStyle to enable drawing Text composables using Brush.
Fix: b/187839528
Relnote: Added Brush to TextStyle and SpanStyle to provide a way to draw text with gradient coloring.
Test: Manual tests on Pixel 4a/6 Pro
Test: New tests
Test: ui:ui-text:cAT
Change-Id: I538698c22f5a03b57ed811ea733dd1194deaaa6a
A compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/style/ShaderBrushSpan.android.kt
M compose/ui/ui-text/api/restricted_current.txt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/platform/AndroidParagraphTest.kt
A compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/TextDrawStyle.kt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/platform/SpannableExtensionsTest.kt
M compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/platform/SkiaParagraph.skiko.kt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/platform/AndroidTextPaintTest.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/TextStyleResolveDefaultsTest.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/TextPaintExtensions.android.kt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/ParagraphIntegrationTest.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextStyle.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidTextPaint.android.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/TextSpanParagraphStyleTest.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/Paragraph.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/TextStyleLayoutAttributesTest.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/SpanStyle.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextPainter.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/SpanStyleTest.kt
A compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/BrushDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextDemos.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/TextStyleTest.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/MultiParagraph.kt
A compose/ui/ui-text/src/test/java/androidx/compose/ui/text/style/TextDrawStyleTest.kt
M compose/ui/ui-text/api/public_plus_experimental_current.txt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidParagraph.android.kt
M compose/ui/ui-text/api/current.txt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
https://android-review.googlesource.com/2063048
Branch: androidx-main
commit 06becffa44774a7dc732d55c084d21c31c3bcb46
Author: Halil Ozercan <halilibo@google.com>
Date: Wed Apr 13 01:38:27 2022
Add Brush to TextStyle and SpanStyle.
Brush is a more capable way of drawing shapes, geometry, and text in Compose, a superset of Color. This change brings Brush as a first class property to TextStyle and SpanStyle to enable drawing Text composables using Brush.
Fix:
Relnote: Added Brush to TextStyle and SpanStyle to provide a way to draw text with gradient coloring.
Test: Manual tests on Pixel 4a/6 Pro
Test: New tests
Test: ui:ui-text:cAT
Change-Id: I538698c22f5a03b57ed811ea733dd1194deaaa6a
A compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/style/ShaderBrushSpan.android.kt
M compose/ui/ui-text/api/restricted_current.txt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/platform/AndroidParagraphTest.kt
A compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/style/TextDrawStyle.kt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/platform/SpannableExtensionsTest.kt
M compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/platform/SkiaParagraph.skiko.kt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/platform/AndroidTextPaintTest.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/TextStyleResolveDefaultsTest.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/TextPaintExtensions.android.kt
M compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/ParagraphIntegrationTest.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextStyle.kt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidTextPaint.android.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/TextSpanParagraphStyleTest.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/Paragraph.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/TextStyleLayoutAttributesTest.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/SpanStyle.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TextPainter.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/SpanStyleTest.kt
A compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/BrushDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextDemos.kt
M compose/ui/ui-text/src/test/java/androidx/compose/ui/text/TextStyleTest.kt
M compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/MultiParagraph.kt
A compose/ui/ui-text/src/test/java/androidx/compose/ui/text/style/TextDrawStyleTest.kt
M compose/ui/ui-text/api/public_plus_experimental_current.txt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/AndroidParagraph.android.kt
M compose/ui/ui-text/api/current.txt
M compose/ui/ui-text/src/androidMain/kotlin/androidx/compose/ui/text/platform/extensions/SpannableExtensions.android.kt
Description
Currently the text composable accepts only color parameters for the text. This prevents developers from rendering text with a gradient or even an ImageBitmap used as a mask. As an alternative, developers need to leverage lower level components to achieve the same effect with more effort:
Sese: https://buganizer.corp.google.com/issues/187766726