@@ -49,6 +49,8 @@ def construct(self):
49
49
50
50
from __future__ import annotations
51
51
52
+ import functools
53
+
52
54
__all__ = ["Text" , "Paragraph" , "MarkupText" , "register_font" ]
53
55
54
56
@@ -407,6 +409,11 @@ def construct(self):
407
409
408
410
"""
409
411
412
+ @staticmethod
413
+ @functools .lru_cache (maxsize = None )
414
+ def font_list () -> list [str ]:
415
+ return manimpango .list_fonts ()
416
+
410
417
def __init__ (
411
418
self ,
412
419
text : str ,
@@ -431,13 +438,12 @@ def __init__(
431
438
width : float = None ,
432
439
should_center : bool = True ,
433
440
disable_ligatures : bool = False ,
441
+ use_svg_cache : bool = False ,
434
442
** kwargs ,
435
443
) -> None :
436
444
self .line_spacing = line_spacing
437
- if font and warn_missing_font :
438
- fonts_list = manimpango .list_fonts ()
439
- if font not in fonts_list :
440
- logger .warning (f"Font { font } not in { fonts_list } ." )
445
+ if font and warn_missing_font and font not in Text .font_list ():
446
+ logger .warning (f"Font { font } not in { Text .font_list ()} ." )
441
447
self .font = font
442
448
self ._font_size = float (font_size )
443
449
# needs to be a float or else size is inflated when font_size = 24
@@ -491,7 +497,7 @@ def __init__(
491
497
height = height ,
492
498
width = width ,
493
499
should_center = should_center ,
494
- use_svg_cache = False ,
500
+ use_svg_cache = use_svg_cache ,
495
501
** kwargs ,
496
502
)
497
503
self .text = text
@@ -1133,6 +1139,11 @@ def construct(self):
1133
1139
1134
1140
"""
1135
1141
1142
+ @staticmethod
1143
+ @functools .lru_cache (maxsize = None )
1144
+ def font_list () -> list [str ]:
1145
+ return manimpango .list_fonts ()
1146
+
1136
1147
def __init__ (
1137
1148
self ,
1138
1149
text : str ,
@@ -1156,10 +1167,8 @@ def __init__(
1156
1167
) -> None :
1157
1168
self .text = text
1158
1169
self .line_spacing = line_spacing
1159
- if font and warn_missing_font :
1160
- fonts_list = manimpango .list_fonts ()
1161
- if font not in fonts_list :
1162
- logger .warning (f"Font { font } not in { fonts_list } ." )
1170
+ if font and warn_missing_font and font not in Text .font_list ():
1171
+ logger .warning (f"Font { font } not in { Text .font_list ()} ." )
1163
1172
self .font = font
1164
1173
self ._font_size = float (font_size )
1165
1174
self .slant = slant
0 commit comments