NAME ^

SDL::Font - Parrot class representing fonts in Parrot SDL

SYNOPSIS ^

        # load this library
        load_bytecode 'library/SDL/Font.pir'

        # set the font's arguments
        .local pmc font_args
        font_args                 = new PerlHash
        font_args[ 'font_file'  ] = 'myfont.ttf'
        font_args[ 'point_size' ] = 48

        # create a new SDL::Font object
        .local pmc font
        .local int font_type

        find_type font_type, 'SDL::Font'
        font = new font_type, font_args

        # draw text to the screen
        #       presuming you have an SDL::Surface, SDL::Color, and SDL::Rect here...
        font.'draw'( 'some text', font_color, destination_surface, dest_rect )

        # or render it to a surface to use later
        font.'render_text'( 'some text', font_color )

DESCRIPTION ^

A SDL::Font object represents a TrueType font in SDL. You can use this to draw fonts to any SDL::Surface.

METHODS ^

All SDL::Font objects have the following methods:

_BUILD( font_args )

Given a Perlhash containing arguments, set the attributes of this font. The keys of this hash are font_file and point_size, two strings containing the path to a TrueType font to load and the size of the font when drawn, in pixels.

The name of this method may change.

draw( text_string, text_color, dest_surface, dest_rect )

Given a string of text to draw, an SDL::Color object representing the color of the text to draw, a SDL::Surface to which to draw, and a SDL::Rect representing the placement of the text within the surface, draws some text.

Whew.

render_text( text_string, text_color )

Renders a string of text of the given SDL::Color. This returns a new SDL::Surface containing the rendered font.

font()

Returns the underlying SDL_Font structure this object wraps. You should never need to call this directly unless you're calling SDL functions directly, in which case why not send me a patch?

point_size( [ new_size ] )

Gets or sets the point size associated with this font object. The single argument is an integer and is optional.

AUTHOR ^

Written and maintained by chromatic, <chromatic at wgz dot org>. Please send patches, feedback, and suggestions to the Perl 6 Internals mailing list.

COPYRIGHT ^

Copyright (c) 2004, The Perl Foundation.


parrot