| Home | Trees | Index | Help |
|---|
| Package ocempgui :: Package draw :: Module String |
|
| Function Summary | |
|---|---|
apply_font_style (font, style) -> None | |
create_file_font (...) -> Font | |
create_font (...) -> Font | |
create_system_font (...) -> Font | |
draw_string (...) -> Surface | |
draw_string_with_bg (...) -> Surface | |
| Function Details |
|---|
apply_font_style(font, style)apply_font_style (font, style) -> None Applies font rendering styles to a Font. Raises a TypeError, if the 'style' argument is not a valid FONT_STYLE_TYPES value. |
create_file_font(fontfile, size, style=0)create_file_font (...) -> Font Creates a new font from a given font file. The 'fontfile' is the path to a font file or a python file-like object. The resulting pygame.Font will have the specified height 'size' in pixels. Additional styles can be passed to give the font a bold, italic, or underlined style. The 'styles' attribute must be a valid combination of the FONT_STYLE_TYPES. The font will be cached internally, so it can be reused without creating it again and again. This also means, that any operation, which will modify the pygame.Font() object, will also be applied to the cached one. It is possible to avoid this by copying the font object using font.copy(). The following example will try to load a font with a height of 14 pixels from a subdirectory: create_file_font ('fonts/MyFont.ttf', 14) Raises a TypeError, if the 'style' argument is not a valid FONT_STYLE_TYPES value. |
create_font(font, size, style=0)create_font (...) -> Font Wraps the create_file_font() and create_system_font() methods. This function tries to create a font using create_file_font() and calls create_system_font() upon failure. |
create_system_font(fontname, size, style=0)create_system_font (...) -> Font Creates a new font from a given font name of the system fonts. The 'fontname' is a valid system font name of an installed font. The resulting pygame.Font will have the specified height 'size' in pixels. Additional styles can be passed to give the font a bold, italic, or underlined style. The 'styles' attribute must be a valid combination of the FONT_STYLE_TYPES. The font will be cached internally, so it can be reused without creating it again and again. This also means, that any operation, which will modify the pygame.Font() object, will also be applied to the cached one. It is possible to avoid this by copying the font object using font.copy(). This will always return a valid Font object, and will fallback on the builtin pygame font if the given font is not found. The following example will try to load a font with a height of 14: create_system_font ('Helvetica', 14) Raises a TypeError, if the 'style' argument is not a valid FONT_STYLE_TYPES value. |
draw_string(text, font, size, antialias, color, style=0)draw_string (...) -> Surface Creates a surface displaying a string. 'text' is the text, which should be renderered to a surface. 'font' can be any valid font name of the system fonts or a font file (see the note). The 'size' is the height of the font in pixels, 'alias' is an integer value, which enables or disables antialiasing of the font, and 'color' is a pygame color style argument for the text. Additional styles can be passed to give the font a bold, italic, or underlined style. The 'styles' attribute must be a valid combination of the FONT_STYLE_TYPES. The following example will create an antialiased string surface with a black font color and tries to use an installed 'Helvetica' font: draw_string ('Test', 'Helvetica', 14, 1, (0, 0, 0)) Note: The function first tries to resolve the font as font file. If that fails, it looks for a system font name, which matches the font argument and returns a Font object based on those information (or the fallback font of pygame, see pygame.font.SysFont() for more information). Besides this the function simply calls the pygame Font.render() function, thus all documentation about it can applied to this function, too. |
draw_string_with_bg(text, font, size, antialias, color, bgcolor, style=0)draw_string_with_bg (...) -> Surface Creates a surface displaying a atring. 'text' is the text, which should be renderered to a surface. 'font' can be any valid font name of the system fonts or a font file (see the note). The 'size' is the height of the font in pixels, 'alias' is an integer value, which enables or disables antialiasing of the font, and 'color' is a pygame color style argument for the text. The Surface will be filled with the passed background color 'bgcolor' Additional styles can be passed to give the font a bold, italic, or underlined style. The 'styles' attribute must be a valid combination of the FONT_STYLE_TYPES. The following example will create an antialiased string surface with a black font color and white background color and tries to use an installed 'Helvetica' font: draw_string ('Test', 'Helvetica', 14, 1, (0, 0, 0), (255, 255, 255)) Note: The function first tries to resolve the font as font file. If that fails, it looks for a system font name, which matches the font argument and returns a Font object based on those information (or the fallback font of pygame, see pygame.font.SysFont() for more information). Besides this the function simply calls the pygame Font.render() function, thus all documentation about it can applied to this function, too. |
| Home | Trees | Index | Help |
|---|
| Generated by Epydoc 2.1 on Thu Jan 10 10:18:42 2008 | http://epydoc.sf.net |