A newer version of the Gradio SDK is available: 6.20.0
Text
Qualified name: manim.mobject.text.text\_mobject.Text
class Text(text, fill_opacity=1.0, stroke_width=0, color=None, font_size=48, line_spacing=-1, font='', slant='NORMAL', weight='NORMAL', t2c=None, t2f=None, t2g=None, t2s=None, t2w=None, gradient=None, tab_width=4, warn_missing_font=True, height=None, width=None, should_center=True, disable_ligatures=False, use_svg_cache=False, **kwargs)
Bases: SVGMobject
Display (non-LaTeX) text rendered using Pango.
Text objects behave like a VGroup-like iterable of all characters
in the given text. In particular, slicing is possible.
- Parameters:
- text (str) – The text that needs to be created as a mobject.
- font (str) – The font family to be used to render the text. This is either a system font or one loaded with register_font(). Note that font family names may be different across operating systems.
- warn_missing_font (bool) – If True (default), Manim will issue a warning if the font does not exist in the (case-sensitive) list of fonts returned from manimpango.list_fonts().
- fill_opacity (float)
- stroke_width (float)
- color (ParsableManimColor | None)
- font_size (float)
- line_spacing (float)
- slant (str)
- weight (str)
- t2c (dict *[*str , str ] | None)
- t2f (dict *[*str , str ] | None)
- t2g (dict *[**str* *,* *Iterable* *[*ParsableManimColor ] ] | None)
- t2s (dict *[*str , str ] | None)
- t2w (dict *[*str , str ] | None)
- gradient (Iterable *[*ParsableManimColor ] | None)
- tab_width (int)
- height (float | None)
- width (float | None)
- should_center (bool)
- disable_ligatures (bool)
- use_svg_cache (bool)
- kwargs (Any)
- Returns:
The mobject-like
VGroup. - Return type:
Text
Examples
As Text uses Pango to render text, rendering non-English
characters is easily possible:
Tests
Check that the creation of Text works:
>>> Text('The horse does not eat cucumber salad.')
Text('The horse does not eat cucumber salad.')
Methods
font_list |
|
|---|---|
init_colors |
Initializes the colors. |
Attributes
animate |
Used to animate the application of any method of self. |
|---|---|
animation_overrides |
|
color |
|
depth |
The depth of the mobject. |
fill_color |
If there are multiple colors (for gradient) this returns the first one |
font_size |
|
hash_seed |
A unique hash representing the result of the generated mobject points. |
height |
The height of the mobject. |
n_points_per_curve |
|
sheen_factor |
|
stroke_color |
|
width |
The width of the mobject. |
_find_indexes(word, text)
Finds the indexes of text in word.
- Parameters:
- word (str)
- text (str)
- Return type: list[tuple[int, int]]
_original__init__(text, fill_opacity=1.0, stroke_width=0, color=None, font_size=48, line_spacing=-1, font='', slant='NORMAL', weight='NORMAL', t2c=None, t2f=None, t2g=None, t2s=None, t2w=None, gradient=None, tab_width=4, warn_missing_font=True, height=None, width=None, should_center=True, disable_ligatures=False, use_svg_cache=False, **kwargs)
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
- text (str)
- fill_opacity (float)
- stroke_width (float)
- color (ParsableManimColor | None)
- font_size (float)
- line_spacing (float)
- font (str)
- slant (str)
- weight (str)
- t2c (dict *[*str , str ] | None)
- t2f (dict *[*str , str ] | None)
- t2g (dict *[**str* *,* *Iterable* *[*ParsableManimColor ] ] | None)
- t2s (dict *[*str , str ] | None)
- t2w (dict *[*str , str ] | None)
- gradient (Iterable *[*ParsableManimColor ] | None)
- tab_width (int)
- warn_missing_font (bool)
- height (float | None)
- width (float | None)
- should_center (bool)
- disable_ligatures (bool)
- use_svg_cache (bool)
- kwargs (Any)
_text2hash(color)
Generates sha256 hash for file name.
- Parameters: color (ParsableManimColor)
- Return type: str
_text2settings(color)
Converts the texts and styles to a setting for parsing.
- Parameters: color (ParsableManimColor)
- Return type: list[TextSetting]
_text2svg(color)
Convert the text to SVG using Pango.
- Parameters: color (ParsableManimColor)
- Return type: str
init_colors(propagate_colors=True)
Initializes the colors.
Gets called upon creation. This is an empty method that can be implemented by subclasses.
- Parameters: propagate_colors (bool)
- Return type: Self