Contains the font object and the functions used to create them.


  • pygame.font.quit() -> none
  • - uninitialize the font module
  • pygame.font.init() -> None
  • - initialize the display module
  • pygame.font.get_init() -> bool
  • - get status of font module initialization
  • Font.get_height() -> int
  • - average height of font glyph
  • Font.get_descent() -> int
  • - gets the font descent
  • Font.get_ascent() -> int
  • - gets the font ascent
  • get_linesize() -> int
  • - gets the font recommended linesize
  • Font.get_bold() -> bool
  • - status of the bold attribute
  • Font.set_bold(bool) -> None
  • - assign the bold attribute
  • get_bold() -> bool
  • - status of the italic attribute
  • Font.set_italic(bool) -> None
  • - assign the italic attribute
  • Font.get_underline() -> bool
  • - status of the underline attribute
  • Font.set_underline(bool) -> None
  • - assign the underline attribute
  • Font.render(text, antialias, fgcolor, [bgcolor])
  • - -> Surface
  • Font.size(text) -> (width, height)
  • - size of rendered text
  • pygame.font(file, size) -> Font
  • - create a new font object


    pygame.font.quit() -> none

    Manually uninitialize SDL's video subsystem. It is safe to call this if font is currently not initialized.


    pygame.font.init() -> None

    Manually initialize the font module. Will raise an exception if it cannot be initialized. It is safe to call this function if font is currently initialized.


    pygame.font.get_init() -> bool

    Returns true if the font module is currently intialized.


    Font.get_height() -> int

    Returns the average size of each glyph in the font.


    Font.get_descent() -> int

    Returns the descent for the font. The descent is the number of pixels from the font baseline to the bottom of the font.


    Font.get_ascent() -> int

    Returns the ascent for the font. The ascent is the number of pixels from the font baseline to the top of the font.


    get_linesize() -> int

    Returns the linesize for the font. Each font comes with it's own recommendation for the spacing number of pixels between each line of the font.


    Font.get_bold() -> bool

    Get the current status of the font's bold attribute


    Font.set_bold(bool) -> None

    Enables or disables the bold attribute for the font. Making the font bold does not work as well as you expect.


    get_bold() -> bool

    Get the current status of the font's italic attribute


    Font.set_italic(bool) -> None

    Enables or disables the italic attribute for the font.


    Font.get_underline() -> bool

    Get the current status of the font's underline attribute


    Font.set_underline(bool) -> None

    Enables or disables the underline attribute for the font.


    Font.render(text, antialias, fgcolor, [bgcolor])

    Render the given text onto a new image surface. The given text can be standard python text or unicode. Antialiasing will smooth the edges of the font for a much cleaner look. The foreground color is a 3-number-sequence containing the desired RGB components for the text. The background color is also a 3-number-sequence of RGB. This sets the background color for the text. If the background color is omitted, the text will have a transparent background.


    Font.size(text) -> (width, height)

    Computes the rendered size of the given text. The text can be standard python text or unicode. Know that changing the bold and italic attributes will change the size of the rendered text.


    pygame.font(file, size) -> Font

    This will create a new font object. The given file must be an existing filename. The font loader does not work with python file-like objects. The size represents the height of the font in pixels.