ManimCommunity / ManimPango

Binding for Pango, to use with Manim.
https://manimpango.manim.community
MIT License
41 stars 13 forks source link

Cannot show Text in Ubuntu20.04 #88

Closed jinastro closed 2 years ago

jinastro commented 2 years ago

I installed manimpango by

sudo apt install libpango1.0-dev
pip install manimpango

but I got some warning messages from pango when I ran python code with Text

(process:11839): Pango-WARNING **: 11:38:57.040: pango_layout_set_markup_with_accel: Attribute 'line_height' is not allowed on the <span> tag on line 1 char 134

and the content in Text in the code cannot show up on the screen

naveen521kk commented 2 years ago

What's the code you used to get that output? Text shouldn't be using Pango markup AFAIR, so I'm curious as to why this issue is caused.

line_height isn't supported on Pango Version < 1.50.0 as mentioned in https://gnome.pages.gitlab.gnome.org/gtk/Pango/pango_markup.html, and I think Ubuntu doesn't have that version. You can check the version of Pango by running python -c 'import manimpango; print(manimpango.pango_version())'.

jinastro commented 2 years ago

What's the code you used to get that output? Text shouldn't be using Pango markup AFAIR, so I'm curious as to why this issue is caused.

line_height isn't supported on Pango Version < 1.50.0 as mentioned in https://gnome.pages.gitlab.gnome.org/gtk/Pango/pango_markup.html, and I think Ubuntu doesn't have that version. You can check the version of Pango by running python -c 'import manimpango; print(manimpango.pango_version())'.

Thanks for your response! My code is a simple test demo shown below

class TextExample(Scene):
    def construct(self):
        text = Text("Here is a text", font="Consolas", font_size=90)
        difference = Text(
            """
            The most important difference between Text and TexText is that\n
            you can change the font more easily, but can't use the LaTeX grammar
            """,
            font="Arial", font_size=24,
            t2c={"Text": BLUE, "TexText": BLUE, "LaTeX": ORANGE}
        )
        VGroup(text, difference).arrange(DOWN, buff=1)
        self.play(Write(text))
        self.play(FadeIn(difference, UP))
        self.wait(3)

        fonts = Text(
            "And you can also set the font according to different words",
            font="Arial",
            t2f={"font": "Consolas", "words": "Consolas"},
            t2c={"font": BLUE, "words": GREEN}
        )
        fonts.set_width(FRAME_WIDTH - 1)
        slant = Text(
            "And the same as slant and weight",
            font="Consolas",
            t2s={"slant": ITALIC},
            t2w={"weight": BOLD},
            t2c={"slant": ORANGE, "weight": RED}
        )
        VGroup(fonts, slant).arrange(DOWN, buff=0.8)
        self.play(FadeOut(text), FadeOut(difference, shift=DOWN))
        self.play(Write(fonts))
        self.wait()
        self.play(Write(slant))
        self.wait()

After running the code you suggested, I found the version of my pango is 1.44.7 So it is the version of pango that makes the problem.

Is there any possibility to install pango>1.5 on ubuntu20.04? Thanks a lot!

naveen521kk commented 2 years ago

My code is a simple test demo shown below [...]

Your code doesn't use line_height at all, does it really show that error when you run the script again (make sure to clear the media directory).

Is there any possibility to install pango>1.5 on ubuntu20.04?

You would need to compile it yourselves, refer to its documentation of how to do so. Or you could use conda which should provide the recent version. I don't think you would need to update though. Also, note 1.5 is not the same as 1.50.

jinastro commented 2 years ago

Your code doesn't use line_height at all, does it really show that error when you run the script again (make sure to clear the media directory).

This is weird, I have confused by it. Seemingly, this line_height origins from some code in manimgl, which need pango>1.5. By the way, when I ran my code twice, this warning was gone but the output video still cannot show text correctly.

You would need to compile it yourselves, refer to its documentation of how to do so. Or you could use conda which should provide the recent version. I don't think you would need to update though. Also, note 1.5 is not the same as 1.50.

Thanks for your suggestion, I tried to compile pango but failed. I am trying to take some other methods.

naveen521kk commented 2 years ago

This is weird, I have confused by it. Seemingly, this line_height origins from some code in manimgl

Make an issue in the manimgl repository? I'm sure you won't run into this issue on the community edition.

By the way, when I ran my code twice, this warning was gone but the output video still cannot show text correctly.

That's the cache and you would need to delete it first. Not sure where it's stored in manimgl.

By the way, when I ran my code twice, this warning was gone but the output video still cannot show text correctly.

Have a look at https://github.com/ManimCommunity/ManimPango/blob/main/packing/build_pango_tests.sh, it's been used in the CI here for running tests. You should remove the --prefix argument there so that it install for the whole system.

jinastro commented 2 years ago

Make an issue in the manimgl repository? I'm sure you won't run into this issue on the community edition.

I have tried the community edition today, which runs correctly on ubuntu20.04. I have made an issue in the manimgl repository.

That's the cache and you would need to delete it first. Not sure where it's stored in manimgl.

yes , its something about cache

Have a look at https://github.com/ManimCommunity/ManimPango/blob/main/packing/build_pango_tests.sh, it's been used in the CI here for running tests. You should remove the --prefix argument there so that it install for the whole system.

Thanks for your .sh file, I am reading it now.

naveen521kk commented 2 years ago

I'll close this issue then. You can still comment here if you have any questions.