Star Ruby Ruby extension library for creating 2D games

StarRuby::Font

A class which represents font. This is immutable.

When you render text on Texture, you have to pass instance of Font to specify font of the text.

TTF and TTC files can be used.

Font names which can be used as arguments are as below:

It is recommended to specify font-style for Linux/Mac OS X

Class methods

Font.new(path_or_name, size, options = {})

Pass the path of a font file or font name to generate Font instance.

You have to pass Hash as options. Keys and values below can be selected.

KeyValueDefault
:boldBold or notfalse
:italicItalic or notfalse
:ttc_indexIndex of TTC file0

:ttc_index is valid only when you specify TTC file path in path_or_name.

Font.exist?(path_or_name)

If font name or font path of a font file exists, return true, otherwise return false.

Instance Methods

bold?

If font is bold, return true, otherwise return false .

dispose

Recommended not to use after Ver 0.1.13.

(After Ver 0.1.13) Don't do anything.

(Before Ver 0.1.12) Release Font resource

disposed?

Recommended not to use after Ver 0.1.13.

(After Ver 0.1.13) Always return false

(Before Ver 0.1.12) If the resource has been disposed by dispose already, return true otherwise return false

get_size(text)

Get array of size of text when render text ([(Width), (Height)]).

italic?

When the font is Italic, return true, otherwise return false

name

Get font name.

size

Get the height of the font.

© Copyright 2012 Hajime Hoshi