Font

A typeface object for rendering text in different styles.

  • Font(file_dir: str, pt_size: int)

Note:

file_dir can be given "kraken-clean" or "kraken-retro" for preloaded fonts. If loaded "kraken-retro", pt_size will be rounded to the nearest multiple of 8. No matter the font, pt_size will be clamped to a minimum of 8.

Methods


Draw

draw(text: str, pos: Vec2 = None, color: Color = None, wrap_width: int = 0) None

Draw text to the renderer.

Parameters

  • text : The text to render.
  • pos : The position to draw the text at (from the top left). Defaults to (0, 0).
  • color : The color to render the text as. Defaults to (255, 255, 255).
  • wrap_width : Wrap the text at the given pixel width. 0 for no explicit wrapping. Defaults to 0.

Note:

\n will write text on a new line.

Set Bold

set_bold(on: bool) None

Set the text bold state.

Parameters

  • on : Whether to enable or disable bold text.

Set Italic

set_italic(on: bool) None

Set the text italic state.

Parameters

  • on : Whether to enable or disable italic text.

Set Underline

set_underline(on: bool) None

Set the text underline state.

Parameters

  • on : Whether to enable or disable underline text.

Set Strikethrough

set_strikethrough(on: bool) None

Set the text strikethrough state.

Parameters

  • on : Whether to enable or disable strikethrough text.

Set Pt Size

set_pt_size(pt: int) None

Set the text point size.

Parameters

  • pt : The point size to set the text to. Values below 8 are clamped to 8.