manim icon indicating copy to clipboard operation
manim copied to clipboard

Problem with Code mobject

Open duchuyvp opened this issue 1 year ago • 2 comments

Description of bug / unexpected behavior

I'm working with Code mobject. I was getting started with this https://docs.manim.community/en/stable/reference/manim.mobject.text.code_mobject.Code.html#codefromstring and I found this.

When I add line print("Hello World"), it works fine. But when I add print(1<2) or print("Hello World", 1<2), an error occur.

I'm not sure it happened with other language or not.

from manim import *


class CodeFromString(Scene):
    def construct(self):
        code = """from manim import Scene, Square

class FadeInSquare(Scene):
    def construct(self):
        print(1<=2)
        s = Square()
        self.play(FadeIn(s))
        self.play(s.animate.scale(2))
        self.wait()
"""
        rendered_code = Code(
            code=code,
            tab_width=4,
            background="window",
            language="Python",
            font="FiraCode Nerd Font",
        )
        self.play(Create(rendered_code))

Logs

IndexError: list index out of range

And btw, what would be nice if you teach me how to apply fontLigasture when render

duchuyvp avatar May 12 '23 06:05 duchuyvp