TextAttribute#

Qualified name: manimpango.attributes.TextAttribute

class TextAttribute(start_index=0, end_index=- 1)#

TextAttribute defines the properties/attributes of the text within a specific range of the text.

A TextAttribute object can define multiple properties at the same time, for example, it can change the background_color, as well as, foreground_color. Also, a TextAttribute can be used for multiple times for different texts. By default, an attribute has an inclusive range from 0 to the end of the text -1, ie. [0, -1].

Initialize TextAttribute.

Parameters
  • start_index (int, optional) – The start index of the range, by default 0 (start of the string).

  • end_index (int, optional) – End index of the range. The character at this index is not included in the range, by default -1 (end of the string).

Return type

None

Methods

property allow_breaks: Optional[bool]#

Whether to break text or not.

If breaks are disabled, the range will be kept in a single run, as far as possible.

property background_alpha: float#

The background_alpha of the text.

Raises

ValueError – If the value is not between 0 and 1.

property background_color: Optional[Tuple[int]]#

The background color of the region.

If the input is a str the value is considered as string representation of color from CSS Specification. The color is then parsed and ValueError is raised if the color is invalid.

If the input is a collections.abc.Iterable then the items in them are parsed in the order of red, green, blue and checked whether they are valid (between 0 and 65535).

Returns either None or a tuple with 3 elements representing red, green, blue respectively. The value of each items in that tuple ranges from 0 to 65535.

Raises

ValueError – If the value passed isn’t a collections.abc.Iterable of 3 elements or a string. Another condition when ValueError is raised is when the color passed is invalid.

property end_index: int#

It is the start of the range. The character at this index is not included in the range.

Raises

ValueError – If the value is not an int.

property fallback: bool#

Enable or disable fallbacks.

If fallback is disabled, characters will only be used from the closest matching font on the system. No fallback will be done to other fonts on the system that might contain the characters in the text.

property family: str#

The font family the text should render. Can be a comma seperated list of fonts in a string.

Raises

ValueError – If value isn’t a str.

property start_index: int#

It is the end index of the range.

Raises

ValueError – If the value is not an int.