fix Text incorrect coloring

This commit is contained in:
Tony031218
2021-02-13 17:51:43 +08:00
parent 9bf51bda02
commit c9e223485c

View File

@ -52,6 +52,7 @@ class Text(SVGMobject):
self.text = text_without_tabs
file_name = self.text2svg()
PangoUtils.remove_last_M(file_name)
self.remove_empty_path(file_name)
SVGMobject.__init__(self, file_name, **config)
self.text = text
if self.disable_ligatures:
@ -67,6 +68,13 @@ class Text(SVGMobject):
if self.height is None:
self.scale(TEXT_MOB_SCALE_FACTOR * self.font_size)
def remove_empty_path(self, file_name):
with open(file_name, 'r') as fpr:
content = fpr.read()
content = re.sub(r'<path .*?d=""/>', '', content)
with open(file_name, 'w') as fpw:
fpw.write(content)
def apply_space_chars(self):
submobs = self.submobjects.copy()
for char_index in range(len(self.text)):