Class Rubygame::TTF
In: lib/rubygame/ttf.rb
lib/rubygame/ttf.rb
Parent: Object

IMPORTANT: this class only exists if SDL_ttf is available! Your code should check "defined?(Rubygame::TTF) != nil" to see if you can use this class, or be prepared to rescue from NameError.

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.

Methods

_render   _render   ascent   ascent   bold   bold   bold=   bold=   bold?   bold?   descent   descent   height   height   italic   italic   italic=   italic=   italic?   italic?   line_skip   line_skip   new   new   quit   quit   render   render   render_unicode   render_unicode   render_utf8   render_utf8   setup   setup   size_text   size_text   size_unicode   size_unicode   size_utf8   size_utf8   underline   underline   underline=   underline=   underline?   underline?  

Public Class methods

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

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

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

file:filename of the TrueType font to use. Should be a TTF or FON file.
size:point size (based on 72DPI). (That means 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.

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.

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.

Public Instance methods

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

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

bold()

Alias for bold?

bold()

Alias for bold?

Enable or disable bold mode for this font. Returns the old value.

Enable or disable bold mode for this font. Returns the old value.

True if bold mode is enabled for this font.

True if bold mode is enabled for this font.

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

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.

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

italic()

Alias for italic?

italic()

Alias for italic?

Enable or disable italic mode for this font. Returns the old value.

Enable or disable italic mode for this font. Returns the old value.

True if italic mode is enabled for this font.

True if italic mode is enabled for this font.

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.

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).

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

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

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

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

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

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

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

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

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

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

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

The width and height the text would be if it were rendered, without the overhead of actually rendering it.

The width and height the text would be if it were rendered, without the overhead of actually rendering it.

The width and height the Unicode text would be if it were rendered, without the overhead of actually rendering it.

The width and height the Unicode text would be if it were rendered, without the overhead of actually rendering it.

The width and height the UTF-8 encoded text would be if it were rendered, without the overhead of actually rendering it.

The width and height the UTF-8 encoded text would be if it were rendered, without the overhead of actually rendering it.

underline()

Alias for underline?

underline()

Alias for underline?

Enable or disable underline mode for this font. Returns the old value.

Enable or disable underline mode for this font. Returns the old value.

True if underline mode is enabled for this font.

True if underline mode is enabled for this font.

[Validate]