Class: Textorize::Renderer

Inherits:
Object
  • Object
show all
Includes:
OSX
Defined in:
lib/textorize/renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(window, string, options) ⇒ Renderer

Returns a new instance of Renderer.



7
8
9
10
11
12
13
14
15
16
# File 'lib/textorize/renderer.rb', line 7

def initialize(window, string, options)
  @text_view = NSTextView.alloc.initWithFrame([0,0,0,0])

  set_attr_and_text options, string
  window.setContentView @text_view
  @text_view.sizeToFit
  
  window.display
  window.orderFrontRegardless
end

Instance Method Details

#bitmapObject



18
19
20
21
22
23
# File 'lib/textorize/renderer.rb', line 18

def bitmap
  @text_view.lockFocus
  bitmap = NSBitmapImageRep.alloc.initWithFocusedViewRect(@text_view.bounds)
  @text_view.unlockFocus
  bitmap
end