Manim: IndexError: list index out of range in text_mobject

Created on 22 Sep 2020  路  6Comments  路  Source: ManimCommunity/manim

Windows 10, Python 3.8.5, latest Manim from master branch

from manimlib.imports import *


class test(Scene):
    def construct(self):
        t = r"""a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0 . : , ; ' " ( ! ? ) + - * / = ` ~ @ $ % ^ & [ ] { } _ \ | < >"""

        text = Text(t, font='Arial', stroke_width=0)

        self.add(text)
        self.wait(.1)

Traceback (most recent call last):
  File "C:\manim\manimlib\extract_scene.py", line 155, in main
    scene = SceneClass(**scene_kwargs)
  File "C:\manim\manimlib\scene\scene.py", line 75, in __init__
    self.construct()
  File "C:\test.py", line 8, in construct
    text = Text(t, font='Arial', stroke_width=0)
  File "C:\manim\manimlib\mobject\svg\text_mobject.py", line 67, in __init__
    self.apply_space_chars()
  File "C:\manim\manimlib\mobject\svg\text_mobject.py", line 162, in apply_space_chars
    space.move_to(self.submobjects[char_index - 1].get_center())
IndexError: list index out of range

Whereas these lines work fine:

        text = Text(t[2:], font='Arial', stroke_width=0)
        text = Text(t[:-2], font='Arial', stroke_width=0)

It looks like SVGMobject cannot handle symbols like < and >. Any Ideas how to fix that?

bug

All 6 comments

Are you using 3b1b/manim or ManimCommunity/manim?
Does it work when you remove the < and > from text?

I can confirm that this happens in manim community as well.

I don't think this is specific to any characters, but rather some weird string length issue: trying to add a Text with sufficiently many "a" characters leads to the same exception.

Does it work when you remove the < and > from text?

Yes.
I used it in 3b1b master. I also tested it with shader Manim. Does community Manim have shader version?

I used it in 3b1b master. I also tested it with shader Manim. Does community Manim have shader version?

No, we don't have something similar for now.

I think I have identified the issue and it should be solved via #476.

@behackl The new version that solved this issue hasn't been distributed on PyPi, right? manimce 0.1.0 still has the same issue.

No, the fix is not released yet unfortunately. In fact, we have recently decided to push back a potential fix until we had some time to clean the interface of Text a little; it is very messy and in fact my proposed fix from #476 caused, for some reason, a difference in the testoutput between Linux and Windows.

Thus: sorry, this will take some time longer. :-/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leotrs picture leotrs  路  5Comments

PgBiel picture PgBiel  路  5Comments

XorUnison picture XorUnison  路  6Comments

ackxolotl picture ackxolotl  路  4Comments

ChristianCoenen picture ChristianCoenen  路  5Comments