Class: BDF::Renderer
- Inherits:
-
Object
- Object
- BDF::Renderer
- 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 21 22 23 24 25 26 |
# 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| if char == "\n" cursor[0] = 0 cursor[1] += font.bounding_box_y next end # Lookup glyph glyph = font.glyph(char) cursor = glyph.render(canvas, cursor) end canvas end |