Class Rubygame::TTF
In: ext/rubygame/rubygame_transform.c
Parent: Object

TTF provides an interface to SDL_ttf, allowing TrueType Font files to be loaded and used to render text to Surfaces.

The TTF class must be initialized with the setup method before any TTF objects can be created or used.

This class is only usable if Rubygame was compiled with the SDL_ttf library. You may test if this feature is available with the usable? method. If you need more flexibility, you can check the library version that Rubygame was compiled against with the version method.

Methods

ascent   b   b=   bold   bold=   descent   height   i   i=   italic   italic=   line_skip   new   quit   render   setup   u   u=   underline   underline=   usable?   version  

Public Class methods

Create a new TTF object, which can render text to a Surface with a particular font style and size.

This function takes these arguments:

file:filename of the TrueType font to use. Should be a TTF or FON file.
size:point size (based on 72DPI). Or, the height in pixels from the bottom of the descent to the top of the ascent.

Clean up and quit SDL_ttf, making the TTF class unusable as a result (until it is setup again). This does not need to be called before Rubygame exits, as it will be done automatically.

Attempt to setup the TTF class for use by initializing SDL_ttf. This must be called before the TTF class can be used. Raises SDLError if there is a problem initializing SDL_ttf.

Returns true if the feature(s) associated with this module/class are available for use. This means that Rubygame was compiled and linked against the C library which provides the feature, i.e. SDL_gfx, SDL_image, or SDL_ttf.

If the features are not available (for example, if the libraries were not installed or detected when Rubygame was compiled), returns false.

Return the major, minor, and patch numbers for the version of SDL_ttf that Rubygame was compiled with. If Rubygame was not compiled with SDL_ttf, all version numbers will be 0 (zero), and you should not attempt to use the TTF class.

This allows for more flexible detection of the capabilities of the TTF class’ base library, SDL_ttf. See also usable?.

Public Instance methods

Return the biggest ascent (baseline to top; in pixels) of all glyphs in the font.

b()

Alias for bold

b=(p1)

Alias for bold=

True if italicizing is enabled for the font.

Set whether italicizing is enabled for this font. Returns the old value.

Return the biggest descent (baseline to bottom; in pixels) of all glyphs in the font.

Return the biggest height (bottom to top; in pixels) of all glyphs in the font.

i()

Alias for italic

i=(p1)

Alias for italic=

True if italicizing is enabled for the font.

Set whether italicizing is enabled for this font. Returns the old value.

Return the recommended distance (in pixels) from a point on a line of text to the same point on the line of text below it.

Renders a string to a Surface with the font‘s style and the given color(s).

This method takes these arguments:

string:the text string to render
aa:Use anti-aliasing if true. Enabling this makes the text look much nicer (smooth curves), but is much slower.
fg:the color to render the text, in the form [r,g,b]
bg:the color to use as a background for the text. This option can be omitted to have a transparent background.
u()

Alias for underline

u=(p1)

Alias for underline=

True if underlining is enabled for the font.

Set whether underlining is enabled for this font. Returns the old value.

[Validate]