ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
20.15k stars 1.49k forks source link

When running Text-related examples, an error occurs: TypeError: Argument 'size' has incorrect type (expected int, got float) #3403

Closed Ae01688 closed 9 months ago

Ae01688 commented 9 months ago

Description of bug / unexpected behavior

When I was using Manim Community v0.17.3, I found that all Text-related examples would report TypeError: Argument 'size' has incorrect type (expected int, got float) when running. The error pointed to the svg_file = manimpango.text2svg() method. image image

Expected behavior

image

How to reproduce the issue

Code for reproducing the problem ```py import jupyter_manim from manim import * %%manim -v WARNING -qm HelloWorld class HelloWorld(Scene): def construct(self): text = Text('Hello world').scale(3) self.add(text) ```
Ae01688 commented 9 months ago

Here is the code that runs:

%%manim -v WARNING -qm HelloWorld

class HelloWorld(Scene):
    def construct(self):
        text = Text('Hello world').scale(3)
        self.add(text)
Ae01688 commented 9 months ago

The following is the error message:

TypeError Traceback (most recent call last) Cell In[21], line 1 ----> 1 get_ipython().run_cell_magic('manim', '-v WARNING -qm HelloWorld', "\nclass HelloWorld(Scene):\n def construct(self):\n text = Text('Hello world').scale(3)\n self.add(text)\n")

File ~\anaconda3\envs\my-manim-environment\Lib\site-packages\IPython\core\interactiveshell.py:2493, in InteractiveShell.run_cell_magic(self, magic_name, line, cell) 2491 with self.builtin_trap: 2492 args = (magic_arg_s, cell) -> 2493 result = fn(*args, **kwargs) 2495 # The code below prevents the output from being displayed 2496 # when using magics with decorator @output_can_be_silenced 2497 # when the last Python token in the expression is a ';'. 2498 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File ~\anaconda3\envs\my-manim-environment\Lib\site-packages\manim\utils\ipython_magic.py:141, in ManimMagic.manim(self, line, cell, local_ns) 139 SceneClass = local_ns[config["scene_names"][0]] 140 scene = SceneClass(renderer=renderer) --> 141 scene.render() 142 finally: 143 # Shader cache becomes invalid as the context is destroyed 144 shader_program_cache.clear()

File ~\anaconda3\envs\my-manim-environment\Lib\site-packages\manim\scene\scene.py:223, in Scene.render(self, preview) 221 self.setup() 222 try: --> 223 self.construct() 224 except EndSceneEarlyException: 225 pass

File :4, in construct(self)

File ~\anaconda3\envs\my-manim-environment\Lib\site-packages\manim\mobject\text\text_mobject.py:486, in Text.init(self, text, fill_opacity, stroke_width, color, font_size, line_spacing, font, slant, weight, t2c, t2f, t2g, t2s, t2w, gradient, tab_width, warn_missing_font, height, width, should_center, disable_ligatures, *kwargs) 483 self.line_spacing = self._font_size + self._font_size self.line_spacing 485 color = Color(color) if color else VMobject().color --> 486 file_name = self._text2svg(color) 487 PangoUtils.remove_last_M(file_name) 488 super().init( 489 file_name, 490 fill_opacity=fill_opacity, (...) 496 **kwargs, 497 )

File ~\anaconda3\envs\my-manim-environment\Lib\site-packages\manim\mobject\text\text_mobject.py:814, in Text._text2svg(self, color) 811 width = config["pixel_width"] 812 height = config["pixel_height"] --> 814 svg_file = manimpango.text2svg( 815 settings, 816 size, 817 line_spacing, 818 self.disable_ligatures, 819 str(file_name.resolve()), 820 START_X, 821 START_Y, 822 width, 823 height, 824 self.text, 825 ) 827 return svg_file

TypeError: Argument 'size' has incorrect type (expected int, got float)

naveen521kk commented 9 months ago

Hey, looks like you've faced https://github.com/ManimCommunity/ManimPango/issues/106. I'll close this as a duplicate of the other one. For now, you could run pip install manimpango --force to fix this issue or not use conda. Thanks!

Ae01688 commented 9 months ago

The problem seems to have been solved. Thank you for taking the time to answer my question. Thank you very much and wish you a happy life.😀 @naveen521kk

merchiru commented 5 months ago

Hey, looks like you've faced ManimCommunity/ManimPango#106. I'll close this as a duplicate of the other one. For now, you could run pip install manimpango --force to fix this issue or not use conda. Thanks!

Thanks, my friend, you're the true hero!