From e836c3bb420472f355572f5feca0382d14fa3167 Mon Sep 17 00:00:00 2001 From: Wallbreaker5th <3277946283@qq.com> Date: Fri, 18 Jun 2021 14:43:09 +0800 Subject: [PATCH 1/2] Temporary hack for showing text correctly --- manimlib/mobject/svg/text_mobject.py | 3 +++ manimlib/utils/space_ops.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/manimlib/mobject/svg/text_mobject.py b/manimlib/mobject/svg/text_mobject.py index e0161f23..6ae95797 100644 --- a/manimlib/mobject/svg/text_mobject.py +++ b/manimlib/mobject/svg/text_mobject.py @@ -68,6 +68,9 @@ class Text(SVGMobject): # anti-aliasing if self.height is None: self.scale(TEXT_MOB_SCALE_FACTOR * self.font_size) + + for i in self.submobjects: + i.insert_n_curves(len(i.get_points())) def remove_empty_path(self, file_name): with open(file_name, 'r') as fpr: diff --git a/manimlib/utils/space_ops.py b/manimlib/utils/space_ops.py index c124cbec..24e4c94d 100644 --- a/manimlib/utils/space_ops.py +++ b/manimlib/utils/space_ops.py @@ -367,6 +367,9 @@ def earclip_triangulation(verts, ring_ends): list(range(e0, e1)) for e0, e1 in zip([0, *ring_ends], ring_ends) ] + for i in rings: + verts[i[0]] += (verts[i[1]]-verts[i[0]])*5e-6 + verts[i[-1]] += (verts[i[-2]]-verts[i[-1]])*5e-6 attached_rings = rings[:1] detached_rings = rings[1:] loop_connections = dict() @@ -402,7 +405,7 @@ def earclip_triangulation(verts, ring_ends): # Move the ring which j belongs to from the # attached list to the detached list new_ring = next(filter( - lambda ring: ring[0] <= j < ring[-1], + lambda ring: ring[0] <= j <= ring[-1], detached_rings )) detached_rings.remove(new_ring) From a99ccea02cec8325a94aee478c6bf4e2e649af7c Mon Sep 17 00:00:00 2001 From: Wallbreaker5th <3277946283@qq.com> Date: Sat, 19 Jun 2021 16:00:39 +0800 Subject: [PATCH 2/2] Add some comments about the temporary hack --- manimlib/mobject/svg/text_mobject.py | 2 ++ manimlib/utils/space_ops.py | 1 + 2 files changed, 3 insertions(+) diff --git a/manimlib/mobject/svg/text_mobject.py b/manimlib/mobject/svg/text_mobject.py index 6ae95797..705524d0 100644 --- a/manimlib/mobject/svg/text_mobject.py +++ b/manimlib/mobject/svg/text_mobject.py @@ -69,6 +69,8 @@ class Text(SVGMobject): if self.height is None: self.scale(TEXT_MOB_SCALE_FACTOR * self.font_size) + # Just a temporary hack to get better triangulation + # See pr #1552 for details for i in self.submobjects: i.insert_n_curves(len(i.get_points())) diff --git a/manimlib/utils/space_ops.py b/manimlib/utils/space_ops.py index 24e4c94d..b24ca4f8 100644 --- a/manimlib/utils/space_ops.py +++ b/manimlib/utils/space_ops.py @@ -367,6 +367,7 @@ def earclip_triangulation(verts, ring_ends): list(range(e0, e1)) for e0, e1 in zip([0, *ring_ends], ring_ends) ] + # Points at the same position may cause problems for i in rings: verts[i[0]] += (verts[i[1]]-verts[i[0]])*5e-6 verts[i[-1]] += (verts[i[-2]]-verts[i[-1]])*5e-6