A font can be used to draw text on a Window object very flexibly. Fonts are ideal for small texts that change regularly. For large, static texts you should use Image#from_text.
Attributes
Name | Read/write? |
---|---|
height | R |
name | R |
Public Class Methods
new (window, font_name, height)
font_name: | Name of a system font, or a filename to a TTF file (must contain ’/’, does not work on Linux). |
height: | Height of the font, in pixels. |
# File reference/gosu.rb, line 171 def initialize(window, font_name, height); end
Public Instance Methods
draw (text, x, y, z, factor_x=1, factor_y=1, color=0xffffffff, mode=:default)
Draws text so the top left corner of the text is at (x; y).
Characters are created internally as needed.
# File reference/gosu.rb, line 179 def draw(text, x, y, z, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
draw_rel (text, x, y, z, rel_x, rel_y, factor_x=1, factor_y=1, color=0xffffffff, mode=:default)
Draws text at a position relative to (x; y).
rel_x: | Determines where the text is drawn horizontally. If relX is 0.0, the text will be to the right of x, if it is 1.0, the text will be to the left of x, if it is 0.5, it will be centered on x. Of course, all real numbers are possible values. |
rel_y: | See rel_x. |
# File reference/gosu.rb, line 184 def draw_rel(text, x, y, z, rel_x, rel_y, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
draw_rot (text, x, y, z, angle, factor_x=1, factor_y=1, color=0xffffffff, mode=:default)
Analogous to draw, but rotates the text by a given angle.
# File reference/gosu.rb, line 187 def draw_rot(text, x, y, z, angle, factor_x=1, factor_y=1, color=0xffffffff, mode=:default); end
text_width (text, factor_x=1)
Returns the width, in pixels, the given text would occupy if drawn.
# File reference/gosu.rb, line 174 def text_width(text, factor_x=1); end