diff --git a/manimlib/mobject/svg/text_mobject.py b/manimlib/mobject/svg/text_mobject.py index 5a9873f5..a19b416d 100644 --- a/manimlib/mobject/svg/text_mobject.py +++ b/manimlib/mobject/svg/text_mobject.py @@ -7,6 +7,7 @@ import manimlib.constants as consts from manimlib.constants import * from manimlib.mobject.svg.svg_mobject import SVGMobject from manimlib.utils.config_ops import digest_config +from manimlib.utils.directories import get_text_dir TEXT_MOB_SCALE_FACTOR = 0.05 @@ -30,6 +31,7 @@ class Text(SVGMobject): # Mobject 'color': consts.WHITE, 'height': None, + 'stroke_width': 0, # Text 'font': '', 'gradient': None, @@ -51,23 +53,8 @@ class Text(SVGMobject): self.lsh = self.size if self.lsh == -1 else self.lsh file_name = self.text2svg() - self.remove_last_M(file_name) SVGMobject.__init__(self, file_name, **config) - nppc = self.n_points_per_curve - for each in self: - if len(each.get_points()) == 0: - continue - points = each.get_points() - last = points[0] - each.clear_points() - for index, point in enumerate(points): - each.append_points([point]) - if index != len(points) - 1 and (index + 1) % nppc == 0 and any(point != points[index+1]): - each.add_line_to(last) - last = points[index + 1] - each.add_line_to(last) - if self.t2c: self.set_color_by_t2c() if self.gradient: @@ -79,13 +66,6 @@ class Text(SVGMobject): if self.height is None: self.scale(TEXT_MOB_SCALE_FACTOR) - def remove_last_M(self, file_name): - with open(file_name, 'r') as fpr: - content = fpr.read() - content = re.sub(r'Z M [^A-Za-z]*? "\/>', 'Z "/>', content) - with open(file_name, 'w') as fpw: - fpw.write(content) - def find_indexes(self, word): m = re.match(r'\[([0-9\-]{0,}):([0-9\-]{0,})\]', word) if m: @@ -206,7 +186,7 @@ class Text(SVGMobject): if self.font == '': print(NOT_SETTING_FONT_MSG) - dir_name = consts.TEXT_DIR + dir_name = get_text_dir() hash_name = self.text2hash() file_name = os.path.join(dir_name, hash_name) +'.svg' if os.path.exists(file_name): diff --git a/manimlib/utils/directories.py b/manimlib/utils/directories.py index cd70af57..efdaffe4 100644 --- a/manimlib/utils/directories.py +++ b/manimlib/utils/directories.py @@ -33,6 +33,10 @@ def get_tex_dir(): return guarantee_existence(os.path.join(get_temp_dir(), "Tex")) +def get_text_dir(): + return guarantee_existence(os.path.join(get_temp_dir(), "Text")) + + def get_mobject_data_dir(): return guarantee_existence(os.path.join(get_temp_dir(), "mobject_data"))