Class: Gosu::Font

Inherits:
Object
  • Object
show all
Defined in:
reference/gosu.rb

Overview

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.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Font) initialize(window, font_name, height)

font_name:Name of a system font, or a filename to a TTF file (must contain ’/’).
height:Height of the font, in pixels.


301
# File 'reference/gosu.rb', line 301

def initialize(window, font_name, height) end

Instance Attribute Details

- (Object) height (readonly)

Returns the value of attribute height



297
298
299
# File 'reference/gosu.rb', line 297

def height
  @height
end

- (Object) name (readonly)

Returns the value of attribute name



297
298
299
# File 'reference/gosu.rb', line 297

def name
  @name
end

Instance Method Details

- (Object) []=(character, image)

Sets the image to be used for a certain character. Must not be called twice for the same character, or after the character has been drawn already.



304
# File 'reference/gosu.rb', line 304

def []=(character, image) end

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



309
# File 'reference/gosu.rb', line 309

def draw(text, x, y, z, factor_x=1, factor_y=1, color=0xffffffff, mode=:default) end

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


314
# File 'reference/gosu.rb', line 314

def draw_rel(text, x, y, z, rel_x, rel_y, factor_x=1, factor_y=1, color=0xffffffff, mode=:default) end

- (Object) draw_rot(text, x, y, z, angle, factor_x = 1, factor_y = 1, color = 0xffffffff, mode = :default)

Deprecated.

Use a combination of Window#rotate and Font#draw instead.

Analogous to draw, but rotates the text by a given angle.



321
# File 'reference/gosu.rb', line 321

def draw_rot(text, x, y, z, angle, factor_x=1, factor_y=1, color=0xffffffff, mode=:default) end

- (Object) text_width(text, factor_x = 1)

Returns the width, in pixels, the given text would occupy if drawn.



317
# File 'reference/gosu.rb', line 317

def text_width(text, factor_x=1) end