textorize

38
Introducing textorize (squint to read)

Upload: thomas-fuchs

Post on 15-Jan-2015

24.379 views

Category:

Technology


0 download

DESCRIPTION

Textorize is a OSX-only command line tool to generate subpixel antialiased PNGs for really awesome looking web font graphics. For more information, see http://mir.aculo.us/2009/09/29/textorize-pristine-font-rendering-for-the-web/ This presentation was given at the Central European Ruby Camp in Vienna on September 26, 2009.

TRANSCRIPT

Page 1: Textorize

Introducing

textorize(squint to read)

Page 2: Textorize

exploit OS X font rendering goodness

through Ruby

Page 3: Textorize

pristine font rendering

for the web

Page 4: Textorize

CSS “font-face”

Flash-based replacement

JS-based replacement

Images

Page 5: Textorize

@font-face

nightmare,license issues

Page 6: Textorize

sIFR 2 + 3 (beta)

Page 7: Textorize

sIFR 2 + 3 (beta)

needs flash

Page 8: Textorize

sIFR 2 + 3 (beta)

sluggish if overused

Page 9: Textorize

sIFR 2 + 3 (beta)

fonts must be converted

Page 10: Textorize

sIFR 2 + 3 (beta)

no subpixel AA

Page 11: Textorize

typeface.js, cufon.js

Page 12: Textorize

typeface.js, cufon.js

no subpixel AA

Page 13: Textorize

typeface.js, cufon.js

complicated font conversion, large .js files

Page 14: Textorize

typeface.js, cufon.js

license issues

Page 15: Textorize

12pt Consolas, no AA

12pt Consolas, “sharp”

12pt Consolas, “crisp”

Photoshop

Page 16: Textorize

12pt Consolas, no AA

12pt Consolas, “sharp”

12pt Consolas, “crisp”

Photoshopmodern fonts

can’t handle no AA

Page 17: Textorize

12pt Consolas, no AA

12pt Consolas, “sharp”

12pt Consolas, “crisp”

Photoshop

artifacts on curves

Page 18: Textorize

12pt Consolas, no AA

12pt Consolas, “sharp”

12pt Consolas, “crisp”

Photoshop

spacing issues

Page 19: Textorize

12pt Consolas, no AA

12pt Consolas, “sharp”

12pt Consolas, “crisp”

Photoshop

no subpixel AA

Page 20: Textorize

with Photoshop,automation from a CLI is difficult

Page 21: Textorize

ImageMagick

convert  -­‐background  white  -­‐fill  black  -­‐font  Consolas.ttf  -­‐pointsize  12  label:OMFGZ  

omfgz.png

Page 22: Textorize

ImageMagick

convert  -­‐background  white  -­‐fill  black  -­‐font  Consolas.ttf  -­‐pointsize  12  label:OMFGZ  

omfgz.png

letter spacing

fail

Page 23: Textorize

ImageMagick

convert  -­‐background  white  -­‐fill  black  -­‐font  Consolas.ttf  -­‐pointsize  12  label:OMFGZ  

omfgz.png

nosubpixel

AA

Page 24: Textorize

ImageMagick

convert  -­‐background  white  -­‐fill  black  -­‐font  Consolas.ttf  -­‐pointsize  12  label:OMFGZ  

omfgz.png

pixelsoup

Page 25: Textorize

(cc) Luís Flávio Loureiro dos Santos

Page 26: Textorize

(cc) Luís Flávio Loureiro dos Santos

Page 28: Textorize

textorize

textorize.rb  -­‐f"Consolas"  -­‐s12  "OMFGZ"

Page 29: Textorize

textorize

textorize.rb  -­‐f"Consolas"  -­‐s12  "OMFGZ"

sub-pixel AA

Page 30: Textorize

textorize

textorize.rb  -­‐f"Consolas"  -­‐s12  "OMFGZ"

proper kerning

Page 31: Textorize

textorize

CLIuses installed

fonts

Page 32: Textorize

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.run        end            end

   class  RunnerApplication  <  OSX::NSObject        include  OSX        attr_accessor  :options        attr_accessor  :string        attr_accessor  :output

       def  initialize            @window  =  NSWindow.alloc.initWithContentRect_styleMask_backing_defer([150,  1500,  1000,  500],  NSBorderlessWindowMask,  2,  0)        end                def  applicationDidFinishLaunching(notification)            renderer  =  Renderer.new(@window,  @string,  @options)            Saver.new(renderer).write_to_file(@output)            NSApplication.sharedApplication.terminate(nil)        end            end

end

Page 33: Textorize

@text_view  =  NSTextView.alloc.initWithFrame([0,0,1000,100])            set_attribs  optionswindow.setContentView  @text_view@text_view.setString  string@text_view.sizeToFit            window.displaywindow.orderFrontRegardless

Page 34: Textorize

bitmap  =  NSBitmapImageRep.alloc.initWithFocusedViewRect(@text_view.bounds)

Page 35: Textorize

@png  =  bitmap.representationUsingType_properties(NSPNGFileType,  nil)@png.writeToFile_atomically(file,  true)

Page 36: Textorize
Page 37: Textorize

major annoyances (could be fixed)

needs background color (or no subpixel AA)

no text selection (IMHO a feature, not a bug)

not searchable

Page 38: Textorize

http://script.aculo.us/thomas

http://github.com/madrobby/textorize