Description
I tried to use Text
to write Chinese, but there were many problems.
For example, the simplest one is to write the word "回". But the result is this (contains unnecessary connections):
class TextBug(Scene):
def construct(self):
txt = Text("回", font="庞门正道标题体", height=FRAME_HEIGHT-1)
self.add(txt)
I lowered its opacity and showed the point set and its indices. The result is this:
class TextBug(Scene):
def construct(self):
txt = Text("回", font="庞门正道标题体", height=FRAME_HEIGHT-1)
txt.set_fill(opacity=0.3)
self.add(txt)
points = txt[0].get_points()
ind = index_labels(points).set_color(PURPLE).set_stroke(width=1)
self.add(ind)
The position and order of the point set are correct. So I suspect that there may be an error in the triangulation, so I displayed the inner triangles in the triangulation, and the result is this:
class TextBug(Scene):
def construct(self):
txt = Text("回", font="庞门正道标题体", height=FRAME_HEIGHT-1)
txt.set_fill(opacity=0.3)
self.add(txt)
points = txt[0].get_points()
ind = index_labels(points).set_color(PURPLE).set_stroke(width=1)
self.add(ind)
tri = txt[0].get_triangulation()
tri_indices = tri[len(points):]
a = tri_indices[0::3]
b = tri_indices[1::3]
c = tri_indices[2::3]
for i, _ in enumerate(a):
self.add(Polygon(points[a[i]], points[b[i]], points[c[i]],\
stroke_color=WHITE, stroke_width=4, fill_color=ORANGE, fill_opacity=0.5))
Basically it is certain that there is a problem, but I don't know how to solve it.
In addition, this is the svg file of this Chinese character, you can use SVGMobject
to test it.
d17bf5c77d8120cd.txt (change its extension to .svg
, because GitHub does not support uploading svg files here)
And it this way, not only Text
will have problems, but SVGMobject
and even other mobjects may also have such problems.
So, @3b1b please take a look at this.