Class: Gosu::Font
- Inherits:
-
Object
- Object
- Gosu::Font
- Defined in:
- rdoc/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
-
#height ⇒ Integer
readonly
The font’s height in pixels.
-
#name ⇒ String
readonly
The font’s name.
Drawing text collapse
-
#draw_markup(markup, x, y, z, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ Object
Like #draw_text, but supports the following markup tags: ‘bold`, `italic`, `<c=rrggbb>colors</c>`.
-
#draw_markup_rel(markup, x, y, z, rel_x, rel_y, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ Object
Like #draw_text_rel, but supports the following markup tags: ‘bold`, `italic`, `<c=rrggbb>colors</c>`.
-
#draw_text(text, x, y, z, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ void
Draws a single line of text with its top left corner at (x, y).
-
#draw_text_rel(text, x, y, z, rel_x, rel_y, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ void
Draws a single line of text relative to (x, y).
Instance Method Summary collapse
-
#[]=(character, image) ⇒ void
Overrides the image for a character.
-
#initialize(height, options = {}) ⇒ Font
constructor
Load a font from the system fonts or a file.
-
#markup_width(markup, scale_x = 1) ⇒ Object
Like #text_width, but supports the following markup tags: ‘bold`, `italic`, `<c=rrggbb>colors</c>`.
-
#text_width(text, scale_x = 1) ⇒ Integer
Returns the width of a single line of text, in pixels, if it were drawn.
Constructor Details
Instance Attribute Details
#height ⇒ Integer (readonly)
Returns the font’s height in pixels.
262 263 264 |
# File 'rdoc/gosu.rb', line 262 def height @height end |
#name ⇒ String (readonly)
The font’s name. This may be the name of a system font or a filename.
258 259 260 |
# File 'rdoc/gosu.rb', line 258 def name @name end |
Instance Method Details
#[]=(character, image) ⇒ void
For any given character, this method MUST NOT be called more than once, and MUST NOT be called if a string containing the character has already been drawn.
This method returns an undefined value.
Overrides the image for a character.
289 |
# File 'rdoc/gosu.rb', line 289 def []=(character, image); end |
#draw_markup(markup, x, y, z, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ Object
Like #draw_text, but supports the following markup tags: ‘bold`, `italic`, `<c=rrggbb>colors</c>`.
314 |
# File 'rdoc/gosu.rb', line 314 def draw_markup(markup, x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end |
#draw_markup_rel(markup, x, y, z, rel_x, rel_y, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ Object
Like #draw_text_rel, but supports the following markup tags: ‘bold`, `italic`, `<c=rrggbb>colors</c>`.
335 |
# File 'rdoc/gosu.rb', line 335 def draw_markup_rel(markup, x, y, z, rel_x, rel_y, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end |
#draw_text(text, x, y, z, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ void
This method returns an undefined value.
Draws a single line of text with its top left corner at (x, y).
310 |
# File 'rdoc/gosu.rb', line 310 def draw_text(text, x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end |
#draw_text_rel(text, x, y, z, rel_x, rel_y, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ void
This method returns an undefined value.
Draws a single line of text relative to (x, y).
The text is aligned to the drawing location according to the ‘rel_x` and `rel_y` parameters: a value of 0.0 corresponds to top and left, while 1.0 corresponds to bottom and right. A value of 0.5 naturally corresponds to the center of the text.
All real numbers are valid alignment values and will be interpolated (or extrapolated) accordingly.
331 |
# File 'rdoc/gosu.rb', line 331 def draw_text_rel(text, x, y, z, rel_x, rel_y, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end |
#markup_width(markup, scale_x = 1) ⇒ Object
Like #text_width, but supports the following markup tags: ‘bold`, `italic`, `<c=rrggbb>colors</c>`.
348 |
# File 'rdoc/gosu.rb', line 348 def markup_width(markup, scale_x=1); end |
#text_width(text, scale_x = 1) ⇒ Integer
Returns the width of a single line of text, in pixels, if it were drawn.
344 |
# File 'rdoc/gosu.rb', line 344 def text_width(text, scale_x=1); end |