AttributeError in font.py after updating to Python 3.10
I am using lottie as a python module. I generate shapes from text via FontStyle()
. After upgrading python version to 3.10, I get this error:
Oct 29 10:40:24 python3[2889931]: text_shape = font.render(text)
Oct 29 10:40:24 python3[2889931]: File "/usr/local/lib/python3.10/dist-packages/lottie/utils/font.py", line 785, in render
Oct 29 10:40:24 python3[2889931]: group = self._renderer.render(text, self.size, self.position+pos, self.use_kerning)
Oct 29 10:40:24 python3[2889931]: File "/usr/local/lib/python3.10/dist-packages/lottie/utils/font.py", line 557, in render
Oct 29 10:40:24 python3[2889931]: self._on_character(ch, size, pos, scale, line, use_kerning, chars, i)
Oct 29 10:40:24 python3[2889931]: File "/usr/local/lib/python3.10/dist-packages/lottie/utils/font.py", line 729, in _on_character
Oct 29 10:40:24 python3[2889931]: return self.wrapped._on_character(char, size, pos, scale, group, use_kerning, chars, i)
Oct 29 10:40:24 python3[2889931]: File "/usr/local/lib/python3.10/dist-packages/lottie/utils/font.py", line 636, in _on_character
Oct 29 10:40:24 python3[2889931]: if self.best._on_character(char, size, pos, scale, group, use_kerning, chars, i):
Oct 29 10:40:24 python3[2889931]: File "/usr/local/lib/python3.10/dist-packages/lottie/utils/font.py", line 487, in _on_character
Oct 29 10:40:24 python3[2889931]: glyphdata = self.font.glyph(chname)
Oct 29 10:40:24 python3[2889931]: File "/usr/local/lib/python3.10/dist-packages/lottie/utils/font.py", line 412, in glyph
Oct 29 10:40:24 python3[2889931]: xmin = getattr(glyph._glyph, "xMin", glyph.lsb)
Oct 29 10:40:24 python3[2889931]: AttributeError: '_TTGlyphGlyf' object has no attribute '_glyph'
As a quick fix it is possible to just replace glyph._glyph
with just glyph
.