Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash: Using a font with ligatures crashes manim-code #3959

Open
gbin opened this issue Oct 15, 2024 · 1 comment
Open

Crash: Using a font with ligatures crashes manim-code #3959

gbin opened this issue Oct 15, 2024 · 1 comment

Comments

@gbin
Copy link

gbin commented Oct 15, 2024

Description of bug / unexpected behavior

If I try to render some Rust code with a ligature font like Fira Mono and add a :: it crashes

Expected behavior

Should render the code

How to reproduce the issue

Code for reproducing the problem
    def play_rust(self):
        rust = """
        impl<'cl> CuTask<'cl> for GenericPIDTask {
          type Input = input_msg!('cl, f32);
          type Output = output_msg!('cl, PIDControlOutput);
        
          fn process( &mut self,
                      clock: &RobotClock,
                      input: Self :: Input,
                      output: Self :: Output) -> CuResult<()> {
            
            }
        }
        """
        rendered_code = Code(code=rust, tab_width=2, background="window", language="Rust", font="Fira Code", font_size=20)
        self.add(rendered_code)
        self.wait(1)

Additional media files

Images/GIFs

Logs

Terminal output ``` File "/home/gbin/projects/CopperPitch/pres.py", line 461, in scene.render() File "/home/gbin/.local/share/virtualenvs/CopperPitch-aZYkSC0m/lib/python3.11/site-packages/manim_slides/slide/manim.py", line 132, in render super().render(*args, **kwargs) File "/home/gbin/.local/share/virtualenvs/CopperPitch-aZYkSC0m/lib/python3.11/site-packages/manim/scene/scene.py", line 229, in render self.construct() File "/home/gbin/projects/CopperPitch/pres.py", line 18, in construct self.play_rust() File "/home/gbin/projects/CopperPitch/pres.py", line 450, in play_rust rendered_code = Code(code=rust, tab_width=2, background="window", language="Rust", font="Fira Code", font_size=20) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gbin/.local/share/virtualenvs/CopperPitch-aZYkSC0m/lib/python3.11/site-packages/manim/mobject/text/code_mobject.py", line 227, in __init__ self.code = self._gen_colored_lines() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gbin/.local/share/virtualenvs/CopperPitch-aZYkSC0m/lib/python3.11/site-packages/manim/mobject/text/code_mobject.py", line 350, in _gen_colored_lines code = Paragraph( ^^^^^^^^^^ File "/home/gbin/.local/share/virtualenvs/CopperPitch-aZYkSC0m/lib/python3.11/site-packages/manim/mobject/text/text_mobject.py", line 163, in __init__ self.lines_text = Text(lines_str, line_spacing=line_spacing, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gbin/.local/share/virtualenvs/CopperPitch-aZYkSC0m/lib/python3.11/site-packages/manim/mobject/text/text_mobject.py", line 520, in __init__ self.submobjects = [*self._gen_chars()] ^^^^^^^^^^^^^^^^^ File "/home/gbin/.local/share/virtualenvs/CopperPitch-aZYkSC0m/lib/python3.11/site-packages/manim/mobject/text/text_mobject.py", line 621, in _gen_chars chars.add(self.submobjects[submobjects_char_index]) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ IndexError: list index out of range list index out of range ```

System specifications

System Details
  • OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)):
  • RAM:
  • Python version (python/py/python3 --version):
  • Installed modules (provide output from pip list):
PASTE HERE
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020):
  • Installed LaTeX packages:

Additional comments

@OliverStrait
Copy link

Currently there is no support for ligature fonts in Code blocks because it will mess coloring indexing like so:
Fira_mono_broken_colors
Crashing is due to unexpected ligature text in Text-Mobject builder.

To resolve this, there is need for custom Paragraph builder that can store proper color indexing with ligatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants