Description
Description of bug / unexpected behavior
Manim closes incorrectly "holes" in some SVG shapes. For example, the following SVG
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="854" height="480" viewBox="0 0 854 480">
<defs>
<g>
<g id="glyph-0-0">
<path d="M -0.0664062 0 L 3.203125 -9.695312 L 4.792969 -9.695312 L 8.058594 0 L 6.699219 0 L 5.820312 -2.707031 L 2.117188 -2.707031 L 1.238281 0 L -0.0664062 0 M 5.460938 -3.808594 L 3.964844 -8.378906 L 2.472656 -3.808594 Z "/>
</g>
</g>
</defs>
<g fill="rgb(100%, 100%, 100%)" fill-opacity="1">
<use xlink:href="#glyph-0-0" x="30" y="33.339844"/>
</g>
</svg>
is rendered by manim ike this:
Expected behavior
The correct rendering should be
as the SVG standard specifies that the "Z" command (close) should draw a line between the last point drawn and the last "M" command. In this case that should close the hole in the shape.
The correct shape is produced by other SVG renderers (eg: any web browser).
How to reproduce the issue
Save the above SVG in a file called "A.svg"
and run the following code:
class Testa(Scene):
def construct(self):
A = SVGMobject("A.svg")
A.scale_to_fit_height(6)
self.add(A)
Additional comments
The problem is apparently caused by the absence of a "Z" (Close) command before "M"oving the pen to the hole in the SVG path. Manim assumes that before every Move a Close was done.
The issue is important because it can affect some users when rendering Text()
objects. The latest versions of pango generate the kind of SVG I pasted as example. In fact, this is exactly the SVG generated by the command Text("A")
in some platforms.
Recently, several threads appeared in discord showing badly rendered text, which I think it is related to this bug:
Metadata
Metadata
Assignees
Labels
Type
Projects
Status