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

Code before:
        font_size: float = DEFAULT_FONT_SIZE,
        line_spacing: float = -1,
        font: str = "",
        slant: str = NORMAL,
        weight: str = NORMAL,
        t2c: dict[str, str] = None,
        t2f: dict[str, str] = None,
        t2g: dict[str, tuple] = None,
        t2s: dict[str, str] = None,
        t2w: dict[str, str] = None,
        gradient: tuple = None,
        tab_width: int = 4,
        warn_missing_font: bool = True,
        # Mobject
        height: float = None,
        width: float = None,
        should_center: bool = True,
        disable_ligatures: bool = False,
        use_svg_cache: bool = False,
        **kwargs,
    ) -> None:
        self.line_spacing = line_spacing
        if font and warn_missing_font:
            Text.font_list = (
                Text.font_list if len(Text.font_list) > 0 else manimpango.list_fonts()
            )
            if font not in Text.font_list:
                logger.warning(f"Font {font} not in {Text.font_list}.")
        self.font = font
        self._font_size = float(font_size)
        # needs to be a float or else size is inflated when font_size = 24
        # (unknown cause)
        self.slant = slant
        self.weight = weight
        self.gradient = gradient
        self.tab_width = tab_width
        if t2c is None:
            t2c = {}
        if t2f is None:
            t2f = {}
        if t2g is None:
            t2g = {}
        if t2s is None:
            t2s = {}
        if t2w is None:
            t2w = {}
        # If long form arguments are present, they take precedence
        t2c = kwargs.pop("text2color", t2c)
        t2f = kwargs.pop("text2font", t2f)
        t2g = kwargs.pop("text2gradient", t2g)
        t2s = kwargs.pop("text2slant", t2s)

Review comment (performance):
More of a semantical question: is there any particular argument against implementing this as a cached method of `Text`? Like

```py
class Text(...):
    ...
    
    @staticmethod
    @functools.lru_cache(maxsize=None)
    def font_list() -> list[str]:
        return manimpango.list_fonts()
```

Code after:
        self,
        text: str,
        fill_opacity: float = 1.0,
        stroke_width: float = 0,
        color: ParsableManimColor | None = None,
        font_size: float = DEFAULT_FONT_SIZE,
        line_spacing: float = -1,
        font: str = "",
        slant: str = NORMAL,
        weight: str = NORMAL,
        t2c: dict[str, str] = None,
        t2f: dict[str, str] = None,
        t2g: dict[str, tuple] = None,
        t2s: dict[str, str] = None,
        t2w: dict[str, str] = None,
        gradient: tuple = None,
        tab_width: int = 4,
        warn_missing_font: bool = True,
        # Mobject
        height: float = None,
        width: float = None,
        should_center: bool = True,
        disable_ligatures: bool = False,
        use_svg_cache: bool = False,
        **kwargs,
    ) -> None:
        self.line_spacing = line_spacing
        if font and warn_missing_font and font not in Text.font_list():
            logger.warning(f"Font {font} not in {Text.font_list()}.")
        self.font = font
        self._font_size = float(font_size)
        # needs to be a float or else size is inflated when font_size = 24
        # (unknown cause)
        self.slant = slant
        self.weight = weight
        self.gradient = gradient
        self.tab_width = tab_width
        if t2c is None:
            t2c = {}
        if t2f is None:
            t2f = {}
        if t2g is None:
            t2g = {}
        if t2s is None:
            t2s = {}
        if t2w is None:
            t2w = {}
        # If long form arguments are present, they take precedence
        t2c = kwargs.pop("text2color", t2c)
        t2f = kwargs.pop("text2font", t2f)
        t2g = kwargs.pop("text2gradient", t2g)