Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The height parameter is not considered when using the SZ property for multiline dynamic text. #2384

Closed
kiran-mercari opened this issue Sep 5, 2023 · 0 comments · Fixed by #2412

Comments

@kiran-mercari
Copy link

kiran-mercari commented Sep 5, 2023

Describe the bug
When using the SZ property for dynamic text in the TextLayer, the height parameter is ignored. This means that if a larger text is passed that exceeds the size of the SZ box, the content will overflow and go outside the box.

What version of Lottie did you test this on?

  • 6.1.0
  • 6.0.0

What version of Android did you test this on?

  • Emulator - Android 6 to 13
  • Samsung Galaxy S23+
  • Samsung Galaxy S23 Ultra+

Steps To Reproduce
Please refer the bellow code:

@composable
fun DynamicTextDemo() {

val composition by rememberLottieComposition(LottieCompositionSpec.RawRes (R.raw.paragraphtext))
val progress by animateLottieCompositionAsState(composition)
val mapTypeFace = composition?.fonts?.map { (k, v) ->
    k to ( v.typeface ?: DEFAULT)
}?.toMap()

val dynamicProperties = rememberLottieDynamicProperties(
    rememberLottieDynamicProperty(
        property = LottieProperty.TEXT,
        value = "Lottie is a great library to add animated files into your app. In this article, we are going to see..",
        keyPath = arrayOf("...") // Key path
    ),
)

Box {
    LottieAnimation(
        composition = composition,
        progress = { progress },
        contentScale = ContentScale.FillBounds,
        modifier = Modifier.fillMaxSize(),
        dynamicProperties = dynamicProperties,
        fontMap = mapTypeFace,
    )
}

}

JSON Structure for Multiline:
"t": { "d": { "k": [{ "s": { "sz": [380, 84], "ps": [0, -18.8397216796875], "s": 24, "f": "Arial-Bold", "t": "dynamic_text_1", "ca": 0, "j": 0, "tr": 20, "lh": 49, "ls": 0, "fc": [0.133, 0.133, 0.133] }, "t": 0 }] }

TextLayer supports multiline text as indicated by the "sz": [380, 84] property. However, there seems to be an issue with restricting the height of the text. Unfortunately, the codebase does not consider the height parameter, which is why the height restriction is not working properly.

Screenshots
Screenshot 2023-09-05 at 6 41 41 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant