### Navigation

- index
- next |
- previous |
- The Pygame SGE 0.5.0 documentation »
- Classes »

# sge.Font

class `sge.``Font`(name=None, ID=None, size=12, underline=False, bold=False, italic=False)

  Font handling class.

  This class stores a font for use by `sge.Sprite.draw_text()` and `sge.Room.project_text()`.

  Note that bold and italic rendering could be ugly. It is better to choose a bold or italic font rather than enabling bold or italic rendering, if possible.

  `size`

    The height of the font in pixels.

  `underline`

    Whether or not underlined rendering is enabled.

  `bold`

    Whether or not bold rendering is enabled.

    Note

    Using this option can be ugly. It is better to choose a bold font rather than enabling bold rendering, if possible.

  `italic`

    Whether or not italic rendering is enabled.

    Note

    Using this option can be ugly. It is better to choose an italic font rather than enabling italic rendering, if possible.

  `name`

    The name of the font as specified when it was created. (Read-only)

  `id`

    The unique identifier of the font. (Read-only)

## sge.Font Methods

`Font.``__init__`(name=None, ID=None, size=12, underline=False, bold=False, italic=False)

  Constructor method.

  Arguments:

  - `name` – The name of the font. Can be one of the following:

    - A string indicating the name of a font file located in one of the paths specified in `sge.font_directories`, e.g. `"MyFont.ttf"`.
    - A string indicating the case-insensitive name of a system font, e.g. `"Liberation Serif"`.
    - A list or tuple of strings indicating either a font file or a system font to choose from in order of preference.

    If none of the above methods return a valid font, the SGE will choose the font.

  - `ID` – The value to set `id` to. If set to `None`, `name` will be used, modified by the SGE if it is already the unique identifier of another font.

  All other arguments set the respective initial attributes of the font. See the documentation for `sge.Font` for more information.

  Note

  It is generally not a good practice to rely on system fonts. A font which you have on your system is probably not on everyone’s system. For example, most Windows systems have a font called Times New Roman, but this font is not normally found on Debian systems. On the other hand, Debian has the Liberation fonts installed by default, but these fonts are uncommon on Windows systems. Rather than relying on system fonts, choose a font which is under a free license (such as the GNU General Public License or the SIL Open Font License) and distribute it with your game; this will ensure that everyone sees text rendered the same way you do.

`Font.``get_size`(text, width=None, height=None)

  Return the size of a certain string of text when rendered.

  See the documentation for `sge.Sprite.draw_text()` for information about the arguments.

### Navigation

- index
- next |
- previous |
- The Pygame SGE 0.5.0 documentation »
- Classes »