Skip to content

IndexError: list index out of range in text_mobject #469

@qo4on

Description

@qo4on

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    pr:bugfixBug fix for use in PRs solving a specific issue:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions