Class: Hokusai::FontRegistry

Inherits:
Object
  • Object
show all
Defined in:
ui/src/hokusai/font.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFontRegistry

Returns a new instance of FontRegistry.



249
250
251
252
# File 'ui/src/hokusai/font.rb', line 249

def initialize
  @fonts = {}
  @active_font = nil
end

Instance Attribute Details

#active_fontObject (readonly)

Returns the value of attribute active_font.



247
248
249
# File 'ui/src/hokusai/font.rb', line 247

def active_font
  @active_font
end

#fontsObject (readonly)

Returns the value of attribute fonts.



247
248
249
# File 'ui/src/hokusai/font.rb', line 247

def fonts
  @fonts
end

Instance Method Details

#activate(name) ⇒ Object

Raises:



266
267
268
269
270
# File 'ui/src/hokusai/font.rb', line 266

def activate(name)
  raise Hokusai::Error.new("Font #{name} is not registered") unless fonts[name]

  @active_font = name
end

#activeObject



276
277
278
# File 'ui/src/hokusai/font.rb', line 276

def active
  fonts[active_font]
end

#active_font_nameObject

Raises:



260
261
262
263
264
# File 'ui/src/hokusai/font.rb', line 260

def active_font_name
  raise Hokusai::Error.new("No active font") if active_font.nil?

  active_font
end

#get(name) ⇒ Object



272
273
274
# File 'ui/src/hokusai/font.rb', line 272

def get(name)
  fonts[name]
end

#register(name, font) ⇒ Object

Raises:



254
255
256
257
258
# File 'ui/src/hokusai/font.rb', line 254

def register(name, font)
  raise Hokusai::Error.new("Font #{name} already registered") if fonts[name]

  fonts[name] = font
end