Repository: ManimCommunity/manim
File: manim/mobject/text/text_mobject.py (Python)

Code before:
                    if setting.line_num == -1:
                        setting.line_num = line_num
                    if start < setting.end:
                        line_num += 1
                        new_setting = copy.copy(setting)
                        setting.end = end
                        new_setting.start = end
                        new_setting.line_num = line_num
                        settings.append(new_setting)
                        settings.sort(key=lambda setting: setting.start)
                        break
        for setting in settings:
            if setting.line_num == -1:
                setting.line_num = line_num

        return settings

    def _text2svg(self, color: Color):
        """Convert the text to SVG using Pango."""
        size = self._font_size
        line_spacing = self.line_spacing
        size /= TEXT2SVG_ADJUSTMENT_FACTOR
        line_spacing /= TEXT2SVG_ADJUSTMENT_FACTOR

        dir_name = config.get_dir("text_dir")
        if not Path(dir_name).is_dir():
            Path(dir_name).mkdir(parents=True)
        hash_name = self._text2hash(color)
        file_name = Path(dir_name).joinpath(hash_name + ".svg")

        if file_name.exists():
            svg_file = str(file_name.resolve())
        else:
            settings = self._text2settings(color)
            width = config["pixel_width"]
            height = config["pixel_height"]

            svg_file = manimpango.text2svg(
                settings,
                size,
                line_spacing,
                self.disable_ligatures,
                str(file_name.resolve()),
                START_X,
                START_Y,
                width,
                height,
                self.text,
            )

        return svg_file

Review comment (suggestion):
Again casts are not important as the `config.get_dir` method already returns a `Path` object

Code after:
                    if setting.line_num == -1:
                        setting.line_num = line_num
                    if start < setting.end:
                        line_num += 1
                        new_setting = copy.copy(setting)
                        setting.end = end
                        new_setting.start = end
                        new_setting.line_num = line_num
                        settings.append(new_setting)
                        settings.sort(key=lambda setting: setting.start)
                        break
        for setting in settings:
            if setting.line_num == -1:
                setting.line_num = line_num

        return settings

    def _text2svg(self, color: Color):
        """Convert the text to SVG using Pango."""
        size = self._font_size
        line_spacing = self.line_spacing
        size /= TEXT2SVG_ADJUSTMENT_FACTOR
        line_spacing /= TEXT2SVG_ADJUSTMENT_FACTOR

        dir_name = config.get_dir("text_dir")
        if not dir_name.is_dir():
            dir_name.mkdir(parents=True)
        hash_name = self._text2hash(color)
        file_name = dir_name / (hash_name + ".svg")

        if file_name.exists():
            svg_file = str(file_name.resolve())
        else:
            settings = self._text2settings(color)
            width = config["pixel_width"]
            height = config["pixel_height"]

            svg_file = manimpango.text2svg(
                settings,
                size,
                line_spacing,
                self.disable_ligatures,
                str(file_name.resolve()),
                START_X,
                START_Y,
                width,
                height,
                self.text,
            )

        return svg_file