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

Rotated text not rendered correctly #397

Closed
JamieJuliusSundaySky opened this issue Jul 24, 2017 · 9 comments · Fixed by #2162
Closed

Rotated text not rendered correctly #397

JamieJuliusSundaySky opened this issue Jul 24, 2017 · 9 comments · Fixed by #2162
Labels

Comments

@JamieJuliusSundaySky
Copy link

The attached zip contains:

  • JSON input
  • Image of expected output
  • Image of actual output

The composition contains two text layers "AB" and "CD". One is point text and one is paragraph text. They both have their Rotation property animated. The expected result is that each text sequence rotates around the anchor point, which is at the bottom left of each text sequence. The actual result is that each glyph is being rotated individually. This happens with both point text and paragraph text alike.
ABCDRotate.zip

@JamieJuliusSundaySky
Copy link
Author

Note that in the example above the text is rendered via the "useTextGlyphs" route. When going through the "Font" route all is well as the rotation is applied to the canvas as a whole and not to the individual paths:

if (!lottieDrawable.useTextGlyphs()) {
  canvas.setMatrix(parentMatrix);
}

@liukaichi
Copy link

liukaichi commented Sep 28, 2017

Happens with me too. Any workarounds?

Edit: Actually, I just ended up converting the text to shapes, and now it works perfectly!

@gpeal gpeal added the Text label Dec 14, 2017
@azchohfi
Copy link
Contributor

azchohfi commented Sep 7, 2018

This JSON is not even working anymore. That's because on your file, "sw" is 0.00999999977648 but we are reading it as an int. @gpeal, should this be read as a double? The only usage of this variable is already being multiplied by the scale so it is returning a float anyway.

@azchohfi
Copy link
Contributor

azchohfi commented Sep 27, 2018

Digging the source, I've found that Lottie Web uses only the first shape from the character it renders (when rendering glyphs):
https://github.com/airbnb/lottie-web/blob/master/player/js/elements/svgElements/SVGTextElement.js#L127
I don't know why, but some files have more than one shape, like this one:
https://github.com/airbnb/lottie-android/blob/master/LottieSample/src/main/assets/lottiefiles/cancel_button.json
They render like this:
image
Maybe I should open a new issue for this...

@gpeal
Copy link
Collaborator

gpeal commented Sep 30, 2018

@azchohfi Update your bodymovin plugin

@axitasavani
Copy link

axitasavani commented Nov 13, 2019

Which BodyMovin Plugin Version used to make animation For Lottie? @gpeal

@gpeal
Copy link
Collaborator

gpeal commented Nov 20, 2019

@axitasavani Use whatever the latest version is. The comment above is from a version that is many years old.

@Pavel87
Copy link

Pavel87 commented Jan 5, 2022

The attached zip contains:

  • JSON input
  • Image of expected output
  • Image of actual output

The composition contains two text layers "AB" and "CD". One is point text and one is paragraph text. They both have their Rotation property animated. The expected result is that each text sequence rotates around the anchor point, which is at the bottom left of each text sequence. The actual result is that each glyph is being rotated individually. This happens with both point text and paragraph text alike. ABCDRotate.zip

I know this has been few years but what is the solution to this issue? @JamieJuliusSundaySky

@Pavel87
Copy link

Pavel87 commented Jan 7, 2022

Ok got the solution... like said above we have to avoid rendering text as glyphs but rather we need to render as font:

if (!lottieDrawable.useTextGlyphs()) { canvas.setMatrix(parentMatrix); }

If we just set the text delegate then the rotation is working as expected.

binding.lottie.setTextDelegate(TextDelegate(binding.lottie))

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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants