Class: Phew::FontRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/phew/font_repository.rb

Overview

Cache for font information retrieved from a Pango context

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ FontRepository

Returns a new instance of FontRepository.

Parameters:

  • context (Pango::Context)

    Pango context to retrieve fonts from.



9
10
11
12
# File 'lib/phew/font_repository.rb', line 9

def initialize(context)
  @store = {}
  @context = context
end

Instance Method Details

#get_font(text_description) ⇒ Object

Retrieve a font based on the given text description. The text description should be in the format accepted by Font#new.

Parameters:

  • text_description (String)

    Description of the font to retrieve.



18
19
20
# File 'lib/phew/font_repository.rb', line 18

def get_font(text_description)
  @store[text_description] ||= Font.new @context, text_description
end