pygame.freetype

 Enhanced pygame module for loading and rendering computer fonts  The pygame.freetype module is a replacement for pygame.font. It has all of the functionality of the original, plus many new features. Yet is has absolutely no dependencies on the SDL_ttf library. It is implemented directly on the FreeType 2 library. The pygame.freetype module is not itself backward compatible with pygame.font. Instead, use the pygame.ftfont module as a drop-in replacement for pygame.font. All font file formats supported by FreeType can be rendered by pygame.freetype, namely TTF, Type1, CFF, OpenType, SFNT, PCF, FNT, BDF, PFR and Type42 fonts. All glyphs having UTF-32 code points are accessible (see Font.ucs4). Most work on fonts is done using Font instances. The module itself only has routines for initialization and creation of Font objects. You can load fonts from the system using the SysFont() function. Extra support of bitmap fonts is available. Available bitmap sizes can be listed (see Font.get_sizes()). For bitmap only fonts Font can set the size for you (see the Font.size property). For now undefined character codes are replaced with the .notdef (not defined) character. How undefined codes are handled may become configurable in a future release. Pygame comes with a built-in default font. This can always be accessed by passing None as the font name to the Font constructor. Extra rendering features available to pygame.freetype.Font are direct to surface rendering (see Font.render_to()), character kerning (see Font.kerning), vertical layout (see Font.vertical), rotation of rendered text (see Font.rotation), and the strong style (see Font.strong). Some properties are configurable, such as strong style strength (see Font.strength) and underline positioning (see Font.underline_adjustment). Text can be positioned by the upper right corner of the text box or by the text baseline (see Font.origin). Finally, a font's vertical and horizontal size can be adjusted separately (see Font.size). The pygame.examples.freetype_misc example shows these features in use. The pygame package does not import freetype automatically when loaded. This module must be imported explicitly to be used. import pygame
import pygame.freetype  New in pygame 1.9.2: freetype    pygame.freetype.get_error()
 Return the latest FreeType error get_error() -> str get_error() -> None  Return a description of the last error which occurred in the FreeType2 library, or None if no errors have occurred.
   pygame.freetype.get_version()
 Return the FreeType version get_version() -> (int, int, int)  Returns the version of the FreeType library in use by this module. Note that the freetype module depends on the FreeType 2 library. It will not compile with the original FreeType 1.0. Hence, the first element of the tuple will always be "2".
   pygame.freetype.init()
 Initialize the underlying FreeType library. init(cache_size=64, resolution=72)  This function initializes the underlying FreeType library and must be called before trying to use any of the functionality of the freetype module. However, pygame.init() will automatically call this function if the freetype module is already imported. It is safe to call this function more than once. Optionally, you may specify a default cache_size for the Glyph cache: the maximum number of glyphs that will be cached at any given time by the module. Exceedingly small values will be automatically tuned for performance. Also a default pixel resolution, in dots per inch, can be given to adjust font scaling.
   pygame.freetype.quit()
 Shut down the underlying FreeType library. quit()  This function closes the freetype module. After calling this function, you should not invoke any class, method or function related to the freetype module as they are likely to fail or might give unpredictable results. It is safe to call this function even if the module hasn't been initialized yet.
   pygame.freetype.get_init()
 Returns True if the FreeType module is currently initialized. get_init() -> bool  Returns True if the pygame.freetype module is currently initialized.  New in pygame 1.9.5.
   pygame.freetype.was_init()
 DEPRECATED: Use get_init() instead. was_init() -> bool  DEPRECATED: Returns True if the pygame.freetype module is currently initialized. Use get_init() instead.
   pygame.freetype.get_cache_size()
 Return the glyph case size get_cache_size() -> long  See pygame.freetype.init().
   pygame.freetype.get_default_resolution()
 Return the default pixel size in dots per inch get_default_resolution() -> long  Returns the default pixel size, in dots per inch, for the module. The default is 72 DPI.
   pygame.freetype.set_default_resolution()
 Set the default pixel size in dots per inch for the module set_default_resolution([resolution])  Set the default pixel size, in dots per inch, for the module. If the optional argument is omitted or zero the resolution is reset to 72 DPI.
   pygame.freetype.SysFont()
 create a Font object from the system fonts SysFont(name, size, bold=False, italic=False) -> Font  Return a new Font object that is loaded from the system fonts. The font will match the requested bold and italic flags. Pygame uses a small set of common font aliases. If the specific font you ask for is not available, a reasonable alternative may be used. If a suitable system font is not found this will fall back on loading the default pygame font. The font name can also be an iterable of font names, a string of comma-separated font names, or a bytes of comma-separated font names, in which case the set of names will be searched in order.  New in pygame 2.0.1: Accept an iterable of font names.
   pygame.freetype.get_default_font()
 Get the filename of the default font get_default_font() -> string  Return the filename of the default pygame font. This is not the full path to the file. The file is usually in the same directory as the font module, but can also be bundled in a separate archive.
   pygame.freetype.Font
 Create a new Font instance from a supported font file. Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font  Argument file can be either a string representing the font's filename, a file-like object containing the font, or None; if None, a default, Pygame, font is used. Optionally, a size argument may be specified to set the default size in points, which determines the size of the rendered characters. The size can also be passed explicitly to each method call. Because of the way the caching system works, specifying a default size on the constructor doesn't imply a performance gain over manually passing the size on each function call. If the font is bitmap and no size is given, the default size is set to the first available size for the font. If the font file has more than one font, the font to load can be chosen with the index argument. An exception is raised for an out-of-range font index value. The optional resolution argument sets the pixel size, in dots per inch, for use in scaling glyphs for this Font instance. If 0 then the default module value, set by init(), is used. The Font object's resolution can only be changed by re-initializing the Font instance. The optional ucs4 argument, an integer, sets the default text translation mode: 0 (False) recognize UTF-16 surrogate pairs, any other value (True), to treat Unicode text as UCS-4, with no surrogate pairs. See Font.ucs4.   name
 Proper font name. name -> string  Read only. Returns the real (long) name of the font, as recorded in the font file.
   path
 Font file path path -> unicode  Read only. Returns the path of the loaded font file
   size
 The default point size used in rendering size -> float size -> (float, float)  Get or set the default size for text metrics and rendering. It can be a single point size, given as a Python int or float, or a font ppem (width, height) tuple. Size values are non-negative. A zero size or width represents an undefined size. In this case the size must be given as a method argument, or an exception is raised. A zero width but non-zero height is a ValueError. For a scalable font, a single number value is equivalent to a tuple with width equal height. A font can be stretched vertically with height set greater than width, or horizontally with width set greater than height. For embedded bitmaps, as listed by get_sizes(), use the nominal width and height to select an available size. Font size differs for a non-scalable, bitmap, font. During a method call it must match one of the available sizes returned by method get_sizes(). If not, an exception is raised. If the size is a single number, the size is first matched against the point size value. If no match, then the available size with the same nominal width and height is chosen.
   get_rect()
 Return the size and offset of rendered text get_rect(text, style=STYLE_DEFAULT, rotation=0, size=0) -> rect  Gets the final dimensions and origin, in pixels, of text using the optional size in points, style, and rotation. For other relevant render properties, and for any optional argument not given, the default values set for the Font instance are used. Returns a Rect instance containing the width and height of the text's bounding box and the position of the text's origin. The origin is useful in aligning separately rendered pieces of text. It gives the baseline position and bearing at the start of the text. See the render_to() method for an example. If text is a char (byte) string, its encoding is assumed to be LATIN1. Optionally, text can be None, which will return the bounding rectangle for the text passed to a previous get_rect(), render(), render_to(), render_raw(), or render_raw_to() call. See render_to() for more details.
   get_metrics()
 Return the glyph metrics for the given text get_metrics(text, size=0) -> [(...), ...]  Returns the glyph metrics for each character in text. The glyph metrics are returned as a list of tuples. Each tuple gives metrics of a single character glyph. The glyph metrics are: (min_x, max_x, min_y, max_y, horizontal_advance_x, horizontal_advance_y) The bounding box min_x, max_x, min_y, and max_y values are returned as grid-fitted pixel coordinates of type int. The advance values are float values. The calculations are done using the font's default size in points. Optionally you may specify another point size with the size argument. The metrics are adjusted for the current rotation, strong, and oblique settings. If text is a char (byte) string, then its encoding is assumed to be LATIN1.
   height
 The unscaled height of the font in font units height -> int  Read only. Gets the height of the font. This is the average value of all glyphs in the font.
   ascender
 The unscaled ascent of the font in font units ascender -> int  Read only. Return the number of units from the font's baseline to the top of the bounding box.
   descender
 The unscaled descent of the font in font units descender -> int  Read only. Return the height in font units for the font descent. The descent is the number of units from the font's baseline to the bottom of the bounding box.
   get_sized_ascender()
 The scaled ascent of the font in pixels get_sized_ascender(<size>=0) -> int  Return the number of units from the font's baseline to the top of the bounding box. It is not adjusted for strong or rotation.
   get_sized_descender()
 The scaled descent of the font in pixels get_sized_descender(<size>=0) -> int  Return the number of pixels from the font's baseline to the top of the bounding box. It is not adjusted for strong or rotation.
   get_sized_height()
 The scaled height of the font in pixels get_sized_height(<size>=0) -> int  Returns the height of the font. This is the average value of all glyphs in the font. It is not adjusted for strong or rotation.
   get_sized_glyph_height()
 The scaled bounding box height of the font in pixels get_sized_glyph_height(<size>=0) -> int  Return the glyph bounding box height of the font in pixels. This is the average value of all glyphs in the font. It is not adjusted for strong or rotation.
   get_sizes()
 return the available sizes of embedded bitmaps get_sizes() -> [(int, int, int, float, float), ...] get_sizes() -> []  Returns a list of tuple records, one for each point size supported. Each tuple containing the point size, the height in pixels, width in pixels, horizontal ppem (nominal width) in fractional pixels, and vertical ppem (nominal height) in fractional pixels.
   render()
 Return rendered text as a surface render(text, fgcolor=None, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> (Surface, Rect)  Returns a new Surface, with the text rendered to it in the color given by 'fgcolor'. If no foreground color is given, the default foreground color, fgcolor is used. If bgcolor is given, the surface will be filled with this color. When no background color is given, the surface background is transparent, zero alpha. Normally the returned surface has a 32 bit pixel size. However, if bgcolor is None and anti-aliasing is disabled a monochrome 8 bit colorkey surface, with colorkey set for the background color, is returned. The return value is a tuple: the new surface and the bounding rectangle giving the size and origin of the rendered text. If an empty string is passed for text then the returned Rect is zero width and the height of the font. Optional fgcolor, style, rotation, and size arguments override the default values set for the Font instance. If text is a char (byte) string, then its encoding is assumed to be LATIN1. Optionally, text can be None, which will render the text passed to a previous get_rect(), render(), render_to(), render_raw(), or render_raw_to() call. See render_to() for details.
   render_to()
 Render text onto an existing surface render_to(surf, dest, text, fgcolor=None, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> Rect  Renders the string text to the pygame.Surface surf, at position dest, a (x, y) surface coordinate pair. If either x or y is not an integer it is converted to one if possible. Any sequence where the first two items are x and y positional elements is accepted, including a Rect instance. As with render(), optional fgcolor, style, rotation, and size argument are available. If a background color bgcolor is given, the text bounding box is first filled with that color. The text is blitted next. Both the background fill and text rendering involve full alpha blits. That is, the alpha values of the foreground, background, and destination target surface all affect the blit. The return value is a rectangle giving the size and position of the rendered text within the surface. If an empty string is passed for text then the returned Rect is zero width and the height of the font. The rect will test False. Optionally, text can be set None, which will re-render text passed to a previous render_to(), get_rect(), render(), render_raw(), or render_raw_to() call. Primarily, this feature is an aid to using render_to() in combination with get_rect(). An example: def word_wrap(surf, text, font, color=(0, 0, 0)):
    font.origin = True
    words = text.split(' ')
    width, height = surf.get_size()
    line_spacing = font.get_sized_height() + 2
    x, y = 0, line_spacing
    space = font.get_rect(' ')
    for word in words:
        bounds = font.get_rect(word)
        if x + bounds.width + bounds.x >= width:
            x, y = 0, y + line_spacing
        if x + bounds.width + bounds.x >= width:
            raise ValueError("word too wide for the surface")
        if y + bounds.height - bounds.y >= height:
            raise ValueError("text to long for the surface")
        font.render_to(surf, (x, y), None, color)
        x += bounds.width + space.width
    return x, y When render_to() is called with the same font properties ― size, style, strength, wide, antialiased, vertical, rotation, kerning, and use_bitmap_strikes ― as get_rect(), render_to() will use the layout calculated by get_rect(). Otherwise, render_to() will recalculate the layout if called with a text string or one of the above properties has changed after the get_rect() call. If text is a char (byte) string, then its encoding is assumed to be LATIN1.
   render_raw()
 Return rendered text as a string of bytes render_raw(text, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (bytes, (int, int))  Like render() but with the pixels returned as a byte string of 8-bit gray-scale values. The foreground color is 255, the background 0, useful as an alpha mask for a foreground pattern.
   render_raw_to()
 Render text into an array of ints render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> Rect  Render to an array object exposing an array struct interface. The array must be two dimensional with integer items. The default dest value, None, is equivalent to position (0, 0). See render_to(). As with the other render methods, text can be None to render a text string passed previously to another method. The return value is a pygame.Rect() giving the size and position of the rendered text.
   style
 The font's style flags style -> int  Gets or sets the default style of the Font. This default style will be used for all text rendering and size calculations unless overridden specifically a render or get_rect() call. The style value may be a bit-wise OR of one or more of the following constants: STYLE_NORMAL
STYLE_UNDERLINE
STYLE_OBLIQUE
STYLE_STRONG
STYLE_WIDE
STYLE_DEFAULT These constants may be found on the FreeType constants module. Optionally, the default style can be modified or obtained accessing the individual style attributes (underline, oblique, strong). The STYLE_OBLIQUE and STYLE_STRONG styles are for scalable fonts only. An attempt to set either for a bitmap font raises an AttributeError. An attempt to set either for an inactive font, as returned by Font.__new__(), raises a RuntimeError. Assigning STYLE_DEFAULT to the style property leaves the property unchanged, as this property defines the default. The style property will never return STYLE_DEFAULT.
   underline
 The state of the font's underline style flag underline -> bool  Gets or sets whether the font will be underlined when drawing text. This default style value will be used for all text rendering and size calculations unless overridden specifically in a render or get_rect() call, via the 'style' parameter.
   strong
 The state of the font's strong style flag strong -> bool  Gets or sets whether the font will be bold when drawing text. This default style value will be used for all text rendering and size calculations unless overridden specifically in a render or get_rect() call, via the 'style' parameter.
   oblique
 The state of the font's oblique style flag oblique -> bool  Gets or sets whether the font will be rendered as oblique. This default style value will be used for all text rendering and size calculations unless overridden specifically in a render or get_rect() call, via the style parameter. The oblique style is only supported for scalable (outline) fonts. An attempt to set this style on a bitmap font will raise an AttributeError. If the font object is inactive, as returned by Font.__new__(), setting this property raises a RuntimeError.
   wide
 The state of the font's wide style flag wide -> bool  Gets or sets whether the font will be stretched horizontally when drawing text. It produces a result similar to pygame.font.Font's bold. This style not available for rotated text.
   strength
 The strength associated with the strong or wide font styles strength -> float  The amount by which a font glyph's size is enlarged for the strong or wide transformations, as a fraction of the untransformed size. For the wide style only the horizontal dimension is increased. For strong text both the horizontal and vertical dimensions are enlarged. A wide style of strength 0.08333 ( 1/12 ) is equivalent to the pygame.font.Font bold style. The default is 0.02778 ( 1/36 ). The strength style is only supported for scalable (outline) fonts. An attempt to set this property on a bitmap font will raise an AttributeError. If the font object is inactive, as returned by Font.__new__(), assignment to this property raises a RuntimeError.
   underline_adjustment
 Adjustment factor for the underline position underline_adjustment -> float  Gets or sets a factor which, when positive, is multiplied with the font's underline offset to adjust the underline position. A negative value turns an underline into a strike-through or overline. It is multiplied with the ascender. Accepted values range between -2.0 and 2.0 inclusive. A value of 0.5 closely matches Tango underlining. A value of 1.0 mimics pygame.font.Font underlining.
   fixed_width
 Gets whether the font is fixed-width fixed_width -> bool  Read only. Returns True if the font contains fixed-width characters (for example Courier, Bitstream Vera Sans Mono, Andale Mono).
   fixed_sizes
 the number of available bitmap sizes for the font fixed_sizes -> int  Read only. Returns the number of point sizes for which the font contains bitmap character images. If zero then the font is not a bitmap font. A scalable font may contain pre-rendered point sizes as strikes.
   scalable
 Gets whether the font is scalable scalable -> bool  Read only. Returns True if the font contains outline glyphs. If so, the point size is not limited to available bitmap sizes.
   use_bitmap_strikes
 allow the use of embedded bitmaps in an outline font file use_bitmap_strikes -> bool  Some scalable fonts include embedded bitmaps for particular point sizes. This property controls whether or not those bitmap strikes are used. Set it False to disable the loading of any bitmap strike. Set it True, the default, to permit bitmap strikes for a non-rotated render with no style other than wide or underline. This property is ignored for bitmap fonts. See also fixed_sizes and get_sizes().
   antialiased
 Font anti-aliasing mode antialiased -> bool  Gets or sets the font's anti-aliasing mode. This defaults to True on all fonts, which are rendered with full 8 bit blending. Set to False to do monochrome rendering. This should provide a small speed gain and reduce cache memory size.
   kerning
 Character kerning mode kerning -> bool  Gets or sets the font's kerning mode. This defaults to False on all fonts, which will be rendered without kerning. Set to True to add kerning between character pairs, if supported by the font, when positioning glyphs.
   vertical
 Font vertical mode vertical -> bool  Gets or sets whether the characters are laid out vertically rather than horizontally. May be useful when rendering Kanji or some other vertical script. Set to True to switch to a vertical text layout. The default is False, place horizontally. Note that the Font class does not automatically determine script orientation. Vertical layout must be selected explicitly. Also note that several font formats (especially bitmap based ones) don't contain the necessary metrics to draw glyphs vertically, so drawing in those cases will give unspecified results.
   rotation
 text rotation in degrees counterclockwise rotation -> int  Gets or sets the baseline angle of the rendered text. The angle is represented as integer degrees. The default angle is 0, with horizontal text rendered along the X-axis, and vertical text along the Y-axis. A positive value rotates these axes counterclockwise that many degrees. A negative angle corresponds to a clockwise rotation. The rotation value is normalized to a value within the range 0 to 359 inclusive (eg. 390 -> 390 - 360 -> 30, -45 -> 360 + -45 -> 315, 720 -> 720 - (2 * 360) -> 0). Only scalable (outline) fonts can be rotated. An attempt to change the rotation of a bitmap font raises an AttributeError. An attempt to change the rotation of an inactive font instance, as returned by Font.__new__(), raises a RuntimeError.
   fgcolor
 default foreground color fgcolor -> Color  Gets or sets the default glyph rendering color. It is initially opaque black ― (0, 0, 0, 255). Applies to render() and render_to().
   bgcolor
 default background color bgcolor -> Color  Gets or sets the default background rendering color. Initially it is unset and text will render with a transparent background by default. Applies to render() and render_to().
  New in pygame 2.0.0.    origin
 Font render to text origin mode origin -> bool  If set True, render_to() and render_raw_to() will take the dest position to be that of the text origin, as opposed to the top-left corner of the bounding box. See get_rect() for details.
   pad
 padded boundary mode pad -> bool  If set True, then the text boundary rectangle will be inflated to match that of font.Font. Otherwise, the boundary rectangle is just large enough for the text.
   ucs4
 Enable UCS-4 mode ucs4 -> bool  Gets or sets the decoding of Unicode text. By default, the freetype module performs UTF-16 surrogate pair decoding on Unicode text. This allows 32-bit escape sequences ('Uxxxxxxxx') between 0x10000 and 0x10FFFF to represent their corresponding UTF-32 code points on Python interpreters built with a UCS-2 Unicode type (on Windows, for instance). It also means character values within the UTF-16 surrogate area (0xD800 to 0xDFFF) are considered part of a surrogate pair. A malformed surrogate pair will raise a UnicodeEncodeError. Setting ucs4 True turns surrogate pair decoding off, allowing access the full UCS-4 character range to a Python interpreter built with four-byte Unicode character support.
   resolution
 Pixel resolution in dots per inch resolution -> int  Read only. Gets pixel size used in scaling font glyphs for this Font instance.


pygame.freetype.Font
 Create a new Font instance from a supported font file. Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font  Argument file can be either a string representing the font's filename, a file-like object containing the font, or None; if None, a default, Pygame, font is used. Optionally, a size argument may be specified to set the default size in points, which determines the size of the rendered characters. The size can also be passed explicitly to each method call. Because of the way the caching system works, specifying a default size on the constructor doesn't imply a performance gain over manually passing the size on each function call. If the font is bitmap and no size is given, the default size is set to the first available size for the font. If the font file has more than one font, the font to load can be chosen with the index argument. An exception is raised for an out-of-range font index value. The optional resolution argument sets the pixel size, in dots per inch, for use in scaling glyphs for this Font instance. If 0 then the default module value, set by init(), is used. The Font object's resolution can only be changed by re-initializing the Font instance. The optional ucs4 argument, an integer, sets the default text translation mode: 0 (False) recognize UTF-16 surrogate pairs, any other value (True), to treat Unicode text as UCS-4, with no surrogate pairs. See Font.ucs4.   name
 Proper font name. name -> string  Read only. Returns the real (long) name of the font, as recorded in the font file.
   path
 Font file path path -> unicode  Read only. Returns the path of the loaded font file
   size
 The default point size used in rendering size -> float size -> (float, float)  Get or set the default size for text metrics and rendering. It can be a single point size, given as a Python int or float, or a font ppem (width, height) tuple. Size values are non-negative. A zero size or width represents an undefined size. In this case the size must be given as a method argument, or an exception is raised. A zero width but non-zero height is a ValueError. For a scalable font, a single number value is equivalent to a tuple with width equal height. A font can be stretched vertically with height set greater than width, or horizontally with width set greater than height. For embedded bitmaps, as listed by get_sizes(), use the nominal width and height to select an available size. Font size differs for a non-scalable, bitmap, font. During a method call it must match one of the available sizes returned by method get_sizes(). If not, an exception is raised. If the size is a single number, the size is first matched against the point size value. If no match, then the available size with the same nominal width and height is chosen.
   get_rect()
 Return the size and offset of rendered text get_rect(text, style=STYLE_DEFAULT, rotation=0, size=0) -> rect  Gets the final dimensions and origin, in pixels, of text using the optional size in points, style, and rotation. For other relevant render properties, and for any optional argument not given, the default values set for the Font instance are used. Returns a Rect instance containing the width and height of the text's bounding box and the position of the text's origin. The origin is useful in aligning separately rendered pieces of text. It gives the baseline position and bearing at the start of the text. See the render_to() method for an example. If text is a char (byte) string, its encoding is assumed to be LATIN1. Optionally, text can be None, which will return the bounding rectangle for the text passed to a previous get_rect(), render(), render_to(), render_raw(), or render_raw_to() call. See render_to() for more details.
   get_metrics()
 Return the glyph metrics for the given text get_metrics(text, size=0) -> [(...), ...]  Returns the glyph metrics for each character in text. The glyph metrics are returned as a list of tuples. Each tuple gives metrics of a single character glyph. The glyph metrics are: (min_x, max_x, min_y, max_y, horizontal_advance_x, horizontal_advance_y) The bounding box min_x, max_x, min_y, and max_y values are returned as grid-fitted pixel coordinates of type int. The advance values are float values. The calculations are done using the font's default size in points. Optionally you may specify another point size with the size argument. The metrics are adjusted for the current rotation, strong, and oblique settings. If text is a char (byte) string, then its encoding is assumed to be LATIN1.
   height
 The unscaled height of the font in font units height -> int  Read only. Gets the height of the font. This is the average value of all glyphs in the font.
   ascender
 The unscaled ascent of the font in font units ascender -> int  Read only. Return the number of units from the font's baseline to the top of the bounding box.
   descender
 The unscaled descent of the font in font units descender -> int  Read only. Return the height in font units for the font descent. The descent is the number of units from the font's baseline to the bottom of the bounding box.
   get_sized_ascender()
 The scaled ascent of the font in pixels get_sized_ascender(<size>=0) -> int  Return the number of units from the font's baseline to the top of the bounding box. It is not adjusted for strong or rotation.
   get_sized_descender()
 The scaled descent of the font in pixels get_sized_descender(<size>=0) -> int  Return the number of pixels from the font's baseline to the top of the bounding box. It is not adjusted for strong or rotation.
   get_sized_height()
 The scaled height of the font in pixels get_sized_height(<size>=0) -> int  Returns the height of the font. This is the average value of all glyphs in the font. It is not adjusted for strong or rotation.
   get_sized_glyph_height()
 The scaled bounding box height of the font in pixels get_sized_glyph_height(<size>=0) -> int  Return the glyph bounding box height of the font in pixels. This is the average value of all glyphs in the font. It is not adjusted for strong or rotation.
   get_sizes()
 return the available sizes of embedded bitmaps get_sizes() -> [(int, int, int, float, float), ...] get_sizes() -> []  Returns a list of tuple records, one for each point size supported. Each tuple containing the point size, the height in pixels, width in pixels, horizontal ppem (nominal width) in fractional pixels, and vertical ppem (nominal height) in fractional pixels.
   render()
 Return rendered text as a surface render(text, fgcolor=None, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> (Surface, Rect)  Returns a new Surface, with the text rendered to it in the color given by 'fgcolor'. If no foreground color is given, the default foreground color, fgcolor is used. If bgcolor is given, the surface will be filled with this color. When no background color is given, the surface background is transparent, zero alpha. Normally the returned surface has a 32 bit pixel size. However, if bgcolor is None and anti-aliasing is disabled a monochrome 8 bit colorkey surface, with colorkey set for the background color, is returned. The return value is a tuple: the new surface and the bounding rectangle giving the size and origin of the rendered text. If an empty string is passed for text then the returned Rect is zero width and the height of the font. Optional fgcolor, style, rotation, and size arguments override the default values set for the Font instance. If text is a char (byte) string, then its encoding is assumed to be LATIN1. Optionally, text can be None, which will render the text passed to a previous get_rect(), render(), render_to(), render_raw(), or render_raw_to() call. See render_to() for details.
   render_to()
 Render text onto an existing surface render_to(surf, dest, text, fgcolor=None, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> Rect  Renders the string text to the pygame.Surface surf, at position dest, a (x, y) surface coordinate pair. If either x or y is not an integer it is converted to one if possible. Any sequence where the first two items are x and y positional elements is accepted, including a Rect instance. As with render(), optional fgcolor, style, rotation, and size argument are available. If a background color bgcolor is given, the text bounding box is first filled with that color. The text is blitted next. Both the background fill and text rendering involve full alpha blits. That is, the alpha values of the foreground, background, and destination target surface all affect the blit. The return value is a rectangle giving the size and position of the rendered text within the surface. If an empty string is passed for text then the returned Rect is zero width and the height of the font. The rect will test False. Optionally, text can be set None, which will re-render text passed to a previous render_to(), get_rect(), render(), render_raw(), or render_raw_to() call. Primarily, this feature is an aid to using render_to() in combination with get_rect(). An example: def word_wrap(surf, text, font, color=(0, 0, 0)):
    font.origin = True
    words = text.split(' ')
    width, height = surf.get_size()
    line_spacing = font.get_sized_height() + 2
    x, y = 0, line_spacing
    space = font.get_rect(' ')
    for word in words:
        bounds = font.get_rect(word)
        if x + bounds.width + bounds.x >= width:
            x, y = 0, y + line_spacing
        if x + bounds.width + bounds.x >= width:
            raise ValueError("word too wide for the surface")
        if y + bounds.height - bounds.y >= height:
            raise ValueError("text to long for the surface")
        font.render_to(surf, (x, y), None, color)
        x += bounds.width + space.width
    return x, y When render_to() is called with the same font properties ― size, style, strength, wide, antialiased, vertical, rotation, kerning, and use_bitmap_strikes ― as get_rect(), render_to() will use the layout calculated by get_rect(). Otherwise, render_to() will recalculate the layout if called with a text string or one of the above properties has changed after the get_rect() call. If text is a char (byte) string, then its encoding is assumed to be LATIN1.
   render_raw()
 Return rendered text as a string of bytes render_raw(text, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (bytes, (int, int))  Like render() but with the pixels returned as a byte string of 8-bit gray-scale values. The foreground color is 255, the background 0, useful as an alpha mask for a foreground pattern.
   render_raw_to()
 Render text into an array of ints render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> Rect  Render to an array object exposing an array struct interface. The array must be two dimensional with integer items. The default dest value, None, is equivalent to position (0, 0). See render_to(). As with the other render methods, text can be None to render a text string passed previously to another method. The return value is a pygame.Rect() giving the size and position of the rendered text.
   style
 The font's style flags style -> int  Gets or sets the default style of the Font. This default style will be used for all text rendering and size calculations unless overridden specifically a render or get_rect() call. The style value may be a bit-wise OR of one or more of the following constants: STYLE_NORMAL
STYLE_UNDERLINE
STYLE_OBLIQUE
STYLE_STRONG
STYLE_WIDE
STYLE_DEFAULT These constants may be found on the FreeType constants module. Optionally, the default style can be modified or obtained accessing the individual style attributes (underline, oblique, strong). The STYLE_OBLIQUE and STYLE_STRONG styles are for scalable fonts only. An attempt to set either for a bitmap font raises an AttributeError. An attempt to set either for an inactive font, as returned by Font.__new__(), raises a RuntimeError. Assigning STYLE_DEFAULT to the style property leaves the property unchanged, as this property defines the default. The style property will never return STYLE_DEFAULT.
   underline
 The state of the font's underline style flag underline -> bool  Gets or sets whether the font will be underlined when drawing text. This default style value will be used for all text rendering and size calculations unless overridden specifically in a render or get_rect() call, via the 'style' parameter.
   strong
 The state of the font's strong style flag strong -> bool  Gets or sets whether the font will be bold when drawing text. This default style value will be used for all text rendering and size calculations unless overridden specifically in a render or get_rect() call, via the 'style' parameter.
   oblique
 The state of the font's oblique style flag oblique -> bool  Gets or sets whether the font will be rendered as oblique. This default style value will be used for all text rendering and size calculations unless overridden specifically in a render or get_rect() call, via the style parameter. The oblique style is only supported for scalable (outline) fonts. An attempt to set this style on a bitmap font will raise an AttributeError. If the font object is inactive, as returned by Font.__new__(), setting this property raises a RuntimeError.
   wide
 The state of the font's wide style flag wide -> bool  Gets or sets whether the font will be stretched horizontally when drawing text. It produces a result similar to pygame.font.Font's bold. This style not available for rotated text.
   strength
 The strength associated with the strong or wide font styles strength -> float  The amount by which a font glyph's size is enlarged for the strong or wide transformations, as a fraction of the untransformed size. For the wide style only the horizontal dimension is increased. For strong text both the horizontal and vertical dimensions are enlarged. A wide style of strength 0.08333 ( 1/12 ) is equivalent to the pygame.font.Font bold style. The default is 0.02778 ( 1/36 ). The strength style is only supported for scalable (outline) fonts. An attempt to set this property on a bitmap font will raise an AttributeError. If the font object is inactive, as returned by Font.__new__(), assignment to this property raises a RuntimeError.
   underline_adjustment
 Adjustment factor for the underline position underline_adjustment -> float  Gets or sets a factor which, when positive, is multiplied with the font's underline offset to adjust the underline position. A negative value turns an underline into a strike-through or overline. It is multiplied with the ascender. Accepted values range between -2.0 and 2.0 inclusive. A value of 0.5 closely matches Tango underlining. A value of 1.0 mimics pygame.font.Font underlining.
   fixed_width
 Gets whether the font is fixed-width fixed_width -> bool  Read only. Returns True if the font contains fixed-width characters (for example Courier, Bitstream Vera Sans Mono, Andale Mono).
   fixed_sizes
 the number of available bitmap sizes for the font fixed_sizes -> int  Read only. Returns the number of point sizes for which the font contains bitmap character images. If zero then the font is not a bitmap font. A scalable font may contain pre-rendered point sizes as strikes.
   scalable
 Gets whether the font is scalable scalable -> bool  Read only. Returns True if the font contains outline glyphs. If so, the point size is not limited to available bitmap sizes.
   use_bitmap_strikes
 allow the use of embedded bitmaps in an outline font file use_bitmap_strikes -> bool  Some scalable fonts include embedded bitmaps for particular point sizes. This property controls whether or not those bitmap strikes are used. Set it False to disable the loading of any bitmap strike. Set it True, the default, to permit bitmap strikes for a non-rotated render with no style other than wide or underline. This property is ignored for bitmap fonts. See also fixed_sizes and get_sizes().
   antialiased
 Font anti-aliasing mode antialiased -> bool  Gets or sets the font's anti-aliasing mode. This defaults to True on all fonts, which are rendered with full 8 bit blending. Set to False to do monochrome rendering. This should provide a small speed gain and reduce cache memory size.
   kerning
 Character kerning mode kerning -> bool  Gets or sets the font's kerning mode. This defaults to False on all fonts, which will be rendered without kerning. Set to True to add kerning between character pairs, if supported by the font, when positioning glyphs.
   vertical
 Font vertical mode vertical -> bool  Gets or sets whether the characters are laid out vertically rather than horizontally. May be useful when rendering Kanji or some other vertical script. Set to True to switch to a vertical text layout. The default is False, place horizontally. Note that the Font class does not automatically determine script orientation. Vertical layout must be selected explicitly. Also note that several font formats (especially bitmap based ones) don't contain the necessary metrics to draw glyphs vertically, so drawing in those cases will give unspecified results.
   rotation
 text rotation in degrees counterclockwise rotation -> int  Gets or sets the baseline angle of the rendered text. The angle is represented as integer degrees. The default angle is 0, with horizontal text rendered along the X-axis, and vertical text along the Y-axis. A positive value rotates these axes counterclockwise that many degrees. A negative angle corresponds to a clockwise rotation. The rotation value is normalized to a value within the range 0 to 359 inclusive (eg. 390 -> 390 - 360 -> 30, -45 -> 360 + -45 -> 315, 720 -> 720 - (2 * 360) -> 0). Only scalable (outline) fonts can be rotated. An attempt to change the rotation of a bitmap font raises an AttributeError. An attempt to change the rotation of an inactive font instance, as returned by Font.__new__(), raises a RuntimeError.
   fgcolor
 default foreground color fgcolor -> Color  Gets or sets the default glyph rendering color. It is initially opaque black ― (0, 0, 0, 255). Applies to render() and render_to().
   bgcolor
 default background color bgcolor -> Color  Gets or sets the default background rendering color. Initially it is unset and text will render with a transparent background by default. Applies to render() and render_to().
  New in pygame 2.0.0.    origin
 Font render to text origin mode origin -> bool  If set True, render_to() and render_raw_to() will take the dest position to be that of the text origin, as opposed to the top-left corner of the bounding box. See get_rect() for details.
   pad
 padded boundary mode pad -> bool  If set True, then the text boundary rectangle will be inflated to match that of font.Font. Otherwise, the boundary rectangle is just large enough for the text.
   ucs4
 Enable UCS-4 mode ucs4 -> bool  Gets or sets the decoding of Unicode text. By default, the freetype module performs UTF-16 surrogate pair decoding on Unicode text. This allows 32-bit escape sequences ('Uxxxxxxxx') between 0x10000 and 0x10FFFF to represent their corresponding UTF-32 code points on Python interpreters built with a UCS-2 Unicode type (on Windows, for instance). It also means character values within the UTF-16 surrogate area (0xD800 to 0xDFFF) are considered part of a surrogate pair. A malformed surrogate pair will raise a UnicodeEncodeError. Setting ucs4 True turns surrogate pair decoding off, allowing access the full UCS-4 character range to a Python interpreter built with four-byte Unicode character support.
   resolution
 Pixel resolution in dots per inch resolution -> int  Read only. Gets pixel size used in scaling font glyphs for this Font instance.


antialiased
 Font anti-aliasing mode antialiased -> bool  Gets or sets the font's anti-aliasing mode. This defaults to True on all fonts, which are rendered with full 8 bit blending. Set to False to do monochrome rendering. This should provide a small speed gain and reduce cache memory size.


ascender
 The unscaled ascent of the font in font units ascender -> int  Read only. Return the number of units from the font's baseline to the top of the bounding box.


bgcolor
 default background color bgcolor -> Color  Gets or sets the default background rendering color. Initially it is unset and text will render with a transparent background by default. Applies to render() and render_to().


descender
 The unscaled descent of the font in font units descender -> int  Read only. Return the height in font units for the font descent. The descent is the number of units from the font's baseline to the bottom of the bounding box.


fgcolor
 default foreground color fgcolor -> Color  Gets or sets the default glyph rendering color. It is initially opaque black ― (0, 0, 0, 255). Applies to render() and render_to().


fixed_sizes
 the number of available bitmap sizes for the font fixed_sizes -> int  Read only. Returns the number of point sizes for which the font contains bitmap character images. If zero then the font is not a bitmap font. A scalable font may contain pre-rendered point sizes as strikes.


fixed_width
 Gets whether the font is fixed-width fixed_width -> bool  Read only. Returns True if the font contains fixed-width characters (for example Courier, Bitstream Vera Sans Mono, Andale Mono).


get_metrics()
 Return the glyph metrics for the given text get_metrics(text, size=0) -> [(...), ...]  Returns the glyph metrics for each character in text. The glyph metrics are returned as a list of tuples. Each tuple gives metrics of a single character glyph. The glyph metrics are: (min_x, max_x, min_y, max_y, horizontal_advance_x, horizontal_advance_y) The bounding box min_x, max_x, min_y, and max_y values are returned as grid-fitted pixel coordinates of type int. The advance values are float values. The calculations are done using the font's default size in points. Optionally you may specify another point size with the size argument. The metrics are adjusted for the current rotation, strong, and oblique settings. If text is a char (byte) string, then its encoding is assumed to be LATIN1.


get_rect()
 Return the size and offset of rendered text get_rect(text, style=STYLE_DEFAULT, rotation=0, size=0) -> rect  Gets the final dimensions and origin, in pixels, of text using the optional size in points, style, and rotation. For other relevant render properties, and for any optional argument not given, the default values set for the Font instance are used. Returns a Rect instance containing the width and height of the text's bounding box and the position of the text's origin. The origin is useful in aligning separately rendered pieces of text. It gives the baseline position and bearing at the start of the text. See the render_to() method for an example. If text is a char (byte) string, its encoding is assumed to be LATIN1. Optionally, text can be None, which will return the bounding rectangle for the text passed to a previous get_rect(), render(), render_to(), render_raw(), or render_raw_to() call. See render_to() for more details.


get_sized_ascender()
 The scaled ascent of the font in pixels get_sized_ascender(<size>=0) -> int  Return the number of units from the font's baseline to the top of the bounding box. It is not adjusted for strong or rotation.


get_sized_descender()
 The scaled descent of the font in pixels get_sized_descender(<size>=0) -> int  Return the number of pixels from the font's baseline to the top of the bounding box. It is not adjusted for strong or rotation.


get_sized_glyph_height()
 The scaled bounding box height of the font in pixels get_sized_glyph_height(<size>=0) -> int  Return the glyph bounding box height of the font in pixels. This is the average value of all glyphs in the font. It is not adjusted for strong or rotation.


get_sized_height()
 The scaled height of the font in pixels get_sized_height(<size>=0) -> int  Returns the height of the font. This is the average value of all glyphs in the font. It is not adjusted for strong or rotation.


get_sizes()
 return the available sizes of embedded bitmaps get_sizes() -> [(int, int, int, float, float), ...] get_sizes() -> []  Returns a list of tuple records, one for each point size supported. Each tuple containing the point size, the height in pixels, width in pixels, horizontal ppem (nominal width) in fractional pixels, and vertical ppem (nominal height) in fractional pixels.


height
 The unscaled height of the font in font units height -> int  Read only. Gets the height of the font. This is the average value of all glyphs in the font.


kerning
 Character kerning mode kerning -> bool  Gets or sets the font's kerning mode. This defaults to False on all fonts, which will be rendered without kerning. Set to True to add kerning between character pairs, if supported by the font, when positioning glyphs.


name
 Proper font name. name -> string  Read only. Returns the real (long) name of the font, as recorded in the font file.


oblique
 The state of the font's oblique style flag oblique -> bool  Gets or sets whether the font will be rendered as oblique. This default style value will be used for all text rendering and size calculations unless overridden specifically in a render or get_rect() call, via the style parameter. The oblique style is only supported for scalable (outline) fonts. An attempt to set this style on a bitmap font will raise an AttributeError. If the font object is inactive, as returned by Font.__new__(), setting this property raises a RuntimeError.


origin
 Font render to text origin mode origin -> bool  If set True, render_to() and render_raw_to() will take the dest position to be that of the text origin, as opposed to the top-left corner of the bounding box. See get_rect() for details.


pad
 padded boundary mode pad -> bool  If set True, then the text boundary rectangle will be inflated to match that of font.Font. Otherwise, the boundary rectangle is just large enough for the text.


path
 Font file path path -> unicode  Read only. Returns the path of the loaded font file


render()
 Return rendered text as a surface render(text, fgcolor=None, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> (Surface, Rect)  Returns a new Surface, with the text rendered to it in the color given by 'fgcolor'. If no foreground color is given, the default foreground color, fgcolor is used. If bgcolor is given, the surface will be filled with this color. When no background color is given, the surface background is transparent, zero alpha. Normally the returned surface has a 32 bit pixel size. However, if bgcolor is None and anti-aliasing is disabled a monochrome 8 bit colorkey surface, with colorkey set for the background color, is returned. The return value is a tuple: the new surface and the bounding rectangle giving the size and origin of the rendered text. If an empty string is passed for text then the returned Rect is zero width and the height of the font. Optional fgcolor, style, rotation, and size arguments override the default values set for the Font instance. If text is a char (byte) string, then its encoding is assumed to be LATIN1. Optionally, text can be None, which will render the text passed to a previous get_rect(), render(), render_to(), render_raw(), or render_raw_to() call. See render_to() for details.


render_raw()
 Return rendered text as a string of bytes render_raw(text, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> (bytes, (int, int))  Like render() but with the pixels returned as a byte string of 8-bit gray-scale values. The foreground color is 255, the background 0, useful as an alpha mask for a foreground pattern.


render_raw_to()
 Render text into an array of ints render_raw_to(array, text, dest=None, style=STYLE_DEFAULT, rotation=0, size=0, invert=False) -> Rect  Render to an array object exposing an array struct interface. The array must be two dimensional with integer items. The default dest value, None, is equivalent to position (0, 0). See render_to(). As with the other render methods, text can be None to render a text string passed previously to another method. The return value is a pygame.Rect() giving the size and position of the rendered text.


render_to()
 Render text onto an existing surface render_to(surf, dest, text, fgcolor=None, bgcolor=None, style=STYLE_DEFAULT, rotation=0, size=0) -> Rect  Renders the string text to the pygame.Surface surf, at position dest, a (x, y) surface coordinate pair. If either x or y is not an integer it is converted to one if possible. Any sequence where the first two items are x and y positional elements is accepted, including a Rect instance. As with render(), optional fgcolor, style, rotation, and size argument are available. If a background color bgcolor is given, the text bounding box is first filled with that color. The text is blitted next. Both the background fill and text rendering involve full alpha blits. That is, the alpha values of the foreground, background, and destination target surface all affect the blit. The return value is a rectangle giving the size and position of the rendered text within the surface. If an empty string is passed for text then the returned Rect is zero width and the height of the font. The rect will test False. Optionally, text can be set None, which will re-render text passed to a previous render_to(), get_rect(), render(), render_raw(), or render_raw_to() call. Primarily, this feature is an aid to using render_to() in combination with get_rect(). An example: def word_wrap(surf, text, font, color=(0, 0, 0)):
    font.origin = True
    words = text.split(' ')
    width, height = surf.get_size()
    line_spacing = font.get_sized_height() + 2
    x, y = 0, line_spacing
    space = font.get_rect(' ')
    for word in words:
        bounds = font.get_rect(word)
        if x + bounds.width + bounds.x >= width:
            x, y = 0, y + line_spacing
        if x + bounds.width + bounds.x >= width:
            raise ValueError("word too wide for the surface")
        if y + bounds.height - bounds.y >= height:
            raise ValueError("text to long for the surface")
        font.render_to(surf, (x, y), None, color)
        x += bounds.width + space.width
    return x, y When render_to() is called with the same font properties ― size, style, strength, wide, antialiased, vertical, rotation, kerning, and use_bitmap_strikes ― as get_rect(), render_to() will use the layout calculated by get_rect(). Otherwise, render_to() will recalculate the layout if called with a text string or one of the above properties has changed after the get_rect() call. If text is a char (byte) string, then its encoding is assumed to be LATIN1.


resolution
 Pixel resolution in dots per inch resolution -> int  Read only. Gets pixel size used in scaling font glyphs for this Font instance.


rotation
 text rotation in degrees counterclockwise rotation -> int  Gets or sets the baseline angle of the rendered text. The angle is represented as integer degrees. The default angle is 0, with horizontal text rendered along the X-axis, and vertical text along the Y-axis. A positive value rotates these axes counterclockwise that many degrees. A negative angle corresponds to a clockwise rotation. The rotation value is normalized to a value within the range 0 to 359 inclusive (eg. 390 -> 390 - 360 -> 30, -45 -> 360 + -45 -> 315, 720 -> 720 - (2 * 360) -> 0). Only scalable (outline) fonts can be rotated. An attempt to change the rotation of a bitmap font raises an AttributeError. An attempt to change the rotation of an inactive font instance, as returned by Font.__new__(), raises a RuntimeError.


scalable
 Gets whether the font is scalable scalable -> bool  Read only. Returns True if the font contains outline glyphs. If so, the point size is not limited to available bitmap sizes.


size
 The default point size used in rendering size -> float size -> (float, float)  Get or set the default size for text metrics and rendering. It can be a single point size, given as a Python int or float, or a font ppem (width, height) tuple. Size values are non-negative. A zero size or width represents an undefined size. In this case the size must be given as a method argument, or an exception is raised. A zero width but non-zero height is a ValueError. For a scalable font, a single number value is equivalent to a tuple with width equal height. A font can be stretched vertically with height set greater than width, or horizontally with width set greater than height. For embedded bitmaps, as listed by get_sizes(), use the nominal width and height to select an available size. Font size differs for a non-scalable, bitmap, font. During a method call it must match one of the available sizes returned by method get_sizes(). If not, an exception is raised. If the size is a single number, the size is first matched against the point size value. If no match, then the available size with the same nominal width and height is chosen.


strength
 The strength associated with the strong or wide font styles strength -> float  The amount by which a font glyph's size is enlarged for the strong or wide transformations, as a fraction of the untransformed size. For the wide style only the horizontal dimension is increased. For strong text both the horizontal and vertical dimensions are enlarged. A wide style of strength 0.08333 ( 1/12 ) is equivalent to the pygame.font.Font bold style. The default is 0.02778 ( 1/36 ). The strength style is only supported for scalable (outline) fonts. An attempt to set this property on a bitmap font will raise an AttributeError. If the font object is inactive, as returned by Font.__new__(), assignment to this property raises a RuntimeError.


strong
 The state of the font's strong style flag strong -> bool  Gets or sets whether the font will be bold when drawing text. This default style value will be used for all text rendering and size calculations unless overridden specifically in a render or get_rect() call, via the 'style' parameter.


style
 The font's style flags style -> int  Gets or sets the default style of the Font. This default style will be used for all text rendering and size calculations unless overridden specifically a render or get_rect() call. The style value may be a bit-wise OR of one or more of the following constants: STYLE_NORMAL
STYLE_UNDERLINE
STYLE_OBLIQUE
STYLE_STRONG
STYLE_WIDE
STYLE_DEFAULT These constants may be found on the FreeType constants module. Optionally, the default style can be modified or obtained accessing the individual style attributes (underline, oblique, strong). The STYLE_OBLIQUE and STYLE_STRONG styles are for scalable fonts only. An attempt to set either for a bitmap font raises an AttributeError. An attempt to set either for an inactive font, as returned by Font.__new__(), raises a RuntimeError. Assigning STYLE_DEFAULT to the style property leaves the property unchanged, as this property defines the default. The style property will never return STYLE_DEFAULT.


ucs4
 Enable UCS-4 mode ucs4 -> bool  Gets or sets the decoding of Unicode text. By default, the freetype module performs UTF-16 surrogate pair decoding on Unicode text. This allows 32-bit escape sequences ('Uxxxxxxxx') between 0x10000 and 0x10FFFF to represent their corresponding UTF-32 code points on Python interpreters built with a UCS-2 Unicode type (on Windows, for instance). It also means character values within the UTF-16 surrogate area (0xD800 to 0xDFFF) are considered part of a surrogate pair. A malformed surrogate pair will raise a UnicodeEncodeError. Setting ucs4 True turns surrogate pair decoding off, allowing access the full UCS-4 character range to a Python interpreter built with four-byte Unicode character support.


underline
 The state of the font's underline style flag underline -> bool  Gets or sets whether the font will be underlined when drawing text. This default style value will be used for all text rendering and size calculations unless overridden specifically in a render or get_rect() call, via the 'style' parameter.


underline_adjustment
 Adjustment factor for the underline position underline_adjustment -> float  Gets or sets a factor which, when positive, is multiplied with the font's underline offset to adjust the underline position. A negative value turns an underline into a strike-through or overline. It is multiplied with the ascender. Accepted values range between -2.0 and 2.0 inclusive. A value of 0.5 closely matches Tango underlining. A value of 1.0 mimics pygame.font.Font underlining.


use_bitmap_strikes
 allow the use of embedded bitmaps in an outline font file use_bitmap_strikes -> bool  Some scalable fonts include embedded bitmaps for particular point sizes. This property controls whether or not those bitmap strikes are used. Set it False to disable the loading of any bitmap strike. Set it True, the default, to permit bitmap strikes for a non-rotated render with no style other than wide or underline. This property is ignored for bitmap fonts. See also fixed_sizes and get_sizes().


vertical
 Font vertical mode vertical -> bool  Gets or sets whether the characters are laid out vertically rather than horizontally. May be useful when rendering Kanji or some other vertical script. Set to True to switch to a vertical text layout. The default is False, place horizontally. Note that the Font class does not automatically determine script orientation. Vertical layout must be selected explicitly. Also note that several font formats (especially bitmap based ones) don't contain the necessary metrics to draw glyphs vertically, so drawing in those cases will give unspecified results.


wide
 The state of the font's wide style flag wide -> bool  Gets or sets whether the font will be stretched horizontally when drawing text. It produces a result similar to pygame.font.Font's bold. This style not available for rotated text.


pygame.freetype.get_cache_size()
 Return the glyph case size get_cache_size() -> long  See pygame.freetype.init().


pygame.freetype.get_default_font()
 Get the filename of the default font get_default_font() -> string  Return the filename of the default pygame font. This is not the full path to the file. The file is usually in the same directory as the font module, but can also be bundled in a separate archive.


pygame.freetype.get_default_resolution()
 Return the default pixel size in dots per inch get_default_resolution() -> long  Returns the default pixel size, in dots per inch, for the module. The default is 72 DPI.


pygame.freetype.get_error()
 Return the latest FreeType error get_error() -> str get_error() -> None  Return a description of the last error which occurred in the FreeType2 library, or None if no errors have occurred.


pygame.freetype.get_init()
 Returns True if the FreeType module is currently initialized. get_init() -> bool  Returns True if the pygame.freetype module is currently initialized.  New in pygame 1.9.5.


pygame.freetype.get_version()
 Return the FreeType version get_version() -> (int, int, int)  Returns the version of the FreeType library in use by this module. Note that the freetype module depends on the FreeType 2 library. It will not compile with the original FreeType 1.0. Hence, the first element of the tuple will always be "2".


pygame.freetype.init()
 Initialize the underlying FreeType library. init(cache_size=64, resolution=72)  This function initializes the underlying FreeType library and must be called before trying to use any of the functionality of the freetype module. However, pygame.init() will automatically call this function if the freetype module is already imported. It is safe to call this function more than once. Optionally, you may specify a default cache_size for the Glyph cache: the maximum number of glyphs that will be cached at any given time by the module. Exceedingly small values will be automatically tuned for performance. Also a default pixel resolution, in dots per inch, can be given to adjust font scaling.


pygame.freetype.quit()
 Shut down the underlying FreeType library. quit()  This function closes the freetype module. After calling this function, you should not invoke any class, method or function related to the freetype module as they are likely to fail or might give unpredictable results. It is safe to call this function even if the module hasn't been initialized yet.


pygame.freetype.set_default_resolution()
 Set the default pixel size in dots per inch for the module set_default_resolution([resolution])  Set the default pixel size, in dots per inch, for the module. If the optional argument is omitted or zero the resolution is reset to 72 DPI.


pygame.freetype.SysFont()
 create a Font object from the system fonts SysFont(name, size, bold=False, italic=False) -> Font  Return a new Font object that is loaded from the system fonts. The font will match the requested bold and italic flags. Pygame uses a small set of common font aliases. If the specific font you ask for is not available, a reasonable alternative may be used. If a suitable system font is not found this will fall back on loading the default pygame font. The font name can also be an iterable of font names, a string of comma-separated font names, or a bytes of comma-separated font names, in which case the set of names will be searched in order.  New in pygame 2.0.1: Accept an iterable of font names.


pygame.freetype.was_init()
 DEPRECATED: Use get_init() instead. was_init() -> bool  DEPRECATED: Returns True if the pygame.freetype module is currently initialized. Use get_init() instead.


pygame.get_error()
 get the current error message get_error() -> errorstr  SDL maintains an internal error message. This message will usually be given to you when pygame.error() is raised, so this function will rarely be needed.


pygame.get_init()
 returns True if pygame is currently initialized get_init() -> bool  Returns True if pygame is currently initialized.  New in pygame 1.9.5.


pygame.get_sdl_byteorder()
 get the byte order of SDL get_sdl_byteorder() -> int  Returns the byte order of the SDL library. It returns 1234 for little endian byte order and 4321 for big endian byte order.  New in pygame 1.8.


pygame.get_sdl_version()
 get the version number of SDL get_sdl_version() -> major, minor, patch  Returns the three version numbers of the SDL library. This version is built at compile time. It can be used to detect which features may or may not be available through pygame.  New in pygame 1.7.0.


pygame.gfxdraw

 pygame module for drawing shapes  EXPERIMENTAL!: This API may change or disappear in later pygame releases. If you use this, your code may break with the next pygame release. The pygame package does not import gfxdraw automatically when loaded, so it must imported explicitly to be used. import pygame
import pygame.gfxdraw For all functions the arguments are strictly positional and integers are accepted for coordinates and radii. The color argument can be one of the following formats:
 a pygame.Color object an (RGB) triplet (tuple/list) an (RGBA) quadruplet (tuple/list)
 The functions rectangle() and box() will accept any (x, y, w, h) sequence for their rect argument, though pygame.Rect instances are preferred. To draw a filled antialiased shape, first use the antialiased (aa*) version of the function, and then use the filled (filled_*) version. For example: col = (255, 0, 0)
surf.fill((255, 255, 255))
pygame.gfxdraw.aacircle(surf, x, y, 30, col)
pygame.gfxdraw.filled_circle(surf, x, y, 30, col)  Note For threading, each of the functions releases the GIL during the C part of the call.   Note See the pygame.draw module for alternative draw methods. The pygame.gfxdraw module differs from the pygame.draw module in the API it uses and the different draw functions available. pygame.gfxdraw wraps the primitives from the library called SDL_gfx, rather than using modified versions.   New in pygame 1.9.0.    pygame.gfxdraw.pixel()
 draw a pixel pixel(surface, x, y, color) -> None  Draws a single pixel, at position (x ,y), on the given surface.
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the pixel
y (int) -- y coordinate of the pixel
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.hline()
 draw a horizontal line hline(surface, x1, x2, y, color) -> None  Draws a straight horizontal line ((x1, y) to (x2, y)) on the given surface. There are no endcaps.
Parameters:

surface (Surface) -- surface to draw on
x1 (int) -- x coordinate of one end of the line
x2 (int) -- x coordinate of the other end of the line
y (int) -- y coordinate of the line
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.vline()
 draw a vertical line vline(surface, x, y1, y2, color) -> None  Draws a straight vertical line ((x, y1) to (x, y2)) on the given surface. There are no endcaps.
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the line
y1 (int) -- y coordinate of one end of the line
y2 (int) -- y coordinate of the other end of the line
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.line()
 draw a line line(surface, x1, y1, x2, y2, color) -> None  Draws a straight line ((x1, y1) to (x2, y2)) on the given surface. There are no endcaps.
Parameters:

surface (Surface) -- surface to draw on
x1 (int) -- x coordinate of one end of the line
y1 (int) -- y coordinate of one end of the line
x2 (int) -- x coordinate of the other end of the line
y2 (int) -- y coordinate of the other end of the line
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.rectangle()
 draw a rectangle rectangle(surface, rect, color) -> None  Draws an unfilled rectangle on the given surface. For a filled rectangle use box().
Parameters:

surface (Surface) -- surface to draw on
rect (Rect) -- rectangle to draw, position and dimensions
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType      Note The rect.bottom and rect.right attributes of a pygame.Rect always lie one pixel outside of its actual border. Therefore, these values will not be included as part of the drawing.
   pygame.gfxdraw.box()
 draw a filled rectangle box(surface, rect, color) -> None  Draws a filled rectangle on the given surface. For an unfilled rectangle use rectangle().
Parameters:

surface (Surface) -- surface to draw on
rect (Rect) -- rectangle to draw, position and dimensions
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType      Note The rect.bottom and rect.right attributes of a pygame.Rect always lie one pixel outside of its actual border. Therefore, these values will not be included as part of the drawing.   Note The pygame.Surface.fill() method works just as well for drawing filled rectangles. In fact pygame.Surface.fill() can be hardware accelerated on some platforms with both software and hardware display modes.
   pygame.gfxdraw.circle()
 draw a circle circle(surface, x, y, r, color) -> None  Draws an unfilled circle on the given surface. For a filled circle use filled_circle().
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the circle
y (int) -- y coordinate of the center of the circle
r (int) -- radius of the circle
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.aacircle()
 draw an antialiased circle aacircle(surface, x, y, r, color) -> None  Draws an unfilled antialiased circle on the given surface.
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the circle
y (int) -- y coordinate of the center of the circle
r (int) -- radius of the circle
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.filled_circle()
 draw a filled circle filled_circle(surface, x, y, r, color) -> None  Draws a filled circle on the given surface. For an unfilled circle use circle().
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the circle
y (int) -- y coordinate of the center of the circle
r (int) -- radius of the circle
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.ellipse()
 draw an ellipse ellipse(surface, x, y, rx, ry, color) -> None  Draws an unfilled ellipse on the given surface. For a filled ellipse use filled_ellipse().
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the ellipse
y (int) -- y coordinate of the center of the ellipse
rx (int) -- horizontal radius of the ellipse
ry (int) -- vertical radius of the ellipse
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.aaellipse()
 draw an antialiased ellipse aaellipse(surface, x, y, rx, ry, color) -> None  Draws an unfilled antialiased ellipse on the given surface.
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the ellipse
y (int) -- y coordinate of the center of the ellipse
rx (int) -- horizontal radius of the ellipse
ry (int) -- vertical radius of the ellipse
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.filled_ellipse()
 draw a filled ellipse filled_ellipse(surface, x, y, rx, ry, color) -> None  Draws a filled ellipse on the given surface. For an unfilled ellipse use ellipse().
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the ellipse
y (int) -- y coordinate of the center of the ellipse
rx (int) -- horizontal radius of the ellipse
ry (int) -- vertical radius of the ellipse
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.arc()
 draw an arc arc(surface, x, y, r, start_angle, stop_angle, color) -> None  Draws an arc on the given surface. For an arc with its endpoints connected to its center use pie(). The two angle arguments are given in degrees and indicate the start and stop positions of the arc. The arc is drawn in a clockwise direction from the start_angle to the stop_angle. If start_angle == stop_angle, nothing will be drawn
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the arc
y (int) -- y coordinate of the center of the arc
r (int) -- radius of the arc
start_angle (int) -- start angle in degrees
stop_angle (int) -- stop angle in degrees
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType      Note This function uses degrees while the pygame.draw.arc() function uses radians.
   pygame.gfxdraw.pie()
 draw a pie pie(surface, x, y, r, start_angle, stop_angle, color) -> None  Draws an unfilled pie on the given surface. A pie is an arc() with its endpoints connected to its center. The two angle arguments are given in degrees and indicate the start and stop positions of the pie. The pie is drawn in a clockwise direction from the start_angle to the stop_angle. If start_angle == stop_angle, a straight line will be drawn from the center position at the given angle, to a length of the radius.
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the pie
y (int) -- y coordinate of the center of the pie
r (int) -- radius of the pie
start_angle (int) -- start angle in degrees
stop_angle (int) -- stop angle in degrees
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.trigon()
 draw a trigon/triangle trigon(surface, x1, y1, x2, y2, x3, y3, color) -> None  Draws an unfilled trigon (triangle) on the given surface. For a filled trigon use filled_trigon(). A trigon can also be drawn using polygon() e.g. polygon(surface, ((x1, y1), (x2, y2), (x3, y3)), color)
Parameters:

surface (Surface) -- surface to draw on
x1 (int) -- x coordinate of the first corner of the trigon
y1 (int) -- y coordinate of the first corner of the trigon
x2 (int) -- x coordinate of the second corner of the trigon
y2 (int) -- y coordinate of the second corner of the trigon
x3 (int) -- x coordinate of the third corner of the trigon
y3 (int) -- y coordinate of the third corner of the trigon
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.aatrigon()
 draw an antialiased trigon/triangle aatrigon(surface, x1, y1, x2, y2, x3, y3, color) -> None  Draws an unfilled antialiased trigon (triangle) on the given surface. An aatrigon can also be drawn using aapolygon() e.g. aapolygon(surface, ((x1, y1), (x2, y2), (x3, y3)), color)
Parameters:

surface (Surface) -- surface to draw on
x1 (int) -- x coordinate of the first corner of the trigon
y1 (int) -- y coordinate of the first corner of the trigon
x2 (int) -- x coordinate of the second corner of the trigon
y2 (int) -- y coordinate of the second corner of the trigon
x3 (int) -- x coordinate of the third corner of the trigon
y3 (int) -- y coordinate of the third corner of the trigon
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.filled_trigon()
 draw a filled trigon/triangle filled_trigon(surface, x1, y1, x2, y2, x3, y3, color) -> None  Draws a filled trigon (triangle) on the given surface. For an unfilled trigon use trigon(). A filled_trigon can also be drawn using filled_polygon() e.g. filled_polygon(surface, ((x1, y1), (x2, y2), (x3, y3)), color)
Parameters:

surface (Surface) -- surface to draw on
x1 (int) -- x coordinate of the first corner of the trigon
y1 (int) -- y coordinate of the first corner of the trigon
x2 (int) -- x coordinate of the second corner of the trigon
y2 (int) -- y coordinate of the second corner of the trigon
x3 (int) -- x coordinate of the third corner of the trigon
y3 (int) -- y coordinate of the third corner of the trigon
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
   pygame.gfxdraw.polygon()
 draw a polygon polygon(surface, points, color) -> None  Draws an unfilled polygon on the given surface. For a filled polygon use filled_polygon(). The adjacent coordinates in the points argument, as well as the first and last points, will be connected by line segments. e.g. For the points [(x1, y1), (x2, y2), (x3, y3)] a line segment will be drawn from (x1, y1) to (x2, y2), from (x2, y2) to (x3, y3), and from (x3, y3) to (x1, y1).
Parameters:

surface (Surface) -- surface to draw on
points (tuple(coordinate) or list(coordinate)) -- a sequence of 3 or more (x, y) coordinates, where each coordinate in the sequence must be a tuple/list/pygame.math.Vector2 of 2 ints/floats (float values will be truncated)
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
Raises:

ValueError -- if len(points) < 3 (must have at least 3 points)
IndexError -- if len(coordinate) < 2 (each coordinate must have at least 2 items)
   pygame.gfxdraw.aapolygon()
 draw an antialiased polygon aapolygon(surface, points, color) -> None  Draws an unfilled antialiased polygon on the given surface. The adjacent coordinates in the points argument, as well as the first and last points, will be connected by line segments. e.g. For the points [(x1, y1), (x2, y2), (x3, y3)] a line segment will be drawn from (x1, y1) to (x2, y2), from (x2, y2) to (x3, y3), and from (x3, y3) to (x1, y1).
Parameters:

surface (Surface) -- surface to draw on
points (tuple(coordinate) or list(coordinate)) -- a sequence of 3 or more (x, y) coordinates, where each coordinate in the sequence must be a tuple/list/pygame.math.Vector2 of 2 ints/floats (float values will be truncated)
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
Raises:

ValueError -- if len(points) < 3 (must have at least 3 points)
IndexError -- if len(coordinate) < 2 (each coordinate must have at least 2 items)
   pygame.gfxdraw.filled_polygon()
 draw a filled polygon filled_polygon(surface, points, color) -> None  Draws a filled polygon on the given surface. For an unfilled polygon use polygon(). The adjacent coordinates in the points argument, as well as the first and last points, will be connected by line segments. e.g. For the points [(x1, y1), (x2, y2), (x3, y3)] a line segment will be drawn from (x1, y1) to (x2, y2), from (x2, y2) to (x3, y3), and from (x3, y3) to (x1, y1).
Parameters:

surface (Surface) -- surface to draw on
points (tuple(coordinate) or list(coordinate)) -- a sequence of 3 or more (x, y) coordinates, where each coordinate in the sequence must be a tuple/list/pygame.math.Vector2 of 2 ints/floats (float values will be truncated)`
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
Raises:

ValueError -- if len(points) < 3 (must have at least 3 points)
IndexError -- if len(coordinate) < 2 (each coordinate must have at least 2 items)
   pygame.gfxdraw.textured_polygon()
 draw a textured polygon textured_polygon(surface, points, texture, tx, ty) -> None  Draws a textured polygon on the given surface. For better performance, the surface and the texture should have the same format. A per-pixel alpha texture blit to a per-pixel alpha surface will differ from a pygame.Surface.blit() blit. Also, a per-pixel alpha texture cannot be used with an 8-bit per pixel destination. The adjacent coordinates in the points argument, as well as the first and last points, will be connected by line segments. e.g. For the points [(x1, y1), (x2, y2), (x3, y3)] a line segment will be drawn from (x1, y1) to (x2, y2), from (x2, y2) to (x3, y3), and from (x3, y3) to (x1, y1).
Parameters:

surface (Surface) -- surface to draw on
points (tuple(coordinate) or list(coordinate)) -- a sequence of 3 or more (x, y) coordinates, where each coordinate in the sequence must be a tuple/list/pygame.math.Vector2 of 2 ints/floats (float values will be truncated)
texture (Surface) -- texture to draw on the polygon
tx (int) -- x offset of the texture
ty (int) -- y offset of the texture
Returns:

None
Return type:

NoneType
Raises:

ValueError -- if len(points) < 3 (must have at least 3 points)
IndexError -- if len(coordinate) < 2 (each coordinate must have at least 2 items)
   pygame.gfxdraw.bezier()
 draw a Bezier curve bezier(surface, points, steps, color) -> None  Draws a Bézier curve on the given surface.
Parameters:

surface (Surface) -- surface to draw on
points (tuple(coordinate) or list(coordinate)) -- a sequence of 3 or more (x, y) coordinates used to form a curve, where each coordinate in the sequence must be a tuple/list/pygame.math.Vector2 of 2 ints/floats (float values will be truncated)
steps (int) -- number of steps for the interpolation, the minimum is 2
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
Raises:

ValueError -- if steps < 2

ValueError -- if len(points) < 3 (must have at least 3 points)
IndexError -- if len(coordinate) < 2 (each coordinate must have at least 2 items)


pygame.gfxdraw.aacircle()
 draw an antialiased circle aacircle(surface, x, y, r, color) -> None  Draws an unfilled antialiased circle on the given surface.
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the circle
y (int) -- y coordinate of the center of the circle
r (int) -- radius of the circle
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.aaellipse()
 draw an antialiased ellipse aaellipse(surface, x, y, rx, ry, color) -> None  Draws an unfilled antialiased ellipse on the given surface.
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the ellipse
y (int) -- y coordinate of the center of the ellipse
rx (int) -- horizontal radius of the ellipse
ry (int) -- vertical radius of the ellipse
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.aapolygon()
 draw an antialiased polygon aapolygon(surface, points, color) -> None  Draws an unfilled antialiased polygon on the given surface. The adjacent coordinates in the points argument, as well as the first and last points, will be connected by line segments. e.g. For the points [(x1, y1), (x2, y2), (x3, y3)] a line segment will be drawn from (x1, y1) to (x2, y2), from (x2, y2) to (x3, y3), and from (x3, y3) to (x1, y1).
Parameters:

surface (Surface) -- surface to draw on
points (tuple(coordinate) or list(coordinate)) -- a sequence of 3 or more (x, y) coordinates, where each coordinate in the sequence must be a tuple/list/pygame.math.Vector2 of 2 ints/floats (float values will be truncated)
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
Raises:

ValueError -- if len(points) < 3 (must have at least 3 points)
IndexError -- if len(coordinate) < 2 (each coordinate must have at least 2 items)


pygame.gfxdraw.aatrigon()
 draw an antialiased trigon/triangle aatrigon(surface, x1, y1, x2, y2, x3, y3, color) -> None  Draws an unfilled antialiased trigon (triangle) on the given surface. An aatrigon can also be drawn using aapolygon() e.g. aapolygon(surface, ((x1, y1), (x2, y2), (x3, y3)), color)
Parameters:

surface (Surface) -- surface to draw on
x1 (int) -- x coordinate of the first corner of the trigon
y1 (int) -- y coordinate of the first corner of the trigon
x2 (int) -- x coordinate of the second corner of the trigon
y2 (int) -- y coordinate of the second corner of the trigon
x3 (int) -- x coordinate of the third corner of the trigon
y3 (int) -- y coordinate of the third corner of the trigon
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.arc()
 draw an arc arc(surface, x, y, r, start_angle, stop_angle, color) -> None  Draws an arc on the given surface. For an arc with its endpoints connected to its center use pie(). The two angle arguments are given in degrees and indicate the start and stop positions of the arc. The arc is drawn in a clockwise direction from the start_angle to the stop_angle. If start_angle == stop_angle, nothing will be drawn
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the arc
y (int) -- y coordinate of the center of the arc
r (int) -- radius of the arc
start_angle (int) -- start angle in degrees
stop_angle (int) -- stop angle in degrees
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType      Note This function uses degrees while the pygame.draw.arc() function uses radians.


pygame.gfxdraw.bezier()
 draw a Bezier curve bezier(surface, points, steps, color) -> None  Draws a Bézier curve on the given surface.
Parameters:

surface (Surface) -- surface to draw on
points (tuple(coordinate) or list(coordinate)) -- a sequence of 3 or more (x, y) coordinates used to form a curve, where each coordinate in the sequence must be a tuple/list/pygame.math.Vector2 of 2 ints/floats (float values will be truncated)
steps (int) -- number of steps for the interpolation, the minimum is 2
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
Raises:

ValueError -- if steps < 2

ValueError -- if len(points) < 3 (must have at least 3 points)
IndexError -- if len(coordinate) < 2 (each coordinate must have at least 2 items)


pygame.gfxdraw.box()
 draw a filled rectangle box(surface, rect, color) -> None  Draws a filled rectangle on the given surface. For an unfilled rectangle use rectangle().
Parameters:

surface (Surface) -- surface to draw on
rect (Rect) -- rectangle to draw, position and dimensions
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType      Note The rect.bottom and rect.right attributes of a pygame.Rect always lie one pixel outside of its actual border. Therefore, these values will not be included as part of the drawing.   Note The pygame.Surface.fill() method works just as well for drawing filled rectangles. In fact pygame.Surface.fill() can be hardware accelerated on some platforms with both software and hardware display modes.


pygame.gfxdraw.circle()
 draw a circle circle(surface, x, y, r, color) -> None  Draws an unfilled circle on the given surface. For a filled circle use filled_circle().
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the circle
y (int) -- y coordinate of the center of the circle
r (int) -- radius of the circle
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.ellipse()
 draw an ellipse ellipse(surface, x, y, rx, ry, color) -> None  Draws an unfilled ellipse on the given surface. For a filled ellipse use filled_ellipse().
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the ellipse
y (int) -- y coordinate of the center of the ellipse
rx (int) -- horizontal radius of the ellipse
ry (int) -- vertical radius of the ellipse
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.filled_circle()
 draw a filled circle filled_circle(surface, x, y, r, color) -> None  Draws a filled circle on the given surface. For an unfilled circle use circle().
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the circle
y (int) -- y coordinate of the center of the circle
r (int) -- radius of the circle
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.filled_ellipse()
 draw a filled ellipse filled_ellipse(surface, x, y, rx, ry, color) -> None  Draws a filled ellipse on the given surface. For an unfilled ellipse use ellipse().
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the ellipse
y (int) -- y coordinate of the center of the ellipse
rx (int) -- horizontal radius of the ellipse
ry (int) -- vertical radius of the ellipse
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.filled_polygon()
 draw a filled polygon filled_polygon(surface, points, color) -> None  Draws a filled polygon on the given surface. For an unfilled polygon use polygon(). The adjacent coordinates in the points argument, as well as the first and last points, will be connected by line segments. e.g. For the points [(x1, y1), (x2, y2), (x3, y3)] a line segment will be drawn from (x1, y1) to (x2, y2), from (x2, y2) to (x3, y3), and from (x3, y3) to (x1, y1).
Parameters:

surface (Surface) -- surface to draw on
points (tuple(coordinate) or list(coordinate)) -- a sequence of 3 or more (x, y) coordinates, where each coordinate in the sequence must be a tuple/list/pygame.math.Vector2 of 2 ints/floats (float values will be truncated)`
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
Raises:

ValueError -- if len(points) < 3 (must have at least 3 points)
IndexError -- if len(coordinate) < 2 (each coordinate must have at least 2 items)


pygame.gfxdraw.filled_trigon()
 draw a filled trigon/triangle filled_trigon(surface, x1, y1, x2, y2, x3, y3, color) -> None  Draws a filled trigon (triangle) on the given surface. For an unfilled trigon use trigon(). A filled_trigon can also be drawn using filled_polygon() e.g. filled_polygon(surface, ((x1, y1), (x2, y2), (x3, y3)), color)
Parameters:

surface (Surface) -- surface to draw on
x1 (int) -- x coordinate of the first corner of the trigon
y1 (int) -- y coordinate of the first corner of the trigon
x2 (int) -- x coordinate of the second corner of the trigon
y2 (int) -- y coordinate of the second corner of the trigon
x3 (int) -- x coordinate of the third corner of the trigon
y3 (int) -- y coordinate of the third corner of the trigon
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.hline()
 draw a horizontal line hline(surface, x1, x2, y, color) -> None  Draws a straight horizontal line ((x1, y) to (x2, y)) on the given surface. There are no endcaps.
Parameters:

surface (Surface) -- surface to draw on
x1 (int) -- x coordinate of one end of the line
x2 (int) -- x coordinate of the other end of the line
y (int) -- y coordinate of the line
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.line()
 draw a line line(surface, x1, y1, x2, y2, color) -> None  Draws a straight line ((x1, y1) to (x2, y2)) on the given surface. There are no endcaps.
Parameters:

surface (Surface) -- surface to draw on
x1 (int) -- x coordinate of one end of the line
y1 (int) -- y coordinate of one end of the line
x2 (int) -- x coordinate of the other end of the line
y2 (int) -- y coordinate of the other end of the line
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.pie()
 draw a pie pie(surface, x, y, r, start_angle, stop_angle, color) -> None  Draws an unfilled pie on the given surface. A pie is an arc() with its endpoints connected to its center. The two angle arguments are given in degrees and indicate the start and stop positions of the pie. The pie is drawn in a clockwise direction from the start_angle to the stop_angle. If start_angle == stop_angle, a straight line will be drawn from the center position at the given angle, to a length of the radius.
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the center of the pie
y (int) -- y coordinate of the center of the pie
r (int) -- radius of the pie
start_angle (int) -- start angle in degrees
stop_angle (int) -- stop angle in degrees
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.pixel()
 draw a pixel pixel(surface, x, y, color) -> None  Draws a single pixel, at position (x ,y), on the given surface.
Parameters:

surface (Surface) -- surface to draw on
x (int) -- x coordinate of the pixel
y (int) -- y coordinate of the pixel
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType


pygame.gfxdraw.polygon()
 draw a polygon polygon(surface, points, color) -> None  Draws an unfilled polygon on the given surface. For a filled polygon use filled_polygon(). The adjacent coordinates in the points argument, as well as the first and last points, will be connected by line segments. e.g. For the points [(x1, y1), (x2, y2), (x3, y3)] a line segment will be drawn from (x1, y1) to (x2, y2), from (x2, y2) to (x3, y3), and from (x3, y3) to (x1, y1).
Parameters:

surface (Surface) -- surface to draw on
points (tuple(coordinate) or list(coordinate)) -- a sequence of 3 or more (x, y) coordinates, where each coordinate in the sequence must be a tuple/list/pygame.math.Vector2 of 2 ints/floats (float values will be truncated)
color (Color or tuple(int, int, int, [int])) -- color to draw with, the alpha value is optional if using a tuple (RGB[A])

Returns:

None
Return type:

NoneType
Raises:

ValueError -- if len(points) < 3 (must have at least 3 points)
IndexError -- if len(coordinate) < 2 (each coordinate must have at least 2 items)