lottie-android icon indicating copy to clipboard operation
lottie-android copied to clipboard

Rotated text not rendered correctly

Open JamieJuliusSundaySky opened this issue 6 years ago • 9 comments

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 avatar Jul 24 '17 15:07 JamieJuliusSundaySky

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);
}

JamieJuliusSundaySky avatar Jul 25 '17 11:07 JamieJuliusSundaySky

Happens with me too. Any workarounds?

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

liukaichi avatar Sep 28 '17 01:09 liukaichi

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 avatar Sep 07 '18 23:09 azchohfi

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...

azchohfi avatar Sep 27 '18 22:09 azchohfi

@azchohfi Update your bodymovin plugin

gpeal avatar Sep 30 '18 18:09 gpeal

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

axitasavani avatar Nov 13 '19 10:11 axitasavani

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

gpeal avatar Nov 20 '19 22:11 gpeal

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 avatar Jan 05 '22 17:01 Pavel87

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))

Pavel87 avatar Jan 07 '22 12:01 Pavel87