ImageText
ClassSource
ImageText(
text: str,
font: str | PathLike[str] | FontInfo | None = None,
font_size: int | str | ImageFontSize | ImageFontAbsSize = ImageFontSize.h2,
pad_size: int = 0,
color: str | tuple[float, ...] = "#FFFFFF",
)
A layer of text that can be rendered as an image.
The image will be rendered every time when it is accessed.
Arguments
Requires
| Name | Type | Required | |
|---|---|---|---|
text | str | The text to be rendered. | |
font | str | PathLike[str] | FontInfo | None | The path of the font, or the searched font used for rendering the text. If not specified, will use the default font. | |
font_size | int | str | ImageFontSize | ImageFontAbsSize | The dynamic font size of the rendered text. If using int, this size will be absolute. | |
pad_size | int | The size used for padding on all sides of the text. | |
color | str | tuple[float, ...] | The text color. |
Methods
copy
v_1: Self = self.copy()
Get a copy of this instance.
Returns
| Name | Type | |
|---|---|---|
v_1 | Self | The copied text image. |
Properties
font_size
font_size: ImageFontAbsSize | ImageFontSize = self.font_size
The font size (dynamic or absolute size).
height
height: int = self.height
The height of the text image.
img
img: Image = self.img
Render the text as an image, and get the pixel-based image.
size
size: tuple[int, int] = self.size
The (width, height) shape of the text image.
text
text: str = self.text
The text to be rendered.
width
width: int = self.width
The width of the text image.