Text
Abstraction of text creation. Depending of the selected backend, the text
rendering can be more or less accurate.
-
class kivy.core.text.LabelBase(**kwargs)
Bases: object
Core text label.
This is the abstract class used for different backend to render text.
Warning
The core text label can’t be changed at runtime, you must recreate one.
| Parameters : |
- font_size: int, default to 12
Font size of the text
- font_name: str, default to DEFAULT_FONT
Font name of the text
- bold: bool, default to False
Activate “bold” text style
- italic: bool, default to False
Activate “italic” text style
- size: list, default to (None, None)
Add constraint to render the text (inside a bounding box)
If no size is given, the label size will be set to the text size.
- padding: int, default to None
If it’s a integer, it will set padding_x and padding_y
- padding_x: int, default to 0
Left/right padding
- padding_y: int, default to 0
Top/bottom padding
- halign: str, default to “left”
Horizontal text alignement inside bounding box
- valign: str, default to “bottom”
Vertical text alignement inside bounding box
- color: list, default to (1, 1, 1, 1)
Text color in (R, G, B, A)
|
-
content_height
Return the content height
-
content_size
Return the content size (width, height)
-
content_width
Return the content width
-
fontid
Return an uniq id for all font parameters
-
get_extents(text)
Return a tuple with (width, height) for a text.
-
label
Get/Set the text
-
refresh()
Force re-rendering of the text
-
render(real=False)
Return a tuple(width, height) to create the image
with the user constraints.
- 2 differents methods are used:
- if user don’t set width, splitting line
and calculate max width + height
- if user set a width, blit per glyph
-
text
Get/Set the text