Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleanups, remove dead options, off-screen rendering, fix fg color

  • Loading branch information...
commit c8e8d9720b4db9b4557bb2329a21558716b88c3d 1 parent 0137321
@madrobby authored
View
21 LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2009 Thomas Fuchs
+http://script.aculo.us/thomas
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
9 README
@@ -4,12 +4,13 @@ Usage: ./textorize.rb [options] string
-f, --font=[FONT] Font name
-s, --size=[SIZE] Font size in point
-l, --lineheight=[HEIGHT] Line height in point
- -k, --kerning=[STEPS] Tighten or loosen kerning by the given amount
-w, --width=[WIDTH] Wrapping width in pixels
-o, --output=[FILENAME] Specify filename for saving
-b, --obliqueness=[ANGLE] Slant angle
- -t, --stencil=[COLOR] Render background with color and stencil text
- -r, --reverse Reverse stencil (color on transparent background)
-c, --color=[COLOR] Render text in specific color
--background=[COLOR] Render background in specific color
- -h, --help Display this message and exit
+ -h, --help Display this message and exit
+
+This software is alpha-quality and has some bugs and known issues. Please contribute!
+
+textorize is released under the MIT license.
View
16 bin/textorize
@@ -18,14 +18,6 @@ opts = OptionParser.new do |opts|
options[:lineheight] = v
end
- opts.on('-k', '--kerning=[STEPS]', Integer, 'Tighten or loosen kerning by the given amount') do |v|
- options[:kerning] = v
- end
-
- opts.on('-w', '--width=[WIDTH]', Integer, 'Wrapping width in pixels') do |v|
- options[:width] = v
- end
-
opts.on('-o', '--output=[FILENAME]', String, 'Specify filename for saving') do |v|
options[:output] = v
end
@@ -34,14 +26,6 @@ opts = OptionParser.new do |opts|
options[:obliqueness] = v
end
- opts.on('-t', '--stencil=[COLOR]', String, 'Render background with color and stencil text') do |v|
- options[:stencil] = v
- end
-
- opts.on('-r', '--reverse', 'Reverse stencil (color on transparent background)') do
- options[:reverse_stencil] = true
- end
-
opts.on('-c', '--color=[COLOR]', String, 'Render text in specific color') do |v|
options[:color] = v
end
View
19 lib/textorize/renderer.rb
@@ -5,11 +5,11 @@ class Renderer
include OSX
def initialize(window, string, options)
- @text_view = NSTextView.alloc.initWithFrame([0,0,1000,100])
-
+ @text_view = NSTextView.alloc.initWithFrame([0,0,0,0])
+
+ @text_view.setString string
set_attribs options
window.setContentView @text_view
- @text_view.setString string
@text_view.sizeToFit
window.display
@@ -30,14 +30,13 @@ def set_attribs(options)
@text_view.useAllLigatures(nil)
color = (options[:color] || '0,0,0').split(',')
- fgcolor = NSColor.colorWithDeviceRed_green_blue_alpha(color[0], color[1], color[2], 1)
- bgcolor = (options[:background] || '1,1,1').split(',')
- @text_view.setBackgroundColor(
- NSColor.colorWithDeviceRed_green_blue_alpha(bgcolor[0], bgcolor[1], bgcolor[2], 1)
- )
- @text_view.setTextColor(fgcolor)
+ background = (options[:background] || '1,1,1').split(',')
- puts @text_view.inspect
+ @text_view.setTextColor(
+ NSColor.colorWithDeviceRed_green_blue_alpha(color[0], color[1], color[2], 1))
+
+ @text_view.setBackgroundColor(
+ NSColor.colorWithDeviceRed_green_blue_alpha(background[0], background[1], background[2], 1))
para = NSMutableParagraphStyle.alloc.init
para.setLineSpacing(options[:lineheight])
View
2  lib/textorize/runner.rb
@@ -24,7 +24,7 @@ class RunnerApplication < OSX::NSObject
attr_accessor :output
def initialize
- @window = NSWindow.alloc.initWithContentRect_styleMask_backing_defer([150, 1500, 1000, 500], NSBorderlessWindowMask, 2, 0)
+ @window = NSWindow.alloc.initWithContentRect_styleMask_backing_defer([-2000, -2000, 2000, 2000], NSBorderlessWindowMask, 2, 0)
end
def applicationDidFinishLaunching(notification)
View
4 textorize.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "textorize"
- s.version = "0.0.7"
+ s.version = "0.1.0"
s.date = "2009-09-26"
s.summary = "OS X subpixel antialiased PNG string renderer"
s.email = "thomas@fesch.at"
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.has_rdoc = false
s.require_paths = ['lib']
s.authors = ["Thomas Fuchs"]
- s.files = ["Rakefile", "bin/textorize", "lib/textorize", "lib/textorize/renderer.rb", "lib/textorize/runner.rb", "lib/textorize/saver.rb", "lib/textorize.rb", "test/test_runner.rb"]
+ s.files = ["Rakefile", "bin/textorize", "lib/textorize", "lib/textorize/renderer.rb", "lib/textorize/runner.rb", "lib/textorize/saver.rb", "lib/textorize.rb", "test/test_runner.rb", 'LICENSE']
s.test_files = Dir["test/test_*.rb"] unless $SAFE > 0
s.executables = ["textorize"]
end
Please sign in to comment.
Something went wrong with that request. Please try again.