ipygame.font
pygame-compatible font module.
def init() -> Nonedef quit() -> Noneget_init
Section titled “get_init”def get_init() -> boolget_sdl_ttf_version
Section titled “get_sdl_ttf_version”def get_sdl_ttf_version(linked: bool = True)get_default_font
Section titled “get_default_font”def get_default_font() -> strget_fonts
Section titled “get_fonts”def get_fonts() -> list[str]List available system font names (lowercase, no extension).
match_font
Section titled “match_font”def match_font(name: str, bold: bool = False, italic: bool = False) -> str | NoneFind a specific system font file path.
SysFont
Section titled “SysFont”def SysFont(name: str | Sequence[str] | None, size: int, bold: bool = False, italic: bool = False, constructor=None) -> "Font"Create a Font from system fonts.
Font Objects
Section titled “Font Objects”class Font()TrueType font rendering using Pillow.
__init__
Section titled “__init__”def __init__(filename: str | Path | None = None, size: int = 20)@propertydef name() -> strstyle_name
Section titled “style_name”@propertydef style_name() -> str@propertydef bold() -> bool@bold.setterdef bold(value: bool)italic
Section titled “italic”@propertydef italic() -> boolitalic
Section titled “italic”@italic.setterdef italic(value: bool)underline
Section titled “underline”@propertydef underline() -> boolunderline
Section titled “underline”@underline.setterdef underline(value: bool)strikethrough
Section titled “strikethrough”@propertydef strikethrough() -> boolstrikethrough
Section titled “strikethrough”@strikethrough.setterdef strikethrough(value: bool)point_size
Section titled “point_size”@propertydef point_size() -> intpoint_size
Section titled “point_size”@point_size.setterdef point_size(value: int)set_bold
Section titled “set_bold”def set_bold(value: bool) -> Noneget_bold
Section titled “get_bold”def get_bold() -> boolset_italic
Section titled “set_italic”def set_italic(value: bool) -> Noneget_italic
Section titled “get_italic”def get_italic() -> boolset_underline
Section titled “set_underline”def set_underline(value: bool) -> Noneget_underline
Section titled “get_underline”def get_underline() -> boolset_strikethrough
Section titled “set_strikethrough”def set_strikethrough(value: bool) -> Noneget_strikethrough
Section titled “get_strikethrough”def get_strikethrough() -> booldef size(text: str) -> tuple[int, int]Get the rendered dimensions of text.
get_height
Section titled “get_height”def get_height() -> intFont height in pixels.
get_linesize
Section titled “get_linesize”def get_linesize() -> intLine spacing (height + leading).
set_linesize
Section titled “set_linesize”def set_linesize(linesize: int) -> Noneget_ascent
Section titled “get_ascent”def get_ascent() -> intget_descent
Section titled “get_descent”def get_descent() -> intget_point_size
Section titled “get_point_size”def get_point_size() -> intset_point_size
Section titled “set_point_size”def set_point_size(val: int) -> Noneset_script
Section titled “set_script”def set_script(script_code: str) -> Noneset_direction
Section titled “set_direction”def set_direction(direction: int) -> Nonemetrics
Section titled “metrics”def metrics(text: str) -> list[tuple[int, int, int, int, int]]Return per-character metrics: (min_x, max_x, min_y, max_y, advance).
render
Section titled “render”def render(text: str, antialias: bool = True, color=None, bgcolor=None, wraplength: int = 0) -> SurfaceRender text to a new Surface.