Class: Font

Inherits:
Object
  • Object
show all
Defined in:
mrb_doc/models/font.rb

Overview

The Font class is used for displaying TTF fonts

Defined Under Namespace

Classes: NotFound

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_size, glyph_count, glyph_padding) ⇒ Font

Creates a new instance of Font

Parameters:

  • base_size (Integer)
  • glyph_count (Integer)
  • glyph_padding (Integer)


11
12
13
14
15
# File 'mrb_doc/models/font.rb', line 11

def initialize(base_size, glyph_count, glyph_padding)
  # mrb_Font_initialize
  # src/mruby_integration/models/font.cpp
  Font.new
end

Instance Attribute Details

#base_sizeInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/font.rb', line 4

def base_size
  @base_size
end

#glyph_countInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/font.rb', line 4

def glyph_count
  @glyph_count
end

#glyph_paddingInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/font.rb', line 4

def glyph_padding
  @glyph_padding
end

Class Method Details

.load(path, size: 32, char_count: 100) ⇒ Font

Loads the font from the specified path

Parameters:

  • path (String)
  • size (Integer) (defaults to: 32)
  • char_count (Integer) (defaults to: 100)

Returns:

Raises:



48
49
50
51
# File 'mrb_doc/models/font.rb', line 48

def self.load(path, size: 32, char_count: 100)
  # src/mruby_integration/models/font.cpp
  Font.new
end

Instance Method Details

#draw(text, position: Vector2::ZERO, size: 32, padding: 0, colour: BLACK) ⇒ nil

Draws the text at the given position, size, padding, and colour

Parameters:

  • text (String)
  • position (Vector2) (defaults to: Vector2::ZERO)
  • size (Integer) (defaults to: 32)
  • padding (Integer) (defaults to: 0)
  • colour (Colour) (defaults to: BLACK)

Returns:

  • (nil)


67
68
69
70
# File 'mrb_doc/models/font.rb', line 67

def draw(text, position: Vector2::ZERO, size: 32, padding: 0, colour: BLACK)
  # src/mruby_integration/models/font.cpp
  nil
end

#measure(text, size: 32, padding: 0) ⇒ Vector2

Returns the size of the text

Parameters:

  • text (String)
  • size (Integer) (defaults to: 32)
  • padding (Integer) (defaults to: 0)

Returns:

Raises:



78
79
80
81
# File 'mrb_doc/models/font.rb', line 78

def measure(text, size: 32, padding: 0)
  # src/mruby_integration/models/font.cpp
  Vector2.new
end

#to_hHash

Return the object represented by a Hash

Returns:

  • (Hash)


37
38
39
40
# File 'mrb_doc/models/font.rb', line 37

def to_h
  # src/mruby_integration/models/font.cpp
  Hash.new
end

#to_image(text, font_size: 32, font_padding: 0, colour: BLACK) ⇒ Image

Creates an image from the font

Parameters:

  • text (String)

    The text to put on the screen

  • font_size (Integer) (defaults to: 32)
  • font_padding (Integer) (defaults to: 0)
  • colour (Colour) (defaults to: BLACK)

Returns:



89
90
91
92
93
# File 'mrb_doc/models/font.rb', line 89

def to_image(text, font_size: 32, font_padding: 0, colour: BLACK)
  # mrb_image_text_ex
  # src/mruby_integration/image.cpp
  Image.new
end

#unloadnil

Unloads the font from memory

Returns:

  • (nil)


55
56
57
58
# File 'mrb_doc/models/font.rb', line 55

def unload
  # src/mruby_integration/models/font.cpp
  nil
end