@@ -85,7 +85,7 @@ def construct(self):
85
85
from manim .mobject .text .text_mobject import Text
86
86
from manim .scene .scene import Scene
87
87
88
- from manim .constants import RIGHT , TAU
88
+ from manim .constants import DEFAULT_FONT_SIZE , DEFAULT_STROKE_WIDTH , RIGHT , TAU
89
89
from manim .mobject .opengl .opengl_surface import OpenGLSurface
90
90
from manim .mobject .opengl .opengl_vectorized_mobject import OpenGLVMobject
91
91
from manim .utils .color import ManimColor
@@ -94,6 +94,7 @@ def construct(self):
94
94
from ..animation .animation import Animation
95
95
from ..animation .composition import Succession
96
96
from ..mobject .mobject import Group , Mobject
97
+ from ..mobject .svg .svg_mobject import SVGMobject
97
98
from ..mobject .types .vectorized_mobject import VMobject
98
99
from ..utils .bezier import integer_interpolate
99
100
from ..utils .rate_functions import double_smooth , linear
@@ -322,6 +323,7 @@ def construct(self):
322
323
def __init__ (
323
324
self ,
324
325
vmobject : VMobject | OpenGLVMobject ,
326
+ stroke_width : float | None = None ,
325
327
rate_func : Callable [[float ], float ] = linear ,
326
328
reverse : bool = False ,
327
329
** kwargs ,
@@ -333,11 +335,13 @@ def __init__(
333
335
run_time ,
334
336
lag_ratio ,
335
337
)
338
+ stroke_width = self ._adjust_stroke_width_for_text (vmobject , stroke_width )
336
339
self .reverse = reverse
337
340
if "remover" not in kwargs :
338
341
kwargs ["remover" ] = reverse
339
342
super ().__init__ (
340
343
vmobject ,
344
+ stroke_width = stroke_width ,
341
345
rate_func = rate_func ,
342
346
run_time = run_time ,
343
347
lag_ratio = lag_ratio ,
@@ -358,6 +362,19 @@ def _set_default_config_from_length(
358
362
lag_ratio = min (4.0 / max (1.0 , length ), 0.2 )
359
363
return run_time , lag_ratio
360
364
365
+ def _adjust_stroke_width_for_text (
366
+ self ,
367
+ vmobject : VMobject | OpenGLVMobject ,
368
+ stroke_width : float | None ,
369
+ scale_factor : float = 0.25 ,
370
+ ) -> float :
371
+ if stroke_width is not None :
372
+ return stroke_width
373
+ if not isinstance (vmobject , SVGMobject ):
374
+ return 2.0 # default in DrawBorderThenFill
375
+ font_size = getattr (vmobject , "font_size" , DEFAULT_FONT_SIZE )
376
+ return (font_size / DEFAULT_FONT_SIZE ) * DEFAULT_STROKE_WIDTH * scale_factor
377
+
361
378
def reverse_submobjects (self ) -> None :
362
379
self .mobject .invert (recursive = True )
363
380
0 commit comments