Class: BDF::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/bdf/renderer.rb

Class Method Summary collapse

Class Method Details

.render(text, opts = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bdf/renderer.rb', line 3

def self.render(text, opts = {})
  font = opts[:font]

  # Get baseline for initial cursor
  cursor = [0, -font.displacement_y]

  # Initial size of one char. resizes automatically
  canvas = Canvas.new(font.bounding_box_x, font.bounding_box_y)

  text.chars.each do |char|
    # Lookup glyph
    glyph = font.glyph(char)

    cursor = glyph.render(canvas, cursor)
  end

  canvas
end