animator.graphics.font_style.FontStyle¶
- class animator.graphics.font_style.FontStyle(name: Optional[Union[str, animator.skia.Typeface]] = None, size: Optional[float] = None, style: animator.skia.FontStyle | str = <animator.skia.FontStyle object>)¶
Bases:
object
Font style for text entities.
- __init__(name: Optional[Union[str, animator.skia.Typeface]] = None, size: Optional[float] = None, style: animator.skia.FontStyle | str = <animator.skia.FontStyle object>) None ¶
Create a new font style.
- Parameters
name – The name of the font or a
skia.Typeface
object to use. IfNone
, the default font is used.size – The font size to use. If
None
, the default font size is used.style – The font style to use.
Methods
__init__
([name, size, style])Create a new font style.
Get a list of the names of available fonts.
get_closest_font_name
(name)Get the closest available font name to the given name.
get_font
([name, style])Get the best matching font.
set_fake_slant
([slant])Set a fake slant for the font in case the font does not support slant.
set_fake_width
([width])Set a fake width for the font in case the font does not support width.
Attributes
COLOR
FAMILY_NAME
SIZE
STYLE
The font family name.
The font size.
The font style.
- static get_closest_font_name(name: str) str | None ¶
Get the closest available font name to the given name.
- static get_font(name: Optional[str] = None, style: animator.skia.FontStyle | str = <animator.skia.FontStyle object>) animator.skia.Typeface ¶
Get the best matching font.
- Parameters
name – The name of the font to use. If
None
, the default font is used.style – The font style to use.
- set_fake_slant(slant: float = 0) None ¶
Set a fake slant for the font in case the font does not support slant.
- Parameters
slant – The fake slant to set in degrees.
0
means no change. Positive values make the font slanted to the right, negative values make it slanted to the left.
- set_fake_width(width: float = 1) None ¶
Set a fake width for the font in case the font does not support width.
- Parameters
width – The fake width to set.
1
means no change. Smaller values make the font narrower, larger values make it wider.
- property style: animator.skia.FontStyle¶
The font style.