| 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.
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. |
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?.
Return the biggest descent (baseline to bottom; in pixels) of all glyphs in the 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.
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. |