Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 7 commits
  • 7 files changed
  • 1 commit comment
  • 1 contributor
View
17 README.rdoc
@@ -1,6 +1,6 @@
-= textorize: for a more beautiful web
+= textorizer: for a more beautiful web
-textorize produces beautifully subpixel antialiased text graphics on OS X, through a Rubycocoa Ruby script.
+textorize produces beautifully subpixel antialiased text graphics on OS X, through a MacRuby Ruby script.
Output format is always PNG.
@@ -13,8 +13,9 @@ http://www.slideshare.net/madrobby/textorize
Install the gem and binary by doing:
- $ gem sources -a http://gems.github.com
- $ sudo gem install madrobby-textorize
+ $ macgem sources -a http://gemcutter.org
+ $ sudo macgem install textorize-mr
+
This will install the textorize Ruby Gem, and the +textorize+ command
line tool.
@@ -33,7 +34,7 @@ line tool.
= Examples
- textorize -f"Gotham" -s200 Hello
+ textorize -f"Didot" -s200 "MacRuby Rocks"
textorize -fLucida\ Grande -s150 --color=0.5,1,0.5 --background=0,0,0.5 foo\ bar
@@ -41,4 +42,10 @@ line tool.
This software is alpha-quality and has some bugs and known issues. Please contribute!
+= Source
+
+http://github.com/mattetti/textorize
+Ported to MacRuby from http://github.com/madrobby/textorize
+
+
textorize is released under the MIT license.
View
5 bin/textorize
@@ -1,5 +1,6 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env macruby
require "optparse"
+require 'rubygems'
require "textorize"
options = {}
@@ -45,7 +46,7 @@ options[:size] ||= 28.0
options[:kerning] ||= 0
options[:lineheight] ||= options[:size]
options[:output] ||= 'output.png'
-options[:strings] = ARGV.first || 'Hello World'
+options[:strings] = ARGV.first || 'MacRuby'
options[:width] ||= 250
options[:obliqueness] ||= 0
View
1  lib/textorize.rb
@@ -1,3 +1,4 @@
+framework 'Cocoa'
$:.unshift File.dirname(__FILE__)
require "textorize/runner"
View
37 lib/textorize/renderer.rb
@@ -1,14 +1,13 @@
-require 'osx/cocoa'
+framework 'cocoa'
module Textorize
class Renderer
- include OSX
def initialize(window, string, options)
@text_view = NSTextView.alloc.initWithFrame([0,0,0,0])
- set_attr_and_text options, string
- window.setContentView @text_view
+ set_attr_and_text(options, string)
+ window.contentView = @text_view
@text_view.sizeToFit
window.display
@@ -25,32 +24,28 @@ def bitmap
private
def set_attr_and_text(options, string)
- @text_view.setHorizontallyResizable(true)
+ @text_view.horizontallyResizable = true
@text_view.useAllLigatures(nil)
para = NSMutableParagraphStyle.alloc.init
- para.setLineSpacing(options[:lineheight])
+ para.lineSpacing = options[:lineheight]
- attribs = NSMutableDictionary.alloc.init
- attribs.setObject_forKey(NSFont.fontWithName_size(options[:font], options[:size]), NSFontAttributeName)
- attribs.setObject_forKey(options[:kerning], NSKernAttributeName)
- attribs.setObject_forKey(para, NSParagraphStyleAttributeName)
- attribs.setObject_forKey(0, NSBaselineOffsetAttributeName)
- attribs.setObject_forKey(options[:obliqueness], NSObliquenessAttributeName)
-
- @text_view.setTypingAttributes(attribs)
+ @text_view.typingAttributes = {
+ NSFontAttributeName => NSFont.fontWithName(options[:font], size: options[:size]),
+ NSKernAttributeName => options[:kerning],
+ NSParagraphStyleAttributeName => para,
+ NSBaselineOffsetAttributeName => 0,
+ NSObliquenessAttributeName => options[:obliqueness]
+ }
+
@text_view.lowerBaseline(nil)
- @text_view.setString string
-
+ @text_view.string = string
color = (options[:color] || '0,0,0').split(',')
background = (options[:background] || '1,1,1').split(',')
- @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))
+ @text_view.textColor = NSColor.colorWithDeviceRed(color[0], green: color[1], blue: color[2], alpha:1)
+ @text_view.backgroundColor = NSColor.colorWithDeviceRed(background[0], green: background[1], blue: background[2], alpha:1)
end
end
View
25 lib/textorize/runner.rb
@@ -1,30 +1,21 @@
-require 'osx/cocoa'
-
module Textorize
class Runner
def initialize(string, output, options)
- app = OSX::NSApplication.sharedApplication
-
- delegate = RunnerApplication.alloc.init
- delegate.options = options
- delegate.string = string
- delegate.output = output
-
- app.setDelegate delegate
+ app = NSApplication.sharedApplication
+ app.delegate = RunnerApplication.new(string, output, options)
app.run
end
end
- class RunnerApplication < OSX::NSObject
- include OSX
- attr_accessor :options
- attr_accessor :string
- attr_accessor :output
+ class RunnerApplication
- def initialize
- @window = NSWindow.alloc.initWithContentRect_styleMask_backing_defer([-2000, -2000, 2000, 2000], NSBorderlessWindowMask, 2, 0)
+ def initialize(string, output, options)
+ @window = NSWindow.alloc.initWithContentRect([-2000, -2000, 2000, 2000], styleMask: NSBorderlessWindowMask, backing: 2, defer: 0)
+ @string = string
+ @output = output
+ @options = options
end
def applicationDidFinishLaunching(notification)
View
5 lib/textorize/saver.rb
@@ -1,15 +1,14 @@
module Textorize
class Saver
- include OSX
attr_reader :png
def initialize(renderer)
bitmap = renderer.bitmap
- @png = bitmap.representationUsingType_properties(NSPNGFileType, nil)
+ @png = bitmap.representationUsingType(NSPNGFileType, properties: nil)
end
def write_to_file(file)
- @png.writeToFile_atomically(file, true)
+ @png.writeToFile(file, atomically: true)
end
end
View
10 textorize.gemspec → textorize-mr.gemspec
@@ -1,14 +1,14 @@
Gem::Specification.new do |s|
- s.name = "textorize"
- s.version = "0.1.2"
+ s.name = "textorize-mr"
+ s.version = "0.1.0"
s.date = "2009-09-27"
- s.summary = "OS X subpixel antialiased PNG string renderer"
+ s.summary = "OS X subpixel antialiased PNG string renderer for MacRuby"
s.email = "thomas@fesch.at"
- s.homepage = "http://github.com/madrobby/textorize"
+ s.homepage = "http://github.com/mattetti/textorize"
s.description = "Textorize is a OS X utility to render subpixel antialised strings into PNG files."
s.has_rdoc = false
s.require_paths = ['lib']
- s.authors = ["Thomas Fuchs"]
+ s.authors = ["Thomas Fuchs", "Matt Aimonetti"]
s.files = ["Rakefile", "LICENSE", "bin/textorize", "lib/textorize", "lib/textorize/renderer.rb", "lib/textorize/runner.rb", "lib/textorize/saver.rb", "lib/textorize.rb", "test/test_runner.rb"]
s.test_files = Dir["test/test_*.rb"] unless $SAFE > 0
s.executables = ["textorize"]

Showing you all comments on commits in this comparison.

@Manfred

Looks a lot like Eloy's commit.

Something went wrong with that request. Please try again.