Class: Gosu::Font

Inherits:
Object
  • Object
show all
Defined in:
lib/gosu_android/graphics/font.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window, font_name, font_height, font_flags = :ff_bold) ⇒ Font

Returns a new instance of Font.



30
31
32
33
34
35
36
# File 'lib/gosu_android/graphics/font.rb', line 30

def initialize(window, font_name, font_height, font_flags = :ff_bold)
  @window = window
  @fonts_manager = window.fonts_manager
  @name = font_name
  @height = font_height * 2
  @flags = flags
end

Instance Attribute Details

#flagsObject (readonly)

Returns the value of attribute flags.



29
30
31
# File 'lib/gosu_android/graphics/font.rb', line 29

def flags
  @flags
end

#nameObject (readonly)

Returns the value of attribute name.



29
30
31
# File 'lib/gosu_android/graphics/font.rb', line 29

def name
  @name
end

Instance Method Details

#draw(text, x, y, z, factor_x = 1, factor_y = 1, c = Color::WHITE, mode = :default) ⇒ Object

Draws text so the top left corner of the text is at (x; y). param text Formatted text without line-breaks.



44
45
46
47
48
49
50
51
52
53
# File 'lib/gosu_android/graphics/font.rb', line 44

def draw(text, x, y, z, factor_x = 1, factor_y = 1, c = Color::WHITE,
  mode = :default)

  offset = 0
  text.each_char do |char|
    (@fonts_manager.getSymbol char ).draw(x + offset, y, z, factor_x, factor_y, c, mode)
    offset += 10
  end

end

#heightObject



38
39
40
# File 'lib/gosu_android/graphics/font.rb', line 38

def height
  @height / 2
end