Class: Gosu::Font
- Inherits:
-
Object
- Object
- Gosu::Font
- Includes:
- Chingu::NamedResource
- Defined in:
- lib/chingu/assets.rb
Class Method Summary collapse
- .[](*args) ⇒ Object
-
.[]=(name, size, font) ⇒ Object
Save a font with the given name and size.
-
.autoload(name, size) ⇒ Object
Load a font with the given name and size.
Methods included from Chingu::NamedResource
Class Method Details
.self.[](name, size) ⇒ Object .self.[](size) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/chingu/assets.rb', line 67 def self.[]( *args ) case args.size when 1 name = Gosu.default_font_name size = args[0] when 2 name, size = args else raise ArgumentError, "wrong number of arguments (#{args.size} for 1 or 2)" end result = @resources[[name, size]] if result.nil? result = autoload(name, size) if result self[name, size] = result result.name = name end end return result end |
.[]=(name, size, font) ⇒ Object
Save a font with the given name and size.
95 96 97 |
# File 'lib/chingu/assets.rb', line 95 def self.[]=( name, size, font ) @resources[[name, size]] = font end |
.autoload(name, size) ⇒ Object
Load a font with the given name and size.
49 50 51 52 53 54 55 56 57 |
# File 'lib/chingu/assets.rb', line 49 def self.autoload(name, size) font_name = if path = find_file(name) path # Use the full path, found in the autoload dirs. else name # Font not found in the path. Assume it is an OS font. end return Gosu::Font.new($window, font_name, size) end |