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

Code before:
            **kwargs,
        )
        self.text = text
        if self.disable_ligatures:
            self.submobjects = [*self._gen_chars()]
        self.chars = self.get_group_class()(*self.submobjects)
        self.text = text_without_tabs.replace(" ", "").replace("\n", "")
        nppc = self.n_points_per_curve
        for each in self:
            if len(each.points) == 0:
                continue
            points = each.points
            curve_start = points[0]
            assert len(curve_start) == self.dim, curve_start
            # Some of the glyphs in this text might not be closed,
            # so we close them by identifying when one curve ends
            # but it is not where the next curve starts.
            # It is more efficient to temporarily create a list
            # of points and add them one at a time, then turn them
            # into a numpy array at the end, rather than creating
            # new numpy arrays every time a point or fixing line
            # is added (which is O(n^2) for numpy arrays).
            closed_curve_points = []
            # OpenGL has points be part of quadratic Bezier curves;
            # Cairo uses cubic Bezier curves.
            if nppc == 3:

                def add_line_to(end):
                    nonlocal closed_curve_points
                    start = closed_curve_points[-1]
                    closed_curve_points += [
                        start,
                        (start + end) / 2,
                        end,
                    ]

            else:

                def add_line_to(end):
                    nonlocal closed_curve_points
                    start = closed_curve_points[-1]
                    closed_curve_points += [
                        start,
                        (start + start + end) / 3,
                        (start + end + end) / 3,
                        end,
                    ]

            for index, point in enumerate(points):
                closed_curve_points.append(point)
                if (

Review comment (suggestion):
Just for the sake of maintainability (and if possible), I'd suggest to replace this comparison to `if config.renderer = RendererType.OPENGL`, the other branch to `elif config.renderer == RendererType.CAIRO`, and `raise NotImplementedError(...)` in a new `else`-part.

Code after:

        color = Color(color) if color else VMobject().color
        file_name = self._text2svg(color)
        PangoUtils.remove_last_M(file_name)
        super().__init__(
            file_name,
            fill_opacity=fill_opacity,
            stroke_width=stroke_width,
            height=height,
            width=width,
            should_center=should_center,
            use_svg_cache=False,
            **kwargs,
        )
        self.text = text
        if self.disable_ligatures:
            self.submobjects = [*self._gen_chars()]
        self.chars = self.get_group_class()(*self.submobjects)
        self.text = text_without_tabs.replace(" ", "").replace("\n", "")
        nppc = self.n_points_per_curve
        for each in self:
            if len(each.points) == 0:
                continue
            points = each.points
            curve_start = points[0]
            assert len(curve_start) == self.dim, curve_start
            # Some of the glyphs in this text might not be closed,
            # so we close them by identifying when one curve ends
            # but it is not where the next curve starts.
            # It is more efficient to temporarily create a list
            # of points and add them one at a time, then turn them
            # into a numpy array at the end, rather than creating
            # new numpy arrays every time a point or fixing line
            # is added (which is O(n^2) for numpy arrays).
            closed_curve_points = []
            # OpenGL has points be part of quadratic Bezier curves;
            # Cairo uses cubic Bezier curves.
            if nppc == 3:  # RendererType.OPENGL

                def add_line_to(end):
                    nonlocal closed_curve_points
                    start = closed_curve_points[-1]
                    closed_curve_points += [
                        start,
                        (start + end) / 2,
                        end,
                    ]

            else:  # RendererType.CAIRO

                def add_line_to(end):