ManimCommunity / ManimPango

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

MarkupText - Invalid Characters #8

Closed naveen521kk closed 3 years ago

naveen521kk commented 3 years ago

Just tried this

>>> MarkupText('<<lllll><<>><><>©')
MarkupText('<<lllll><<>><><>©')

I see an empty SVG file created with the following warnings over at console.

(process:4516): Pango-WARNING **: 23:48:47.481: pango_layout_set_markup_with_accel: Error on line 1 char 17: “<lllll” is not a valid name

Suggestion: Use pango_parse_markup and raise an error when markup is invalid. @PhilippImhof are you interested in doing this, or else I will do.

PhilippImhof commented 3 years ago

Good catch. I didn't think of implementing a sanity check, knowing that Pango would simply fail and the error message was rather clear. I will gladly do it, but won't be able for the next few days.

If you think it cannot wait, I am fine with you fixing it. Remember that the color and gradient part must be parsed and stripped before the check, as they are not supported by Pango. (Just to be sure, but you would probably have thought of that anyway.)

naveen521kk commented 3 years ago

No hurry for me, just do it when you are free :)

knowing that Pango would simply fail and the error message was rather clear.

If Pango had tried to exit, it would have made Python Crash, at least it just warns or else things would be difficult.

PhilippImhof commented 3 years ago

If Pango had tried to exit, it would have made Python Crash, at least it just warns or else things would be difficult.

I know. I tested that beforehand. 👍