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

Incorrect positioning of custom text #1758

Closed
vincekao-dd opened this issue Mar 10, 2021 · 9 comments · Fixed by #2162
Closed

Incorrect positioning of custom text #1758

vincekao-dd opened this issue Mar 10, 2021 · 9 comments · Fixed by #2162

Comments

@vincekao-dd
Copy link

vincekao-dd commented Mar 10, 2021

Lottie is supported and developed on nights and weekends. Issues from Lottie sponsors will be prioritized.

Checklist

  1. My animation doesn't use any unsupported features.
  2. I know what part of my animation doesn't work.
  3. I have created a simplified version of my animation
  4. I have attached the AEP file (as a zip file so it can be attached) that only has the part of the animation that doesn't work.

Describe the bug
Our animation consists of an envelope that opens up to display a card with custom user-defined text. We set the text using a TextDelegate and a custom font. The entire animation works perfectly and the correct text/font is displayed, but the positioning of the text is misaligned. Rather than being aligned with the left side of the card, the text area seems to start in the middle. It's still left-justified, but the XY coordinates of the textbox are shifted to the center coordinates of the card.

We experimented with a modified version of the animation where we aligned the center X of the textbox with the left edge of the canvas (so that the left half of the text box is outside the card) and this seemed to fix the issue. The problem is that we have a constantly increasing number of variations of this animation which all work as expected in their original form on both iOS and Web, so producing a separate version of each animation for Android is not a viable solution.

This seems to be the same issue as described in these reports, but there is no recent activity or posted solution:
#388
#481
#451

Thanks in advance for your assistance!

What version of Lottie did you test this on?
3.6.1

What version of Android did you test this on?
APIs 27-30

Steps To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots
image
image

json attached:
misaligned_text.json.zip

@oissa1
Copy link

oissa1 commented May 1, 2021

I'm having the exact same issue. Haven't been able to find a solution. I've tried messing around with After Effects and whatever I do the text is never rendered in Android in the same position that it looks in AE.

@AjayGol
Copy link

AjayGol commented May 7, 2021

I have facing same issue

In iOS text position showing currently but in android showing wrong position text. Only issue on text position.

@timmygap
Copy link

Same issue for me, If I try to use the TextDelegate, the Text moved to a wrong position. Without the TextDelegate it works, but than we can't translate the labels.

@LorienMan
Copy link

Same issue for me, If I try to use the TextDelegate, the Text moved to a wrong position. Without the TextDelegate it works, but than we can't translate the labels.

Same!

@okamayana-tinyspeck
Copy link

Still no fix?

@cjmFirefly03
Copy link

Having the same issue :(

@frankiesimon
Copy link

Same here :(

@gpeal
Copy link
Collaborator

gpeal commented Jan 16, 2022

@vincekao-dd @oissa1 @AjayGol @tkrawetzke @LorienMan @okamayana-tinyspeck @cjmFirefly03 @frankiesimon Could you all please attach aep files that reproduce this? Including them will always increase the likelihood that bugs can get addressed.

@gpeal gpeal added the Text label Jan 17, 2022
@mattbusuu
Copy link

mattbusuu commented Mar 14, 2022

@gpeal

I am also getting the same problem.

Not my animation, but using this animation:
https://lottiefiles.com/67074-text-input-transparent

And applying the filter via:

        val textDelegate = TextDelegate(splashAnimation)
        textDelegate.setText("username", "my custom string  123")
        splashAnimation.setTextDelegate(textDelegate)

I am getting the following:

Screenshot 2022-03-14 at 20 56 06

Which is wrong, as the text "my custom string 123" should be left aligned, along with the cursor, but it is shifted to the right.

Version: com.airbnb.android:lottie:5.0.3

(Small note, I did try with this file first, but it rendered fine: https://lottiefiles.com/58264-pin-on-the-map). I'm not an animation expert though, so not sure if there is a connection....

gpeal added a commit that referenced this issue Nov 26, 2022
This PR completely rewrites the text layout algorithm. It should be more accurate in most cases now. Center and right justifications as well as alignment of paragraph text and text wrapping should all be much more accurate.

Note that there may be an outstanding issue with the y position of paragraph text which affects #1758 but I have been unable to reproduce it with an AEP file for debugging.

Fixes #1479
Fixes #1758 
Fixes #397 
Likely fixes #2135
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.

10 participants