Layout¶
Qualified name: manimpango.Layout
- class Layout(text=None, markup=None, font_desc=None, attributes=None, width=None, height=None, alignment=None, justify=None)¶
A
Layout
class represents an entire paragraph of text.Layout
provides a high-level driver for formatting entire paragraphs of text at once. This includes paragraph-level functionality such as line breaking, justification, alignment and ellipsization.A
Layout
is initialized with astr
. The layout can then be rendered. There are a number of parameters to adjust the formatting of aLayout
.When both
markup
andtext
is set the behavior is unknown.- Parameters
text (str) – The text to be set, by default None.
markup (str) – The text encoded in PangoMarkup, by default None.
font_desc (FontDescription) – The font description to be used while rendering.
attributes (list[TextAttribute]) –
width (int) –
height (int) –
alignment (Alignment) –
justify (bool) –
Examples
>>> import manimpango as mp >>> mp.Layout("hello world") <Layout text='hello world' markup=None>
- Raises
ValueError – If both
text
andmarkup
is None.- Parameters
text (str) –
markup (str) –
font_desc (FontDescription) –
attributes (list[TextAttribute]) –
width (int) –
height (int) –
alignment (Alignment) –
justify (bool) –
Methods
Returns the bounding box of the layout.
Renders the layout into a PNG or SVG file depending on the filename.
- get_bounding_box()¶
Returns the bounding box of the layout.
Note that it’s heavy to calculate the bounding box of a layout, so it’s better to cache the result.
Example
>>> import manimpango as mp >>> layout = mp.Layout("hello world") >>> layout.get_bounding_box() (0, 0, 82, 19)
- Returns
The bounding box of the layout in the form of
(x, y, width, height)
.- Return type
- property markup: str¶
The markup (in pango markup format) to render.
- Raises
MarkupParseError – If the passed markup is invalid.