Permalink
Browse files

Add padding option

  • Loading branch information...
1 parent d302ab0 commit ceaaf2a718c4363c6e46401ed3dc97c110bf8065 @madrobby committed Oct 20, 2009
Showing with 9 additions and 2 deletions.
  1. +1 −0 README.rdoc
  2. +4 −0 bin/textorize
  3. +3 −1 lib/textorize/renderer.rb
  4. +1 −1 textorize.gemspec
View
@@ -41,6 +41,7 @@ http://rubycocoa.sourceforge.net/GettingStarted
-t, --ligatures=[TYPE] Ligatures usage: all, standard or off
--list-fonts List available fonts
-k, --kerning=[VALUE] Kerning adjustment
+ -p, --padding=[VALUE] Padding in px
-o, --output=[FILENAME] Specify filename for saving
-b, --obliqueness=[ANGLE] Slant angle
-c, --color=[COLOR] Render text in specific color (CSS color value)
View
@@ -30,6 +30,10 @@ opts = OptionParser.new do |opts|
options[:kerning] = v
end
+ opts.on('-p', '--padding=[VALUE]', Float, 'Padding in px') do |v|
+ options[:padding] = v
+ end
+
opts.on('-o', '--output=[FILENAME]', String, 'Specify filename for saving') do |v|
options[:output] = v
end
@@ -4,7 +4,7 @@ module Textorize
class Renderer
include OSX
- def initialize(window, string, options)
+ def initialize(window, string, options)
@text_view = NSTextView.alloc.initWithFrame([0,0,0,0])
window.opaque = false
@@ -46,6 +46,8 @@ def set_attr_and_text(options, string)
@text_view.lowerBaseline(nil)
+ @text_view.setTextContainerInset([options[:padding],options[:padding]]) if options[:padding]
+
@text_view.string = string
@text_view.textColor = NSColor.from_css(options[:color] || 'black')
@text_view.backgroundColor = NSColor.from_css(options[:background] || 'white')
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "textorize"
- s.version = "0.26"
+ s.version = "0.27"
s.date = "2009-10-12"
s.summary = "OS X subpixel antialiased PNG string renderer"
s.email = "thomas@fesch.at"

0 comments on commit ceaaf2a

Please sign in to comment.