Nino
07/23/2025, 4:20 PMText
composable in Android. The letters "giggle" / "snap" between 2 y values it seems, that's really noticeable.
It feels like text is handled differently in Compose. Is it possible to "rasterize" the Text composable and just rotate the pixels (even if it creates some aliasing)?
Here a small reproductible example (with a simple colored square that is working perfectly fine).
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.SpaceEvenly,
horizontalAlignment = Alignment.CenterHorizontally,
) {
val angle by rememberInfiniteTransition().animateFloat(
initialValue = 0F,
targetValue = 10F,
animationSpec = infiniteRepeatable(
animation = tween(
durationMillis = 50_000,
easing = LinearEasing,
),
repeatMode = RepeatMode.Reverse,
)
)
Text(
modifier = Modifier
.graphicsLayer {
rotationZ = angle
}
.padding(64.dp),
text = "I'm a text that giggle all around, unlike this box down here :( -_| ",
textAlign = TextAlign.Center,
fontSize = 20.sp
)
Box(
modifier = Modifier
.graphicsLayer {
rotationZ = angle
}
.size(200.dp)
.background(Color.Magenta),
)
}
romainguy
07/23/2025, 4:22 PMromainguy
07/23/2025, 4:22 PMromainguy
07/23/2025, 4:23 PMromainguy
07/23/2025, 4:23 PMNino
07/23/2025, 4:29 PMcompositingStrategy = CompositingStrategy.Offscreen
is exactly what fixes my problem. But I don't understand why rendering the text in an offscreen buffer fixes the text "snapping". Any clues? 😄
Also, "linear text compose" doesn't bring anything, am I missing something?romainguy
07/23/2025, 4:33 PMromainguy
07/23/2025, 4:34 PMromainguy
07/23/2025, 4:34 PMromainguy
07/23/2025, 4:35 PMromainguy
07/23/2025, 4:35 PMProvideTextStyle(
TextStyle(textMotion = Animated)
) {
Text(…)
}
Nino
07/23/2025, 4:37 PMcompositingStrategy = CompositingStrategy.Offscreen
is the fact we have to render "twice" this Composable, right?romainguy
07/23/2025, 4:38 PMromainguy
07/23/2025, 4:38 PMromainguy
07/23/2025, 4:39 PMromainguy
07/23/2025, 4:39 PMNino
07/23/2025, 4:42 PMTextMotion.Animated
), and it all boils down to good old Canvas with LINEAR_TEXT_FLAG
and SUBPIXEL_TEXT_FLAG
romainguy
07/23/2025, 4:45 PMNino
07/23/2025, 5:17 PMromainguy
07/23/2025, 5:32 PMHalil Ozercan
07/23/2025, 6:11 PMHalil Ozercan
07/23/2025, 6:12 PM