<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>HACKING</filename>
    </added>
    <added>
      <filename>bugs/resolved/canvas_sets_y_to_0.rb</filename>
    </added>
    <added>
      <filename>bugs/resolved/table_ignores_align_headers.rb</filename>
    </added>
    <added>
      <filename>bugs/resolved/table_suppress_newline.rb</filename>
    </added>
    <added>
      <filename>data/encodings/win_ansi.txt</filename>
    </added>
    <added>
      <filename>data/images/fractal.jpg</filename>
    </added>
    <added>
      <filename>data/images/letterhead.jpg</filename>
    </added>
    <added>
      <filename>examples/background.rb</filename>
    </added>
    <added>
      <filename>examples/cmyk.rb</filename>
    </added>
    <added>
      <filename>examples/euro.rb</filename>
    </added>
    <added>
      <filename>examples/font_calculations.rb</filename>
    </added>
    <added>
      <filename>examples/image_fit.rb</filename>
    </added>
    <added>
      <filename>examples/image_position.rb</filename>
    </added>
    <added>
      <filename>examples/measurement_units.rb</filename>
    </added>
    <added>
      <filename>examples/padded_box.rb</filename>
    </added>
    <added>
      <filename>examples/position_by_baseline.rb</filename>
    </added>
    <added>
      <filename>examples/stroke_bounds.rb</filename>
    </added>
    <added>
      <filename>examples/table_alignment.rb</filename>
    </added>
    <added>
      <filename>examples/table_border_color.rb</filename>
    </added>
    <added>
      <filename>examples/table_colspan.rb</filename>
    </added>
    <added>
      <filename>examples/table_header_color.rb</filename>
    </added>
    <added>
      <filename>examples/table_header_underline.rb</filename>
    </added>
    <added>
      <filename>examples/text_box.rb</filename>
    </added>
    <added>
      <filename>examples/win_ansi_charset.rb</filename>
    </added>
    <added>
      <filename>lib/prawn/document/annotations.rb</filename>
    </added>
    <added>
      <filename>lib/prawn/document/destinations.rb</filename>
    </added>
    <added>
      <filename>lib/prawn/document/text/box.rb</filename>
    </added>
    <added>
      <filename>lib/prawn/encoding.rb</filename>
    </added>
    <added>
      <filename>lib/prawn/literal_string.rb</filename>
    </added>
    <added>
      <filename>lib/prawn/measurement_extensions.rb</filename>
    </added>
    <added>
      <filename>lib/prawn/measurements.rb</filename>
    </added>
    <added>
      <filename>lib/prawn/name_tree.rb</filename>
    </added>
    <added>
      <filename>spec/annotations_spec.rb</filename>
    </added>
    <added>
      <filename>spec/destinations_spec.rb</filename>
    </added>
    <added>
      <filename>spec/measurement_units_spec.rb</filename>
    </added>
    <added>
      <filename>spec/name_tree_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/ttfunk</filename>
    </added>
    <added>
      <filename>www/twilight.css</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,6 @@
 [submodule &quot;vendor/pdf-inspector&quot;]
 	path = vendor/pdf-inspector
 	url = git://github.com/sandal/pdf-inspector.git
+[submodule &quot;vendor/ttfunk&quot;]
+	path = vendor/ttfunk
+	url = git://github.com/sandal/ttfunk.git</diff>
      <filename>.gitmodules</filename>
    </modified>
    <modified>
      <diff>@@ -12,6 +12,9 @@ Website:
 
 http://prawn.majesticseacreature.com
 
+Examples:
+http://github.com/sandal/prawn/tree/master/examples
+
 Bug Tracker / Wiki:
 
 http://prawn.lighthouseapp.com/projects/9398-prawn/home
@@ -34,7 +37,7 @@ NOTES TO DEVELOPERS:
 
 You will need the pdf-reader and test-spec gems to run Prawn.  Be sure to run
 the specs on both Ruby 1.8.6 and the latest Ruby 1.9 snapshot, as both versions
-are supported.  1.8.7 is *not* officially supported.
+are supported.  1.8.7 is not officially supported.
 
 Prawn relies on PDF::Inspector, a collection of PDF::Reader backed classes
 for analyzing PDF output.  This is provided as a submodule in Prawn's git</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -53,6 +53,19 @@ task :examples do
 
 end
 
+task :generate do
+  if File.exists?(&quot;examples/#{ENV['example']}.rb&quot;)
+    puts &quot;Example already exists&quot;
+  else
+    File.open(&quot;examples/#{ENV['example']}.rb&quot;, &quot;w&quot;) do |f|
+      f &lt;&lt; [&quot;$LOAD_PATH &lt;&lt; File.join(File.dirname(__FILE__), '..', 'lib')&quot;,
+            &quot;require 'prawn'\n&quot;,
+            &quot;Prawn::Document.generate('#{ENV['example']}.pdf') do\n\nend&quot;].join(&quot;\n&quot;)
+    end
+    sh &quot;git add examples/#{ENV['example']}.rb&quot;
+  end
+end
+
 spec = Gem::Specification.new do |spec|
   spec.name = &quot;prawn&quot;
   spec.version = PRAWN_VERSION</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -4,14 +4,16 @@ require 'prawn'
 Prawn::Document.generate(&quot;bounding_boxes.pdf&quot;) do   
       
   bounding_box [100,600], :width =&gt; 200 do
+    move_down 10
     text &quot;The rain in spain falls mainly on the plains &quot; * 5
+    move_down 20
     stroke do
       line bounds.top_left,    bounds.top_right
       line bounds.bottom_left, bounds.bottom_right
     end
   end
 
-  bounding_box [100,500], :width =&gt; 200, :height =&gt; 200 do
+  bounding_box [100,cursor], :width =&gt; 200, :height =&gt; 200 do
     stroke do
       circle_at [100,100], :radius =&gt; 100
       line bounds.top_left, bounds.bottom_right
@@ -23,7 +25,9 @@ Prawn::Document.generate(&quot;bounding_boxes.pdf&quot;) do
     end   
   end
       
-end        
+end     
+
+`open bounding_boxes.pdf`   
      
                  
                  </diff>
      <filename>examples/bounding_boxes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,7 @@ Prawn::Document.generate(&quot;cell.pdf&quot;) do
     :text =&gt; &quot;You know that kittens are made of mud!&quot;, :document =&gt; self)
   cell2 = Prawn::Graphics::Cell.new(
     :border_width =&gt; 3, :padding =&gt; 10,
-    :text =&gt; &quot;And that puppies are made of gravy&quot;, :document =&gt; self)
+    :text =&gt; &quot;And that puppies are made of gravy&quot;, :document =&gt; self, :font_size =&gt; 9)
   cell3 = Prawn::Graphics::Cell.new(
     :border_width =&gt; 3, :padding =&gt; 10, :width =&gt; 100, 
     :text =&gt; &quot;This is simply the way of the world&quot;, :document =&gt; self)</diff>
      <filename>examples/cell.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,6 +19,8 @@ ruby_19 do
 end
                                                                                   
 Prawn::Document.generate(&quot;fancy_table.pdf&quot;, :page_layout =&gt; :landscape) do
+  
+  #font &quot;#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf&quot;
 
   mask(:y) { table body, :headers      =&gt; headers, 
                          :align        =&gt; :center,</diff>
      <filename>examples/fancy_table.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,5 +15,13 @@ Prawn::Document.generate &quot;font_size.pdf&quot;, :page_size =&gt; &quot;A4&quot; do
     text 'Font at 9 point'
   end
   
+  font(&quot;Times-Roman&quot;, :style =&gt; :italic, :size =&gt; 12) do
+    text &quot;Font in times at 12&quot;
+    font.size(16) { text &quot;Font in Times at 16&quot; }
+  end
+  
   text 'Font at 16 point'
-end
+  
+  font &quot;Courier&quot;, :size =&gt; 40
+  text &quot;40 pt!&quot;
+end
\ No newline at end of file</diff>
      <filename>examples/font_size.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,26 +3,31 @@
 $LOAD_PATH &lt;&lt; File.join(File.dirname(__FILE__), '..', 'lib')
 require &quot;prawn&quot;
    
-Prawn::Document.generate(&quot;image-flow.pdf&quot;, :page_layout =&gt; :landscape) do                             
+Prawn::Document.generate(&quot;image-flow.pdf&quot;, :page_layout =&gt; :landscape) do  
+  font.size = 8                           
   stef = &quot;#{Prawn::BASEDIR}/data/images/stef.jpg&quot;  
   
-  text &quot;o hai&quot;
+  text &quot;Image at default position with no arguments&quot;
+  
+  move_down 10
   
   image stef 
   
-  text &quot;flowing text&quot; 
+  text &quot;Centered image flowing&quot; 
   
   image stef, :position =&gt; :center   
   
-  text &quot;beneath images&quot;
+  text &quot;Right aligned image flowing&quot;
                  
   image stef, :position =&gt; :right  
   
-  text &quot;again&quot;
+  text &quot;Explicitly left aligned image flowing&quot;
+                 
+  move_down 10                 
                  
   image stef, :position =&gt; :left     
   
-  text &quot;and again&quot;     
+  text &quot;Flowing image at x=50&quot;     
   
   image stef, :position =&gt; 50
   </diff>
      <filename>examples/image_flow.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,6 +12,7 @@ Prawn::Document.generate(&quot;ruport.pdf&quot;) do
   pad(50) { text &quot;I'm Padded&quot; }
   text &quot;I'm far away&quot;
   stroke_horizontal_line 50, 100
-  stroke_vertical_line_at 300, 50, 250
+  stroke_horizontal_line 50, 100, :at =&gt; 300
+  stroke_vertical_line 300, 50, :at =&gt; 250
 
 end</diff>
      <filename>examples/ruport_helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,7 +20,7 @@ def recurse_bounding_box(pdf, max_depth=5, depth=1)
   left_top_corners = [5, box.right-width-5].combine [box.top-5, height+5]
   left_top_corners.each do |lt|
     pdf.bounding_box(lt, :width=&gt;width, :height=&gt;height) do
-      pdf.stroke_rectangle [0,height], width, height
+      pdf.stroke_bounds
       recurse_bounding_box(pdf, max_depth, depth+1) if depth&lt;max_depth
     end
   end
@@ -30,5 +30,3 @@ end
 Prawn::Document.generate(&quot;russian_boxes.pdf&quot;) do |pdf|
   recurse_bounding_box(pdf)
 end
-
-</diff>
      <filename>examples/russian_boxes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ require &quot;prawn&quot;
 
 Prawn::Document.generate &quot;hello.pdf&quot; do       
   fill_color &quot;0000ff&quot;
-  text &quot;Hello World&quot;, :at =&gt; [200,720], :size =&gt; 32       
+  text &quot;Hello World&quot;, :at =&gt; [200,420], :size =&gt; 32, :rotate =&gt; 45
   font &quot;Times-Roman&quot;     
   fill_color &quot;ff0000&quot;
   text &quot;Overcoming singular font limitation&quot;, :at =&gt; [5,5]    </diff>
      <filename>examples/simple_text.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ require &quot;prawn&quot;
 Prawn::Document.generate &quot;hello-ttf.pdf&quot; do       
   fill_color &quot;0000ff&quot;
   font &quot;#{Prawn::BASEDIR}/data/fonts/comicsans.ttf&quot; 
-  text &quot;Hello World&quot;, :at =&gt; [200,720], :size =&gt; 32           
+  text &quot;Hello World&quot;, :at =&gt; [200,720], :size =&gt; 32         
 
   font &quot;#{Prawn::BASEDIR}/data/fonts/Chalkboard.ttf&quot;
 </diff>
      <filename>examples/simple_text_ttf.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,37 +1,41 @@
 # encoding: utf-8
-
+ 
 # prawn.rb : A library for PDF generation in Ruby
 #
-# Copyright April 2008, Gregory Brown.  All Rights Reserved.
+# Copyright April 2008, Gregory Brown. All Rights Reserved.
 #
 # This is free software. Please see the LICENSE and COPYING files for details.
            
-%w[font_ttf].each do |dep|
+%w[ttfunk/lib].each do |dep|
   $LOAD_PATH.unshift(File.dirname(__FILE__) + &quot;/../vendor/#{dep}&quot;)
 end
-
-require 'ttf'
-
-module Prawn 
+ 
+require 'ttfunk'
+ 
+module Prawn
   file = __FILE__
   file = File.readlink(file) if File.symlink?(file)
   dir = File.dirname(file)
                           
   # The base source directory for Prawn as installed on the system
-  BASEDIR = File.expand_path(File.join(dir, '..'))  
+  BASEDIR = File.expand_path(File.join(dir, '..'))
   
-  VERSION = &quot;0.2.3.99&quot;
+  VERSION = &quot;0.3.0&quot;
   
   extend self
   
-  def verify_options(accepted,actual) #:nodoc:                    
+  attr_accessor :debug
+  
+  def verify_options(accepted,actual) #:nodoc:
+    return unless debug || $DEBUG
     require &quot;set&quot;
     unless (act=Set[*actual.keys]).subset?(acc=Set[*accepted])
-      raise Prawn::Errors::UnknownOption, 
+      raise Prawn::Errors::UnknownOption,
         &quot;\nDetected unknown option(s): #{(act - acc).to_a.inspect}\n&quot; &lt;&lt;
         &quot;Accepted options are: #{accepted.inspect}&quot;
-    end    
-  end      
+    end
+    yield if block_given?
+  end
   
   module Configurable #:nodoc:
     def configuration(*args)
@@ -41,16 +45,16 @@ module Prawn
       elsif args.length &gt; 1
         @config.values_at(*args)
       elsif args.length == 1
-        @config[args[0]] 
-      else 
-        @config  
+        @config[args[0]]
+      else
+        @config
       end
-    end     
+    end
     
     alias_method :C, :configuration
   end
-end                                                 
-
+end
+ 
 require &quot;prawn/compatibility&quot;
 require &quot;prawn/errors&quot;
 require &quot;prawn/pdf_object&quot;
@@ -60,4 +64,6 @@ require &quot;prawn/images/jpg&quot;
 require &quot;prawn/images/png&quot;
 require &quot;prawn/document&quot;
 require &quot;prawn/reference&quot;
-require &quot;prawn/font&quot;
\ No newline at end of file
+require &quot;prawn/font&quot;
+require &quot;prawn/encoding&quot;
+require &quot;prawn/measurements&quot;
\ No newline at end of file</diff>
      <filename>lib/prawn.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,19 +9,23 @@
 require &quot;stringio&quot;
 require &quot;prawn/document/page_geometry&quot; 
 require &quot;prawn/document/bounding_box&quot;
-require &quot;prawn/document/text&quot;      
+require &quot;prawn/document/text&quot;
 require &quot;prawn/document/table&quot;
 require &quot;prawn/document/internals&quot;
 require &quot;prawn/document/span&quot;
+require &quot;prawn/document/annotations&quot;
+require &quot;prawn/document/destinations&quot;
 
 module Prawn
   class Document  
            
     include Prawn::Document::Internals
-    include Prawn::Graphics    
+    include Prawn::Document::Annotations
+    include Prawn::Document::Destinations
+    include Prawn::Graphics
     include Prawn::Images
-    include Text                             
-    include PageGeometry                             
+    include Text
+    include PageGeometry
     
     attr_accessor :y, :margin_box
     attr_reader   :margins, :page_size, :page_layout
@@ -65,6 +69,7 @@ module Prawn
     # &lt;tt&gt;:bottom_margin&lt;/tt&gt;:: Sets the bottom margin in points [0.5 inch]
     # &lt;tt&gt;:skip_page_creation&lt;/tt&gt;:: Creates a document without starting the first page [false]
     # &lt;tt&gt;:compress&lt;/tt&gt;:: Compresses content streams before rendering them [false]
+    # &lt;tt&gt;:background&lt;/tt&gt;:: An image path to be used as background on all pages [nil]
     # 
     # Usage:
     #                             
@@ -74,19 +79,23 @@ module Prawn
     #   # New document, A4 paper, landscaped
     #   pdf = Prawn::Document.new(:page_size =&gt; &quot;A4&quot;, :page_layout =&gt; :landscape)    
     #
+    #   # New document, with background
+    #   pdf = Prawn::Document.new(:background =&gt; &quot;#{Prawn::BASEDIR}/data/images/pigs.jpg&quot;)    
+    #
     def initialize(options={},&amp;block)   
        Prawn.verify_options [:page_size, :page_layout, :left_margin, 
          :right_margin, :top_margin, :bottom_margin, :skip_page_creation, 
-         :compress, :skip_encoding, :text_options ], options
+         :compress, :skip_encoding, :text_options, :background ], options
          
        @objects = []
        @info    = ref(:Creator =&gt; &quot;Prawn&quot;, :Producer =&gt; &quot;Prawn&quot;)
-       @pages   = ref(:Type =&gt; :Pages, :Count =&gt; 0, :Kids =&gt; [])  
-       @root    = ref(:Type =&gt; :Catalog, :Pages =&gt; @pages)        
+       @pages   = ref(:Type =&gt; :Pages, :Count =&gt; 0, :Kids =&gt; [])
+       @root    = ref(:Type =&gt; :Catalog, :Pages =&gt; @pages)
        @page_size       = options[:page_size]   || &quot;LETTER&quot;    
        @page_layout     = options[:page_layout] || :portrait
        @compress        = options[:compress] || false                
        @skip_encoding   = options[:skip_encoding]
+       @background      = options[:background]
        
        text_options.update(options[:text_options] || {}) 
              
@@ -132,7 +141,9 @@ module Prawn
      
        add_content &quot;q&quot;   
        
-       @y = @bounding_box.absolute_top        
+       @y = @bounding_box.absolute_top
+       
+       image(@background, :at =&gt; [0,@y]) if @background
     end             
       
     # Returns the number of pages in the document
@@ -145,6 +156,13 @@ module Prawn
     def page_count
       @pages.data[:Count]
     end
+    
+    # The current y drawing position relative to the innermost bounding box,
+    # or to the page margins at the top level.  
+    #
+    def cursor
+      y - bounds.absolute_bottom
+    end
        
     # Renders the PDF document to string
     #
@@ -268,7 +286,7 @@ module Prawn
                           :Parent    =&gt; @pages, 
                           :MediaBox  =&gt; page_dimensions, 
                           :Contents  =&gt; @page_content)
-      font.add_to_current_page if @font_name  
+      font.add_to_current_page if @font
       update_colors
     end
     </diff>
      <filename>lib/prawn/document.rb</filename>
    </modified>
    <modified>
      <diff>@@ -135,6 +135,15 @@ module Prawn
         ) 
       end
     end  
+    
+    # A bounding box with the same dimensions of its parents, minus a margin
+    # on all sides
+    #
+    def padded_box(margin, &amp;block)
+      bounding_box [bounds.left + margin, bounds.top - margin],
+        :width  =&gt; bounds.width - (margin * 2), 
+        :height =&gt; bounds.height - (margin * 2), &amp;block 
+    end
        
     # A header is a LazyBoundingBox drawn relative to the margins that can be
     # repeated on every page of the document.</diff>
      <filename>lib/prawn/document/bounding_box.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,6 @@ module Prawn
     # are you won't need anything you find here.  
     #
     module Internals    
-      
       # Creates a new Prawn::Reference and adds it to the Document's object
       # list.  The +data+ argument is anything that Prawn::PdfObject() can convert.    
       def ref(data)
@@ -50,6 +49,13 @@ module Prawn
         page_resources[:XObject] ||= {}
       end  
       
+      # The Name dictionary (PDF spec 3.6.3) for this document. It is
+      # lazily initialized, so that documents that do not need a name
+      # dictionary do not incur the additional overhead.
+      def names
+        @root.data[:Names] ||= ref(:Type =&gt; :Names)
+      end
+
       private      
       
       def finish_page_content     
@@ -104,4 +110,4 @@ module Prawn
                  
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>lib/prawn/document/internals.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,70 +9,71 @@
 module Prawn
   class Document
     module PageGeometry
-          
+
       # Dimensions pulled from PDF::Writer, rubyforge.org/projects/ruby-pdf
-      SIZES = { &quot;4A0&quot; =&gt; [4767.87, 6740.79], 
-                &quot;2A0&quot; =&gt; [3370.39, 4767.87], 
-                 &quot;A0&quot; =&gt; [2383.94, 3370.39], 
-                 &quot;A1&quot; =&gt; [1683.78, 2383.94], 
-                 &quot;A2&quot; =&gt; [1190.55, 1683.78], 
-                 &quot;A3&quot; =&gt; [841.89, 1190.55], 
-                 &quot;A4&quot; =&gt; [595.28, 841.89], 
-                 &quot;A5&quot; =&gt; [419.53, 595.28], 
-                 &quot;A6&quot; =&gt; [297.64, 419.53], 
-                 &quot;A7&quot; =&gt; [209.76, 297.64], 
-                 &quot;A8&quot; =&gt; [147.40, 209.76], 
-                 &quot;A9&quot; =&gt; [104.88, 147.40], 
-                &quot;A10&quot; =&gt; [73.70, 104.88], 
-                 &quot;B0&quot; =&gt; [2834.65, 4008.19], 
-                 &quot;B1&quot; =&gt; [2004.09, 2834.65], 
-                 &quot;B2&quot; =&gt; [1417.32, 2004.09], 
-                 &quot;B3&quot; =&gt; [1000.63, 1417.32], 
-                 &quot;B4&quot; =&gt; [708.66, 1000.63], 
-                 &quot;B5&quot; =&gt; [498.90, 708.66], 
-                 &quot;B6&quot; =&gt; [354.33, 498.90], 
-                 &quot;B7&quot; =&gt; [249.45, 354.33], 
-                 &quot;B8&quot; =&gt; [175.75, 249.45], 
-                 &quot;B9&quot; =&gt; [124.72, 175.75], 
-                &quot;B10&quot; =&gt; [87.87, 124.72], 
-                 &quot;C0&quot; =&gt; [2599.37, 3676.54], 
-                 &quot;C1&quot; =&gt; [1836.85, 2599.37], 
-                 &quot;C2&quot; =&gt; [1298.27, 1836.85], 
-                 &quot;C3&quot; =&gt; [918.43, 1298.27], 
-                 &quot;C4&quot; =&gt; [649.13, 918.43], 
-                 &quot;C5&quot; =&gt; [459.21, 649.13], 
-                 &quot;C6&quot; =&gt; [323.15, 459.21], 
-                 &quot;C7&quot; =&gt; [229.61, 323.15], 
-                 &quot;C8&quot; =&gt; [161.57, 229.61], 
-                 &quot;C9&quot; =&gt; [113.39, 161.57], 
-                &quot;C10&quot; =&gt; [79.37, 113.39], 
-                &quot;RA0&quot; =&gt; [2437.80, 3458.27], 
-                &quot;RA1&quot; =&gt; [1729.13, 2437.80], 
-                &quot;RA2&quot; =&gt; [1218.90, 1729.13], 
-                &quot;RA3&quot; =&gt; [864.57, 1218.90], 
-                &quot;RA4&quot; =&gt; [609.45, 864.57], 
-               &quot;SRA0&quot; =&gt; [2551.18, 3628.35], 
-               &quot;SRA1&quot; =&gt; [1814.17, 2551.18], 
-               &quot;SRA2&quot; =&gt; [1275.59, 1814.17], 
-               &quot;SRA3&quot; =&gt; [907.09, 1275.59], 
-               &quot;SRA4&quot; =&gt; [637.80, 907.09], 
-             &quot;LETTER&quot; =&gt; [612.00, 792.00], 
-              &quot;LEGAL&quot; =&gt; [612.00, 1008.00], 
-              &quot;FOLIO&quot; =&gt; [612.00, 936.00], 
-          &quot;EXECUTIVE&quot; =&gt; [521.86, 756.00] }
-     
+      SIZES = { &quot;4A0&quot; =&gt; [4767.87, 6740.79],
+                &quot;2A0&quot; =&gt; [3370.39, 4767.87],
+                 &quot;A0&quot; =&gt; [2383.94, 3370.39],
+                 &quot;A1&quot; =&gt; [1683.78, 2383.94],
+                 &quot;A2&quot; =&gt; [1190.55, 1683.78],
+                 &quot;A3&quot; =&gt; [841.89, 1190.55],
+                 &quot;A4&quot; =&gt; [595.28, 841.89],
+                 &quot;A5&quot; =&gt; [419.53, 595.28],
+                 &quot;A6&quot; =&gt; [297.64, 419.53],
+                 &quot;A7&quot; =&gt; [209.76, 297.64],
+                 &quot;A8&quot; =&gt; [147.40, 209.76],
+                 &quot;A9&quot; =&gt; [104.88, 147.40],
+                &quot;A10&quot; =&gt; [73.70, 104.88],
+                 &quot;B0&quot; =&gt; [2834.65, 4008.19],
+                 &quot;B1&quot; =&gt; [2004.09, 2834.65],
+                 &quot;B2&quot; =&gt; [1417.32, 2004.09],
+                 &quot;B3&quot; =&gt; [1000.63, 1417.32],
+                 &quot;B4&quot; =&gt; [708.66, 1000.63],
+                 &quot;B5&quot; =&gt; [498.90, 708.66],
+                 &quot;B6&quot; =&gt; [354.33, 498.90],
+                 &quot;B7&quot; =&gt; [249.45, 354.33],
+                 &quot;B8&quot; =&gt; [175.75, 249.45],
+                 &quot;B9&quot; =&gt; [124.72, 175.75],
+                &quot;B10&quot; =&gt; [87.87, 124.72],
+                 &quot;C0&quot; =&gt; [2599.37, 3676.54],
+                 &quot;C1&quot; =&gt; [1836.85, 2599.37],
+                 &quot;C2&quot; =&gt; [1298.27, 1836.85],
+                 &quot;C3&quot; =&gt; [918.43, 1298.27],
+                 &quot;C4&quot; =&gt; [649.13, 918.43],
+                 &quot;C5&quot; =&gt; [459.21, 649.13],
+                 &quot;C6&quot; =&gt; [323.15, 459.21],
+                 &quot;C7&quot; =&gt; [229.61, 323.15],
+                 &quot;C8&quot; =&gt; [161.57, 229.61],
+                 &quot;C9&quot; =&gt; [113.39, 161.57],
+                &quot;C10&quot; =&gt; [79.37, 113.39],
+                &quot;RA0&quot; =&gt; [2437.80, 3458.27],
+                &quot;RA1&quot; =&gt; [1729.13, 2437.80],
+                &quot;RA2&quot; =&gt; [1218.90, 1729.13],
+                &quot;RA3&quot; =&gt; [864.57, 1218.90],
+                &quot;RA4&quot; =&gt; [609.45, 864.57],
+               &quot;SRA0&quot; =&gt; [2551.18, 3628.35],
+               &quot;SRA1&quot; =&gt; [1814.17, 2551.18],
+               &quot;SRA2&quot; =&gt; [1275.59, 1814.17],
+               &quot;SRA3&quot; =&gt; [907.09, 1275.59],
+               &quot;SRA4&quot; =&gt; [637.80, 907.09],
+          &quot;EXECUTIVE&quot; =&gt; [521.86, 756.00],
+              &quot;FOLIO&quot; =&gt; [612.00, 936.00],
+              &quot;LEGAL&quot; =&gt; [612.00, 1008.00],
+             &quot;LETTER&quot; =&gt; [612.00, 792.00],
+            &quot;TABLOID&quot; =&gt; [792.00, 1224.00] }
+
       def page_dimensions #:nodoc:
         coords = SIZES[page_size] || page_size
-        [0,0] + case(page_layout)   
+        [0,0] + case(page_layout)
         when :portrait
           coords
         when :landscape
-          coords.reverse 
-        else 
-          raise Prawn::Errors::InvalidPageLayout, 
+          coords.reverse
+        else
+          raise Prawn::Errors::InvalidPageLayout,
             &quot;Layout must be either :portrait or :landscape&quot;
         end
-      end 
-    end     
+      end
+    end
   end
 end</diff>
      <filename>lib/prawn/document/page_geometry.rb</filename>
    </modified>
    <modified>
      <diff>@@ -37,7 +37,14 @@ module Prawn
     #
     #   end
     #
+    #   Will raise &lt;tt&gt;Prawn::Errors::EmptyTable&lt;/tt&gt; given 
+    #   a nil or empty &lt;tt&gt;data&lt;/tt&gt; paramater.
+    #
     def table(data,options={})           
+      if data.nil? || data.empty?
+        raise Prawn::Errors::EmptyTable,
+          &quot;data must be a non-empty, non-nil, two dimensional array of Prawn::Cells or strings&quot;
+      end
       Prawn::Document::Table.new(data,self,options).draw
     end
 
@@ -85,12 +92,13 @@ module Prawn
       # &lt;tt&gt;:vertical_padding&lt;/tt&gt;:: The vertical cell padding in PDF points [5]
       # &lt;tt&gt;:padding&lt;/tt&gt;:: Horizontal and vertical cell padding (overrides both)
       # &lt;tt&gt;:border_width&lt;/tt&gt;:: With of border lines in PDF points [1]
-      # &lt;tt&gt;:border_style&lt;/tt&gt;:: If set to :grid, fills in all borders.  Otherwise, borders are drawn on columns only, not rows
+      # &lt;tt&gt;:border_style&lt;/tt&gt;:: If set to :grid, fills in all borders. If set to :underline_header, underline header only. Otherwise, borders are drawn on columns only, not rows
       # &lt;tt&gt;:position&lt;/tt&gt;:: One of &lt;tt&gt;:left&lt;/tt&gt;, &lt;tt&gt;:center&lt;/tt&gt; or &lt;tt&gt;n&lt;/tt&gt;, where &lt;tt&gt;n&lt;/tt&gt; is an x-offset from the left edge of the current bounding box
       # &lt;tt&gt;:widths:&lt;/tt&gt; A hash of indices and widths in PDF points.  E.g. &lt;tt&gt;{ 0 =&gt; 50, 1 =&gt; 100 }&lt;/tt&gt;
       # &lt;tt&gt;:row_colors&lt;/tt&gt;:: An array of row background colors which are used cyclicly.   
       # &lt;tt&gt;:align&lt;/tt&gt;:: Alignment of text in columns, for entire table (&lt;tt&gt;:center&lt;/tt&gt;) or by column (&lt;tt&gt;{ 0 =&gt; :left, 1 =&gt; :center}&lt;/tt&gt;)
-      # &lt;tt&gt;:align_headers&lt;/tt&gt;:: Alignment of header text.
+      # &lt;tt&gt;:align_headers&lt;/tt&gt;:: Alignment of header text.  Specify for entire header (&lt;tt&gt;:left&lt;/tt&gt;) or by column (&lt;tt&gt;{ 0 =&gt; :right, 1 =&gt; :left}&lt;/tt&gt;). If omitted, the header alignment is the same as the column alignment.
+      # &lt;tt&gt;:minimum_rows&lt;/tt&gt;:: The minimum rows to display on a page, including header.
       #
       # Row colors are specified as html encoded values, e.g.
       # [&quot;ffffff&quot;,&quot;aaaaaa&quot;,&quot;ccaaff&quot;].  You can also specify 
@@ -110,8 +118,9 @@ module Prawn
         @document = document
         
         Prawn.verify_options [:font_size,:border_style, :border_width,
-         :position, :headers, :row_colors, :align, :align_headers, 
-         :horizontal_padding, :vertical_padding, :padding, :widths ], options     
+         :position, :headers, :row_colors, :align, :align_headers, :header_text_color, :border_color,
+         :horizontal_padding, :vertical_padding, :padding, :widths, 
+         :header_color ], options     
                                             
         configuration.update(options)  
 
@@ -193,10 +202,12 @@ module Prawn
         @document.font.size C(:font_size) do
           renderable_data.each_with_index do |row,index|
             c = Prawn::Graphics::CellBlock.new(@document)
-            row.each_with_index do |e,i|     
+            
+            col_index = 0
+            row.each do |e|
               case C(:align)
               when Hash
-                align            = C(:align)[i]
+                align            = C(:align)[col_index]
               else
                 align            = C(:align)
               end   
@@ -207,7 +218,7 @@ module Prawn
               case e
               when Prawn::Graphics::Cell
                 e.document = @document
-                e.width    = @col_widths[i]
+                e.width    = @col_widths[col_index]
                 e.horizontal_padding = C(:horizontal_padding)
                 e.vertical_padding   = C(:vertical_padding)    
                 e.border_width       = C(:border_width)
@@ -215,28 +226,42 @@ module Prawn
                 e.align              = align 
                 c &lt;&lt; e
               else
+                text = e.is_a?(Hash) ? e[:text] : e.to_s
+                width = if e.is_a?(Hash) &amp;&amp; e.has_key?(:colspan)
+                  @col_widths.slice(col_index, e[:colspan]).inject { |sum, width| sum + width }
+                else
+                  @col_widths[col_index]
+                end
+                
                 c &lt;&lt; Prawn::Graphics::Cell.new(
                   :document =&gt; @document, 
-                  :text     =&gt; e.to_s, 
-                  :width    =&gt; @col_widths[i],
+                  :text     =&gt; text,
+                  :width    =&gt; width,
                   :horizontal_padding =&gt; C(:horizontal_padding),
                   :vertical_padding   =&gt; C(:vertical_padding),
                   :border_width       =&gt; C(:border_width),
                   :border_style       =&gt; :sides,
                   :align              =&gt; align ) 
-              end   
+              end
+              
+              col_index += (e.is_a?(Hash) &amp;&amp; e.has_key?(:colspan)) ? e[:colspan] : 1
             end
                                                 
             bbox = @parent_bounds.stretchy? ? @document.margin_box : @parent_bounds
             if c.height &gt; y_pos - bbox.absolute_bottom
-              draw_page(page_contents)
-              @document.start_new_page
-              if C(:headers)
-                page_contents = [page_contents[0]]
-                y_pos = @document.y - page_contents[0].height
-              else
-                page_contents = []
+              if C(:headers) &amp;&amp; page_contents.length == 1
+                @document.start_new_page
                 y_pos = @document.y
+              else
+                draw_page(page_contents)
+                @document.start_new_page
+                if C(:headers) &amp;&amp; page_contents.any?
+                  page_contents = [page_contents[0]]
+                  y_pos = @document.y - page_contents[0].height
+                else
+                  page_contents = []
+                  y_pos = @document.y
+                end
               end
             end
 
@@ -254,29 +279,50 @@ module Prawn
 
       def draw_page(contents)
         return if contents.empty?
-
-        if C(:border_style) == :grid || contents.length == 1
+ 
+        if C(:border_style) == :underline_header
+          contents.each { |e| e.border_style = :none }
+          contents.first.border_style = :bottom_only if C(:headers)
+        elsif C(:border_style) == :grid || contents.length == 1
           contents.each { |e| e.border_style = :all }
-        else                            
-          if C(:headers)
-            contents.first.border_style = :all 
-            contents.first.align        = C(:align_headers) || :left
-          else
-            contents.first.border_style  = :no_bottom    
+        else
+          contents.first.border_style = C(:headers) ? :all : :no_bottom
+          contents.last.border_style = :no_top
+        end
+        
+        if C(:headers)
+          contents.first.cells.each_with_index do |e,i|
+            if C(:align_headers)
+              case C(:align_headers)
+                when Hash
+                  align = C(:align_headers)[i]
+                else
+                  align = C(:align_headers)
+                end
+            end
+            e.align = align if align
+            e.text_color = C(:header_text_color) if C(:header_text_color)
+            e.background_color = C(:header_color) if C(:header_color)
           end
-          contents.last.border_style  = :no_top
         end
-
-        contents.each do |x| 
-          x.background_color = next_row_color if C(:row_colors)
+        
+        contents.each do |x|
+          unless x.background_color
+            x.background_color = next_row_color if C(:row_colors)
+          end
+          x.border_color = C(:border_color) if C(:border_color)
+          
           x.draw 
         end
-
+ 
         reset_row_colors
       end
 
+
       def next_row_color
-        C(:row_colors).unshift(C(:row_colors).pop).last
+        color = C(:row_colors).shift
+        C(:row_colors).push(color)
+        color
       end
 
       def reset_row_colors    </diff>
      <filename>lib/prawn/document/table.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,7 @@
 #
 # This is free software. Please see the LICENSE and COPYING files for details.
 require &quot;zlib&quot;
+require &quot;prawn/document/text/box&quot;
 
 module Prawn
   class Document
@@ -37,15 +38,39 @@ module Prawn
       # text will be kerned by default.  You can disable this feature by passing
       # &lt;tt&gt;:kerning =&gt; false&lt;/tt&gt;.
       #
-      # === Character Encoding Details: 
+      # === Text Positioning Details:
+      #
+      # FIXME: If we go with this of using ascender for TTF and font height
+      # For AFM, we need to document the sucker.
+      #
+      # When using the +:at+ parameter, Prawn will position your text by its
+      # baseline, and flow along a single line.
+      #
+      # When using automatic text flow, Prawn will position your text exactly
+      # font.height *below* the baseline, and space each line of text by 
+      # font.height + options[:spacing] (default 0)
+      #
+      # Finally, the drawing position will be moved to the baseline of final 
+      # line of text, plus any additional spacing.
+      #
+      # If you wish to position your flowing text by it's baseline rather
+      # than +font.height+ below, simply call &lt;tt&gt;move_up font.height&lt;/tt&gt; 
+      # before your call to text()
+      #
+      # == Rotation
+      #
+      # Text can be rotated before it is placed on the canvas by specifying the
+      # :rotate option. Rotation occurs counter-clockwise.
+      #
+      # == Encoding
       #
       # Note that strings passed to this function should be encoded as UTF-8.
       # If you get unexpected characters appearing in your rendered document, 
       # check this.
       #
       # If the current font is a built-in one, although the string must be
-      # encoded as UTF-8, only characters that are available in ISO-8859-1
-      # are allowed (transliteration will be attempted).
+      # encoded as UTF-8, only characters that are available in WinAnsi
+      # are allowed.
       #
       # If an empty box is rendered to your PDF instead of the character you 
       # wanted it usually means the current font doesn't include that character.
@@ -67,6 +92,9 @@ module Prawn
           x,y = translate(options[:at])            
           font.size(options[:size]) { add_text_content(text,x,y,options) }
         else
+          if options[:rotate]
+            raise ArgumentError, &quot;Rotated text may only be used with :at&quot; 
+          end
           wrapped_text(text,options)
         end         
 
@@ -86,7 +114,7 @@ module Prawn
       
       def process_text_options(options)
         Prawn.verify_options [:style, :kerning, :size, :at, :wrap, 
-                              :spacing, :align ], options                               
+                              :spacing, :align, :rotate ], options                               
         
         if options[:style]  
           raise &quot;Bad font family&quot; unless font.family
@@ -117,8 +145,12 @@ module Prawn
 
           lines = text.lines
                                                        
-          lines.each do |e|                                                   
-            move_text_position( font.height + font.descender )                                 
+          lines.each do |e|         
+            if font.metrics.type0?     
+              move_text_position(font.ascender)
+            else                                     
+              move_text_position(font.height) 
+            end                               
                            
             line_width = font.width_of(e)
             case(options[:align]) 
@@ -132,27 +164,33 @@ module Prawn
             end
                                
             add_text_content(e,x,y,options)
-            move_text_position(options[:spacing] || -font.descender )     
+            
+            if font.metrics.type0?
+              move_text_position(font.height - font.ascender)
+            end
+            
+            move_text_position(options[:spacing]) if options[:spacing]
           end 
         end
       end  
-      
+
       def add_text_content(text, x, y, options)
         text = font.metrics.convert_text(text,options)
 
-        add_content %Q{
-          BT
-          /#{font.identifier} #{font.size} Tf
-          #{x} #{y} Td
-        }  
-
+        add_content &quot;\nBT&quot;
+        add_content &quot;/#{font.identifier} #{font.size} Tf&quot;
+        if options[:rotate]
+          rad = options[:rotate].to_i * Math::PI / 180
+          arr = [ Math.cos(rad), Math.sin(rad), -Math.sin(rad), Math.cos(rad), x, y ]
+          add_content &quot;%.3f %.3f %.3f %.3f %.3f %.3f Tm&quot; % arr
+        else
+          add_content &quot;#{x} #{y} Td&quot;
+        end
+        rad = 1.570796
         add_content Prawn::PdfObject(text, true) &lt;&lt;
-          &quot; #{options[:kerning] ? 'TJ' : 'Tj'}\n&quot;
-
-        add_content %Q{
-          ET
-        }
-      end  
+          &quot; #{options[:kerning] ? 'TJ' : 'Tj'}&quot;
+        add_content &quot;ET\n&quot;
+      end
     end
   end
 end</diff>
      <filename>lib/prawn/document/text.rb</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,10 @@ module Prawn
      # This error is raised when table data is malformed
      #
      class InvalidTableData &lt; StandardError; end 
+
+     # This error is raised when an empty or nil table is rendered
+     #
+     class EmptyTable &lt; StandardError; end 
      
   end
 end   </diff>
      <filename>lib/prawn/errors.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,8 @@ require &quot;prawn/font/cmap&quot;
 module Prawn 
   
   class Document 
-    # Sets the current font.
+    # Without arguments, this returns the currently selected font. Otherwise,
+    # it sets the current font.
     #
     # The single parameter must be a string. It can be one of the 14 built-in
     # fonts supported by PDF, or the location of a TTF file. The BUILT_INS
@@ -22,19 +23,35 @@ module Prawn
     # more portable.
     #
     def font(name=nil, options={}) 
-      if name     
-        if font_families.key?(name)
-          ff = name                                                      
-          name = font_families[name][options[:style] || :normal]
-        end 
-        Prawn::Font.register(name,:for =&gt; self, :family =&gt; ff) unless font_registry[name]      
-        font_registry[name].add_to_current_page
-        @font_name = name   
-      elsif @font_name.nil?                                              
-        Prawn::Font.register(&quot;Helvetica&quot;, :for =&gt; self, :family =&gt; &quot;Helvetica&quot;) 
-        @font_name = &quot;Helvetica&quot;             
-      end  
-      font_registry[@font_name] 
+      return @font || font(&quot;Helvetica&quot;) if name.nil?
+
+      if block_given?
+        original_name = font.name
+        original_size = font.size
+      end
+      
+      @font = find_font(name, options)
+      @font.add_to_current_page
+     
+      @font.size = options[:size] if options[:size]
+      
+      if block_given?
+        yield
+        font(original_name, :size =&gt; original_size)
+      else
+        @font
+      end
+    end
+
+    # Looks up the given font name. Once a font has been found by that name,
+    # it will be cached to subsequent lookups for that font will return the
+    # same object.
+    def find_font(name, options={}) #:nodoc:
+      if font_families.key?(name)
+        family, name = name, font_families[name][options[:style] || :normal]
+      end
+
+      font_registry[name] ||= Font.new(name, options.merge(:for =&gt; self, :family =&gt; family))
     end      
        
     # Hash of Font objects keyed by names
@@ -94,10 +111,6 @@ module Prawn
                         
     DEFAULT_SIZE = 12
       
-    def self.register(name,options={})  #:nodoc:      
-       options[:for].font_registry[name] = Font.new(name,options)
-    end      
-    
     # The font metrics object  
     attr_reader   :metrics
     
@@ -125,16 +138,13 @@ module Prawn
       @document.proc_set :PDF, :Text  
       @size       = DEFAULT_SIZE
       @identifier = :&quot;F#{@document.font_registry.size + 1}&quot;  
-      
-      case(name)
-      when /\.ttf$/i
-        embed_ttf(name)
-      else
-        register_builtin(name)
-      end  
-      
-      add_to_current_page    
-    end      
+
+      @reference = nil
+    end     
+    
+    def inspect
+      &quot;Prawn::Font&lt; #{name}: #{size} &gt;&quot;
+    end
     
     # Sets the default font size for use within a block. Individual overrides
     # can be used as desired. The previous font size will be restored after the
@@ -166,6 +176,9 @@ module Prawn
         
     # Gets width of string in PDF points at current font size
     #
+    # If using an AFM, string *must* be encoded as WinAnsi 
+    # (Use normalize_encoding to convert)
+    # 
     def width_of(string)
       @metrics.string_width(string,@size)
     end     
@@ -173,6 +186,9 @@ module Prawn
     # Gets height of text in PDF points at current font size.
     # Text +:line_width+ must be specified in PDF points. 
     #
+    # If using an AFM, string *must* be encoded as WinAnsi 
+    # (Use normalize_encoding to convert)
+    #
     def height_of(text,options={}) 
       @metrics.string_height( text, :font_size  =&gt; @size, 
                                     :line_width =&gt; options[:line_width] ) 
@@ -195,6 +211,10 @@ module Prawn
     def descender 
       @metrics.descender / 1000.0 * @size
     end
+    
+    def line_gap
+      @metrics.line_gap / 1000.0 * @size
+    end
                            
     def normalize_encoding(text) # :nodoc:
       # check the string is encoded sanely
@@ -208,23 +228,25 @@ module Prawn
     end
                  
     def add_to_current_page #:nodoc:
+      embed! unless @reference
       @document.page_fonts.merge!(@identifier =&gt; @reference)
     end              
     
     private
-    
-    # built-in fonts only work with latin encoding, so translate the string
-    def normalize_builtin_encoding(text)
-      if text.respond_to?(:encode!)
-        text.encode!(&quot;ISO-8859-1&quot;)
+
+    def embed!
+      case(name)
+      when /\.ttf$/i
+        embed_ttf(name)
       else
-        require 'iconv'
-        text.replace Iconv.conv('ISO-8859-1//TRANSLIT', 'utf-8', text)
-      end
-    rescue
-      raise Prawn::Errors::IncompatibleStringEncoding, &quot;When using a &quot; +
-          &quot;builtin font, only characters that exist in &quot; +
-          &quot;WinAnsi/ISO-8859-1 are allowed.&quot;
+        register_builtin(name)
+      end  
+    end
+
+    # built-in fonts only work with winansi encoding, so translate the string
+    def normalize_builtin_encoding(text)
+      enc = Prawn::Encoding::WinAnsi.new
+      text.replace text.unpack(&quot;U*&quot;).collect { |i| enc[i] }.pack(&quot;C*&quot;)
     end
 
     def normalize_ttf_encoding(text)
@@ -275,7 +297,7 @@ module Prawn
 
       raise &quot;Can't detect a postscript name for #{file}&quot; if basename.nil?
 
-      @encodings = @metrics.enc_table
+      @encodings = @metrics.cmap
 
       if @encodings.nil?
         raise &quot;#{file} missing the required encoding table&quot;</diff>
      <filename>lib/prawn/font.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,6 +9,8 @@
 #
 # This is free software. Please see the LICENSE and COPYING files for details.
 
+require 'prawn/encoding'
+
 module Prawn
   class Font 
     class Metrics #:nodoc:
@@ -33,37 +35,6 @@ module Prawn
       end
 
       class Adobe &lt; Metrics #:nodoc:     
-         
-        ISOLatin1Encoding = %w[
-         .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
-         .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
-         .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
-         .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef space
-         exclam quotedbl numbersign dollar percent ampersand quoteright
-         parenleft parenright asterisk plus comma minus period slash zero one
-         two three four five six seven eight nine colon semicolon less equal
-         greater question at A B C D E F G H I J K L M N O P Q R S
-         T U V W X Y Z bracketleft backslash bracketright asciicircum
-         underscore quoteleft a b c d e f g h i j k l m n o p q r s
-         t u v w x y z braceleft bar braceright asciitilde .notdef .notdef
-         .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
-         .notdef .notdef .notdef .notdef .notdef .notdef .notdef dotlessi grave
-         acute circumflex tilde macron breve dotaccent dieresis .notdef ring
-         cedilla .notdef hungarumlaut ogonek caron space exclamdown cent
-         sterling currency yen brokenbar section dieresis copyright ordfeminine
-         guillemotleft logicalnot hyphen registered macron degree plusminus
-         twosuperior threesuperior acute mu paragraph periodcentered cedilla
-         onesuperior ordmasculine guillemotright onequarter onehalf threequarters
-         questiondown Agrave Aacute Acircumflex Atilde Adieresis Aring AE
-         Ccedilla Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex
-         Idieresis Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis
-         multiply Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn
-         germandbls agrave aacute acircumflex atilde adieresis aring ae
-         ccedilla egrave eacute ecircumflex edieresis igrave iacute icircumflex
-         idieresis eth ntilde ograve oacute ocircumflex otilde odieresis divide
-         oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis
-        ]    
-      
         attr_reader :attributes
                                   
         def initialize(font_name)            
@@ -85,7 +56,9 @@ module Prawn
         end   
 
         # calculates the width of the supplied string.
-        # String *must* be encoded as iso-8859-1
+        #
+        # String *must* be encoded as WinAnsi 
+        #
         def string_width(string, font_size, options = {}) 
           scale = font_size / 1000.0
           
@@ -107,7 +80,8 @@ module Prawn
         # converts a string into an array with spacing offsets
         # bewteen characters that need to be kerned
         #
-        # String *must* be encoded as iso-8859-1
+        # String *must* be encoded as WinAnsi
+        #
         def kern(string) 
           kerned = string.unpack(&quot;C*&quot;).inject([]) do |a,r|
             if a.last.is_a? Array
@@ -131,14 +105,14 @@ module Prawn
         
         def latin_kern_pairs_table   
           @kern_pairs_table ||= @kern_pairs.inject({}) do |h,p|
-            h[p[0].map { |n| ISOLatin1Encoding.index(n) }] = p[1]
+            h[p[0].map { |n| Encoding::WinAnsi::CHARACTERS.index(n) }] = p[1]
             h
           end
         end
  
         def latin_glyphs_table
           @glyphs_table ||= (0..255).map do |i|
-            @glyph_widths[ISOLatin1Encoding[i]].to_i
+            @glyph_widths[Encoding::WinAnsi::CHARACTERS[i]].to_i
           end 
         end
 
@@ -183,7 +157,7 @@ module Prawn
         # perform any changes to the string that need to happen
         # before it is rendered to the canvas
         #
-        # String *must* be encoded as iso-8859-1         
+        # String *must* be encoded as WinAnsi       
         #
         def convert_text(text, options={})
           options[:kerning] ? kern(text) : text
@@ -199,44 +173,45 @@ module Prawn
              @metrics_path.join(&quot;\n&quot;)
         end  
       
-        def parse_afm(file) 
+        def parse_afm(file_name) 
           section = []
-          
-          File.open(file,&quot;rb&quot;) do |file|
-            
-            file.each do |line| 
-              if line =~ /^Start(\w+)/
-                section.push $1
-                next
-              elsif line =~ /^End(\w+)/
-                section.pop
-                next
-              end
-              
-              if section == [&quot;FontMetrics&quot;, &quot;CharMetrics&quot;]
-                next unless line =~ /^CH?\s/  
-          
-                name                  = line[/\bN\s+(\.?\w+)\s*;/, 1]
-                @glyph_widths[name]   = line[/\bWX\s+(\d+)\s*;/, 1].to_i
-                @bounding_boxes[name] = line[/\bB\s+([^;]+);/, 1].to_s.rstrip
-              elsif section == [&quot;FontMetrics&quot;, &quot;KernData&quot;, &quot;KernPairs&quot;]
-                next unless line =~ /^KPX\s+(\.?\w+)\s+(\.?\w+)\s+(-?\d+)/
-                @kern_pairs[[$1, $2]] = $3.to_i
-              elsif section == [&quot;FontMetrics&quot;, &quot;KernData&quot;, &quot;TrackKern&quot;]
-                next
-              elsif section == [&quot;FontMetrics&quot;, &quot;Composites&quot;]
-                next
-              elsif line =~ /(^\w+)\s+(.*)/
-                key, value = $1.to_s.downcase, $2      
-              
-                @attributes[key] =  @attributes[key] ? 
-                  Array(@attributes[key]) &lt;&lt; value : value
-              else
-                warn &quot;Can't parse:  #{line}&quot;
-              end
+
+          File.foreach(file_name) do |line|        
+            case line
+            when /^Start(\w+)/
+              section.push $1
+              next
+            when /^End(\w+)/
+              section.pop
+              next
             end
-          end
-        end               
+
+            case section
+            when [&quot;FontMetrics&quot;, &quot;CharMetrics&quot;]
+              next unless line =~ /^CH?\s/  
+
+              name                  = line[/\bN\s+(\.?\w+)\s*;/, 1]
+              @glyph_widths[name]   = line[/\bWX\s+(\d+)\s*;/, 1].to_i
+              @bounding_boxes[name] = line[/\bB\s+([^;]+);/, 1].to_s.rstrip
+            when [&quot;FontMetrics&quot;, &quot;KernData&quot;, &quot;KernPairs&quot;]
+              next unless line =~ /^KPX\s+(\.?\w+)\s+(\.?\w+)\s+(-?\d+)/
+              @kern_pairs[[$1, $2]] = $3.to_i
+            when [&quot;FontMetrics&quot;, &quot;KernData&quot;, &quot;TrackKern&quot;], 
+              [&quot;FontMetrics&quot;, &quot;Composites&quot;]
+              next
+            else
+              parse_generic_afm_attribute(line)
+            end
+          end 
+        end
+
+        def parse_generic_afm_attribute(line)
+          line =~ /(^\w+)\s+(.*)/
+          key, value = $1.to_s.downcase, $2      
+
+          @attributes[key] =  @attributes[key] ? 
+          Array(@attributes[key]) &lt;&lt; value : value
+        end     
       end
 
       class TTF &lt; Metrics #:nodoc:  
@@ -244,18 +219,18 @@ module Prawn
         attr_accessor :ttf
         
         def initialize(font)
-          @ttf = ::Font::TTF::File.open(font,&quot;rb&quot;)
+          @ttf = TTFunk::File.new(font)
           @attributes       = {}
           @glyph_widths     = {}
           @bounding_boxes   = {} 
           @char_widths      = {}   
-          @has_kerning_data = !kern_pairs_table.empty?    
+          @has_kerning_data = !! @ttf.kern? &amp;&amp; @ttf.kern.sub_tables[0]
         end
 
         def cmap
-          @cmap ||= enc_table.charmaps
+          @cmap ||= @ttf.cmap.formats[4]
         end
-
+        
         def string_width(string, font_size, options = {})
           scale = font_size / 1000.0
           if options[:kerning]
@@ -298,9 +273,7 @@ module Prawn
               i = r.is_a?(Array) ? r.pack(&quot;U*&quot;) : r 
               x = if i.is_a?(String)
                 unicode_codepoints = i.unpack(&quot;U*&quot;)
-                glyph_codes = unicode_codepoints.map { |u| 
-                  enc_table.get_glyph_id_for_unicode(u)
-                }
+                glyph_codes = unicode_codepoints.map { |u| cmap[u] }
                 glyph_codes.pack(&quot;n*&quot;)
               else
                 i
@@ -313,7 +286,7 @@ module Prawn
         def glyph_widths
           glyphs = cmap.values.uniq.sort
           first_glyph = glyphs.shift
-          widths = [first_glyph, [Integer(hmtx[first_glyph][0] * scale_factor)]]
+          widths = [first_glyph, [Integer(hmtx[first_glyph][0] * scale_factor)]] 
           prev_glyph = first_glyph
           glyphs.each do |glyph|
             unless glyph == prev_glyph + 1
@@ -327,38 +300,25 @@ module Prawn
         end
 
         def bbox
-          head = @ttf.get_table(:head)
           [:x_min, :y_min, :x_max, :y_max].map do |atr| 
-            Integer(head.send(atr)) * scale_factor
+            Integer(@ttf.head.send(atr)) * scale_factor
           end
         end
 
         def ascender
-          Integer(@ttf.get_table(:hhea).ascender * scale_factor)
+          Integer(@ttf.hhea.ascent * scale_factor)
         end
 
         def descender
-          Integer(@ttf.get_table(:hhea).descender * scale_factor)
+          Integer(@ttf.hhea.descent * scale_factor)
         end      
         
         def line_gap
-          Integer(@ttf.get_table(:hhea).line_gap * scale_factor)   
+          Integer(@ttf.hhea.line_gap * scale_factor)   
         end
 
         def basename
-          return @basename if @basename
-          ps_name = ::Font::TTF::Table::Name::NameRecord::POSTSCRIPT_NAME
-
-          @ttf.get_table(:name).name_records.each do |rec|
-            @basename = rec.utf8_str.to_sym if rec.name_id == ps_name            
-          end
-          @basename
-        end
-
-        def enc_table
-          @enc_table ||= @ttf.get_table(:cmap).encoding_tables.find do |t|
-            t.class == ::Font::TTF::Table::Cmap::EncodingTable4
-          end
+          @basename ||= @ttf.name.postscript_name
         end
 
         # TODO: instead of creating a map that contains every glyph in the font,
@@ -375,20 +335,7 @@ module Prawn
         end
         
         def kern_pairs_table
-          return @kern_pairs_table if @kern_pairs_table
-          
-          table = @ttf.get_table(:kern).subtables.find { |s| 
-            s.is_a? ::Font::TTF::Table::Kern::KerningSubtable0 }
-          
-          if table
-            @kern_pairs_table = table.kerning_pairs.inject({}) do |h,p|
-              h[[p.left, p.right]] = p.value; h
-            end
-          else
-            @kern_pairs_table = {}
-          end               
-        rescue ::Font::TTF::TableMissing
-          @kern_pairs_table = {}
+          @kerning_data ||= has_kerning_data? ? @ttf.kern.sub_tables[0] : {}
         end
 
         def has_kerning_data?
@@ -404,18 +351,16 @@ module Prawn
           if options[:kerning] 
             kern(text)         
           else     
-           unicode_codepoints = text.unpack(&quot;U*&quot;)
-            glyph_codes = unicode_codepoints.map { |u| 
-              enc_table.get_glyph_id_for_unicode(u)
-            }
+            unicode_codepoints = text.unpack(&quot;U*&quot;)
+            glyph_codes = unicode_codepoints.map { |u| cmap[u] }
             text = glyph_codes.pack(&quot;n*&quot;)
           end
         end
-
+        
         private
 
         def hmtx
-          @hmtx ||= @ttf.get_table(:hmtx).metrics
+          @hmtx ||= @ttf.hmtx.values
         end         
         
         def character_width_by_code(code)    
@@ -424,7 +369,7 @@ module Prawn
         end                   
 
         def scale_factor
-          @scale ||= 1000 * Float(@ttf.get_table(:head).units_per_em)**-1
+          @scale ||= 1000 * Float(@ttf.head.units_per_em)**-1
         end
 
       end</diff>
      <filename>lib/prawn/font/metrics.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,25 +7,25 @@
 # This is free software. Please see the LICENSE and COPYING files for details.
 
 require &quot;enumerator&quot;
-require &quot;prawn/graphics/cell&quot;   
+require &quot;prawn/graphics/cell&quot;
 require &quot;prawn/graphics/color&quot;
 
 module Prawn
 
-  # Implements the drawing facilities for Prawn::Document.  
+  # Implements the drawing facilities for Prawn::Document.
   # Use this to draw the most beautiful imaginable things.
-  # 
+  #
   # This file lifts and modifies several of PDF::Writer's graphics functions
   # ruby-pdf.rubyforge.org
   #
-  module Graphics  
-    
+  module Graphics
+
     include Color
-           
+
     #######################################################################
     # Low level drawing operations must translate to absolute coords!     #
     #######################################################################
-       
+
     # Moves the drawing position to a given point.  The point can be
     # specified as a tuple or a flattened argument list
     #
@@ -33,50 +33,50 @@ module Prawn
     #   pdf.move_to(100,50)
     #
     def move_to(*point)
-      x,y = translate(point)           
+      x,y = translate(point)
       add_content(&quot;%.3f %.3f m&quot; % [ x, y ])
     end
-    
+
     # Draws a line from the current drawing position to the specified point.
-    # The destination may be described as a tuple or a flattened list:    
+    # The destination may be described as a tuple or a flattened list:
     #
-    #   pdf.line_to [50,50] 
-    #   pdf.line_to(50,50)    
+    #   pdf.line_to [50,50]
+    #   pdf.line_to(50,50)
     #
-    def line_to(*point)      
+    def line_to(*point)
       x,y = translate(point)
-      add_content(&quot;%.3f %.3f l&quot; % [ x, y ]) 
-    end    
-    
-    # Draws a Bezier curve from the current drawing position to the 
+      add_content(&quot;%.3f %.3f l&quot; % [ x, y ])
+    end
+
+    # Draws a Bezier curve from the current drawing position to the
     # specified point, bounded by two additional points.
-    #  
-    #   pdf.curve_to [100,100], :bounds =&gt; [[90,90],[75,75]]   
     #
-    def curve_to(dest,options={})                           
-       options[:bounds] or raise Prawn::Errors::InvalidGraphicsPath, 
+    #   pdf.curve_to [100,100], :bounds =&gt; [[90,90],[75,75]]
+    #
+    def curve_to(dest,options={})
+       options[:bounds] or raise Prawn::Errors::InvalidGraphicsPath,
          &quot;Bounding points for bezier curve must be specified &quot;+
-         &quot;as :bounds =&gt; [[x1,y1],[x2,y2]]&quot;       
+         &quot;as :bounds =&gt; [[x1,y1],[x2,y2]]&quot;
 
        curve_points = (options[:bounds] &lt;&lt; dest).map { |e| translate(e) }
-       add_content(&quot;%.3f %.3f %.3f %.3f %.3f %.3f c&quot; % 
-                     curve_points.flatten )    
-    end   
-    
-    # Draws a rectangle given &lt;tt&gt;point&lt;/tt&gt;, &lt;tt&gt;width&lt;/tt&gt; and 
+       add_content(&quot;%.3f %.3f %.3f %.3f %.3f %.3f c&quot; %
+                     curve_points.flatten )
+    end
+
+    # Draws a rectangle given &lt;tt&gt;point&lt;/tt&gt;, &lt;tt&gt;width&lt;/tt&gt; and
     # &lt;tt&gt;height&lt;/tt&gt;.  The rectangle is bounded by its upper-left corner.
     #
     #    pdf.rectangle [300,300], 100, 200
-    # 
+    #
     def rectangle(point,width,height)
       x,y = translate(point)
-      add_content(&quot;%.3f %.3f %.3f %.3f re&quot; % [ x, y - height, width, height ])      
+      add_content(&quot;%.3f %.3f %.3f %.3f re&quot; % [ x, y - height, width, height ])
     end
-       
+
     ###########################################################
-    #  Higher level functions: May use relative coords        #   
-    ########################################################### 
-      
+    #  Higher level functions: May use relative coords        #
+    ###########################################################
+
     # Sets line thickness to the &lt;tt&gt;width&lt;/tt&gt; specified.
     #
     def line_width=(width)
@@ -93,24 +93,33 @@ module Prawn
         @line_width || 1
       end
     end
-       
-    # Draws a line from one point to another. Points may be specified as 
+
+    # Draws a line from one point to another. Points may be specified as
     # tuples or flattened argument list:
     #
-    #   pdf.line [100,100], [200,250] 
+    #   pdf.line [100,100], [200,250]
     #   pdf.line(100,100,200,250)
     #
     def line(*points)
       x0,y0,x1,y1 = points.flatten
       move_to(x0, y0)
       line_to(x1, y1)
-    end   
+    end
 
     # Draws a horizontal line from &lt;tt&gt;x1&lt;/tt&gt; to &lt;tt&gt;x2&lt;/tt&gt; at the
-    # current &lt;tt&gt;y&lt;/tt&gt; position.
+    # current &lt;tt&gt;y&lt;/tt&gt; position, or the position specified by the :at option.
     #
-    def horizontal_line(x1,x2)
-      line(x1,y-bounds.absolute_bottom,x2,y-bounds.absolute_bottom)
+    #  # draw a line from [25, 75] to [100, 75]
+    #  horizontal_line 25, 100, :at =&gt; 75  
+    #
+    def horizontal_line(x1,x2,options={})
+      if options[:at]
+        y1 = options[:at]
+      else
+        y1 = y - bounds.absolute_bottom
+      end
+      
+      line(x1,y1,x2,y1)
     end
 
     # Draws a horizontal line from the left border to the right border of the
@@ -120,115 +129,124 @@ module Prawn
       horizontal_line(bounds.left, bounds.right)
     end
 
-    # Draws a vertical line at the given x position from y1 to y2.
-    # 
-    def vertical_line_at(x,y1,y2)
-      line(x,y1,x,y2)
+    # Draws a vertical line at the x cooordinate given by :at from y1 to y2.
+    #
+    #   # draw a line from [25, 100] to [25, 300]
+    #   vertical_line 100, 300, :at =&gt; 25
+    #
+    def vertical_line(y1,y2,params)
+      line(params[:at],y1,params[:at],y2)
     end
-               
+
     # Draws a Bezier curve between two points, bounded by two additional
     # points
     #
-    #    pdf.curve [50,100], [100,100], :bounds =&gt; [[90,90],[75,75]]  
+    #    pdf.curve [50,100], [100,100], :bounds =&gt; [[90,90],[75,75]]
     #
     def curve(origin,dest, options={})
-      move_to *origin    
+      move_to(*origin)
       curve_to(dest,options)
     end
 
     # This constant is used to approximate a symmetrical arc using a cubic
-    # Bezier curve.   
+    # Bezier curve.
     #
     KAPPA = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0)
-                                                                  
+
     # Draws a circle of radius &lt;tt&gt;:radius&lt;/tt&gt; with the centre-point at &lt;tt&gt;point&lt;/tt&gt;
     # as a complete subpath. The drawing point will be moved to the
-    # centre-point upon completion of the drawing the circle.     
-    #                                           
-    #    pdf.circle_at [100,100], :radius =&gt; 25  
+    # centre-point upon completion of the drawing the circle.
+    #
+    #    pdf.circle_at [100,100], :radius =&gt; 25
     #
-    def circle_at(point, options)  
+    def circle_at(point, options)
       x,y = point
-      ellipse_at [x, y], options[:radius]     
-    end 
-      
+      ellipse_at [x, y], options[:radius]
+    end
+
     # Draws an ellipse of +x+ radius &lt;tt&gt;r1&lt;/tt&gt; and +y+ radius &lt;tt&gt;r2&lt;/tt&gt;
     # with the centre-point at &lt;tt&gt;point&lt;/tt&gt; as a complete subpath. The
     # drawing point will be moved to the centre-point upon completion of the
-    # drawing the ellipse.   
-    #                                    
+    # drawing the ellipse.
+    #
     #    # draws an ellipse with x-radius 25 and y-radius 50
-    #    pdf.ellipse_at [100,100], 25, 50   
+    #    pdf.ellipse_at [100,100], 25, 50
     #
-    def ellipse_at(point, r1, r2 = r1)  
+    def ellipse_at(point, r1, r2 = r1)
       x, y = point
       l1 = r1 * KAPPA
-      l2 = r2 * KAPPA            
-      
+      l2 = r2 * KAPPA
+
       move_to(x + r1, y)
-      
+
       # Upper right hand corner
-      curve_to [x,  y + r2], 
+      curve_to [x,  y + r2],
         :bounds =&gt; [[x + r1, y + l1], [x + l2, y + r2]]
 
-      # Upper left hand corner                          
-      curve_to [x - r1, y],  
-        :bounds =&gt; [[x - l2, y + r2], [x - r1, y + l1]] 
- 
+      # Upper left hand corner
+      curve_to [x - r1, y],
+        :bounds =&gt; [[x - l2, y + r2], [x - r1, y + l1]]
+
       # Lower left hand corner
-      curve_to [x, y - r2],  
-        :bounds =&gt; [[x - r1, y - l1], [x - l2, y - r2]]  
+      curve_to [x, y - r2],
+        :bounds =&gt; [[x - r1, y - l1], [x - l2, y - r2]]
 
       # Lower right hand corner
       curve_to [x + r1, y],
-        :bounds =&gt; [[x + l2, y - r2], [x + r1, y - l1]]    
-   
+        :bounds =&gt; [[x + l2, y - r2], [x + r1, y - l1]]
+
       move_to(x, y)
     end
-     
+
     # Draws a polygon from the specified points.
-    #                                              
+    #
     #    # draws a snazzy triangle
-    #    pdf.polygon [100,100], [100,200], [200,200]  
+    #    pdf.polygon [100,100], [100,200], [200,200]
     #
-    def polygon(*points) 
+    def polygon(*points)
       move_to points[0]
       (points &lt;&lt; points[0]).each_cons(2) do |p1,p2|
         line_to(*p2)
       end
     end
-    
+
     # Strokes and closes the current path. See Graphic::Color for color details
     #
     def stroke
       yield if block_given?
       add_content &quot;S&quot;
     end
+    
+    # Draws and strokes a rectangle represented by the current bounding box
+    #
+    def stroke_bounds
+      stroke_rectangle bounds.top_left, bounds.width, bounds.height
+    end
 
     # Fills and closes the current path. See Graphic::Color for color details
     #
-    def fill               
+    def fill
       yield if block_given?
       add_content &quot;f&quot;
     end
 
     # Fills, strokes, and closes the current path. See Graphic::Color for color details
     #
-    def fill_and_stroke  
+    def fill_and_stroke
       yield if block_given?
-      add_content &quot;b&quot; 
-    end                                                       
-    
-    private       
-    
+      add_content &quot;b&quot;
+    end
+
+    private
+
     def translate(*point)
       x,y = point.flatten
       [@bounding_box.absolute_left + x, @bounding_box.absolute_bottom + y]
-    end    
-    
+    end
+
     def translate!(point)
       point.replace(translate(point))
-    end                                                                        
+    end
 
   end
 end</diff>
      <filename>lib/prawn/graphics.rb</filename>
    </modified>
    <modified>
      <diff>@@ -42,23 +42,29 @@ module Prawn
       # &lt;tt&gt;:document&lt;/tt&gt;:: The Prawn::Document object to render on. 
       # &lt;tt&gt;:text&lt;/tt&gt;:: The text to be flowed within the cell
       # &lt;tt&gt;:width&lt;/tt&gt;:: The width in PDF points of the cell.
-      # &lt;tt&gt;:border&lt;/tt&gt;:: The border line width. If omitted, no border will be drawn.
+      # &lt;tt&gt;:height&lt;/tt&gt;:: The height in PDF points of the cell.
       # &lt;tt&gt;:horizontal_padding&lt;/tt&gt;:: The horizontal padding in PDF points
       # &lt;tt&gt;:vertical_padding&lt;/tt&gt;:: The vertical padding in PDF points
       # &lt;tt&gt;:padding&lt;/tt&gt;:: Overrides both horizontal and vertical padding
-      # &lt;tt&gt;:border_style&lt;/tt&gt;:: One of &lt;tt&gt;:all&lt;/tt&gt;, &lt;tt&gt;:no_top&lt;/tt&gt;, &lt;tt&gt;:no_bottom&lt;/tt&gt;, &lt;tt&gt;:sides&lt;/tt&gt;   
       # &lt;tt&gt;:align&lt;/tt&gt;:: One of &lt;tt&gt;:left&lt;/tt&gt;, &lt;tt&gt;:right&lt;/tt&gt;, &lt;tt&gt;:center&lt;/tt&gt;
+      # &lt;tt&gt;:borders&lt;/tt&gt;:: An array of sides which should have a border. Any of &lt;tt&gt;:top&lt;/tt&gt;, &lt;tt&gt;:left&lt;/tt&gt;, &lt;tt&gt;:right&lt;/tt&gt;, &lt;tt&gt;:bottom&lt;/tt&gt;
+      # &lt;tt&gt;:border_width&lt;/tt&gt;:: The border line width. Defaults to 1.
+      # &lt;tt&gt;:border_style&lt;/tt&gt;:: One of &lt;tt&gt;:all&lt;/tt&gt;, &lt;tt&gt;:no_top&lt;/tt&gt;, &lt;tt&gt;:no_bottom&lt;/tt&gt;, &lt;tt&gt;:sides&lt;/tt&gt;, &lt;tt&gt;:none&lt;/tt&gt;, &lt;tt&gt;:bottom_only&lt;/tt&gt;. Defaults to :all.
       #
       def initialize(options={})
         @point        = options[:point]
         @document     = options[:document]
         @text         = options[:text].to_s
+        @text_color   = options[:text_color]
         @width        = options[:width]
+        @height       = options[:height]
         @borders      = options[:borders]
         @border_width = options[:border_width] || 1
         @border_style = options[:border_style] || :all               
+        @border_color = options[:border_color]
         @background_color = options[:background_color] 
         @align            = options[:align] || :left
+        @font_size        = options[:font_size]
 
         @horizontal_padding = options[:horizontal_padding] || 0
         @vertical_padding   = options[:vertical_padding]   || 0
@@ -70,7 +76,7 @@ module Prawn
 
       attr_accessor :point, :border_style, :border_width, :background_color,
                     :document, :horizontal_padding, :vertical_padding, :align,
-                    :borders
+                    :borders, :text_color, :border_color
                     
       attr_writer   :height, :width #:nodoc:   
            
@@ -90,7 +96,7 @@ module Prawn
       #
       def width
         @width || (@document.font.metrics.string_width(@text,
-          @document.font.size)) + 2*@horizontal_padding
+          @font_size || @document.font.size)) + 2*@horizontal_padding
       end
 
       # The height of the cell in PDF points
@@ -125,26 +131,30 @@ module Prawn
           @document.mask(:line_width) do
             @document.line_width = @border_width
 
-            if borders.include?(:left)
-              @document.stroke_line [rel_point[0], rel_point[1] + (@border_width / 2.0)], 
-                [rel_point[0], rel_point[1] - height - @border_width / 2.0 ]
-            end
-
-            if borders.include?(:right)
-              @document.stroke_line( 
-                [rel_point[0] + width, rel_point[1] + (@border_width / 2.0)],
-                [rel_point[0] + width, rel_point[1] - height - @border_width / 2.0] )
-            end
-
-            if borders.include?(:top)
-              @document.stroke_line(
-                [ rel_point[0] + @border_width / 2.0, rel_point[1] ], 
-                [ rel_point[0] - @border_width / 2.0 + width, rel_point[1] ])
-            end
-
-            if borders.include?(:bottom)
-              @document.stroke_line [rel_point[0], rel_point[1] - height ],
-                                  [rel_point[0] + width, rel_point[1] - height]
+            @document.mask(:stroke_color) do
+              @document.stroke_color @border_color if @border_color
+
+              if borders.include?(:left)
+                @document.stroke_line [rel_point[0], rel_point[1] + (@border_width / 2.0)], 
+                  [rel_point[0], rel_point[1] - height - @border_width / 2.0 ]
+              end
+
+              if borders.include?(:right)
+                @document.stroke_line( 
+                  [rel_point[0] + width, rel_point[1] + (@border_width / 2.0)],
+                  [rel_point[0] + width, rel_point[1] - height - @border_width / 2.0] )
+              end
+
+              if borders.include?(:top)
+                @document.stroke_line(
+                  [ rel_point[0] + @border_width / 2.0, rel_point[1] ], 
+                  [ rel_point[0] - @border_width / 2.0 + width, rel_point[1] ])
+              end
+
+              if borders.include?(:bottom)
+                @document.stroke_line [rel_point[0], rel_point[1] - height ],
+                                    [rel_point[0] + width, rel_point[1] - height]
+              end
             end
 
           end
@@ -157,7 +167,16 @@ module Prawn
                                  @point[1] - @vertical_padding], 
                                 :width   =&gt; text_area_width,
                                 :height  =&gt; height - @vertical_padding) do
-          @document.text @text, :align =&gt; @align
+          @document.move_up @document.font.line_gap
+
+          options = {:align =&gt; @align}
+
+          options[:size] = @font_size if @font_size
+
+          @document.mask(:fill_color) do
+            @document.fill_color @text_color if @text_color                        
+            @document.text @text, options
+          end
         end
       end
 
@@ -173,6 +192,10 @@ module Prawn
           [:left,:right,:bottom]
         when :no_bottom
           [:left,:right,:top]
+        when :bottom_only
+          [:bottom]
+        when :none
+          []
         end
       end
 
@@ -189,8 +212,8 @@ module Prawn
         @height   = 0
       end
 
-      attr_reader :width, :height
-      attr_accessor :background_color
+      attr_reader :width, :height, :cells
+      attr_accessor :background_color, :text_color, :border_color
 
       def &lt;&lt;(cell)
         @cells &lt;&lt; cell
@@ -208,6 +231,8 @@ module Prawn
                       y - @document.bounds.absolute_bottom]
           e.height = @height
           e.background_color ||= @background_color
+          e.text_color ||= @text_color
+          e.border_color ||= @border_color
           e.draw
           x += e.width
         end</diff>
      <filename>lib/prawn/graphics/cell.rb</filename>
    </modified>
    <modified>
      <diff>@@ -18,11 +18,13 @@ module Prawn
     # &lt;tt&gt;file&lt;/tt&gt;:: path to file or an object that responds to #read
     #
     # Options:
-    # &lt;tt&gt;:at&lt;/tt&gt;:: the location of the top left corner of the image.
+    # &lt;tt&gt;:at&lt;/tt&gt;:: an array [x,y] with the location of the top left corner of the image.
     # &lt;tt&gt;:position&lt;/tt&gt;::  One of (:left, :center, :right) or an x-offset
+    # &lt;tt&gt;:vposition&lt;/tt&gt;::  One of (:top, :center, :center) or an y-offset    
     # &lt;tt&gt;:height&lt;/tt&gt;:: the height of the image [actual height of the image]
     # &lt;tt&gt;:width&lt;/tt&gt;:: the width of the image [actual width of the image]
-    # &lt;tt&gt;:scale&lt;/tt&gt;:: scale the dimensions of the image proportionally   
+    # &lt;tt&gt;:scale&lt;/tt&gt;:: scale the dimensions of the image proportionally
+    # &lt;tt&gt;:fit&lt;/tt&gt;:: scale the dimensions of the image proportionally to fit inside [width,height]
     # 
     #   Prawn::Document.generate(&quot;image2.pdf&quot;, :page_layout =&gt; :landscape) do     
     #     pigs = &quot;#{Prawn::BASEDIR}/data/images/pigs.jpg&quot; 
@@ -36,6 +38,11 @@ module Prawn
     # proportionally.  When both are provided, the image will be stretched to 
     # fit the dimensions without maintaining the aspect ratio.
     #
+    #
+    # If :at is provided, the image will be place in the current page but
+    # the text position will not be changed.
+    #
+    #
     # If instead of an explicit filename, an object with a read method is
     # passed as +file+, you can embed images from IO objects and things
     # that act like them (including Tempfiles and open-uri objects).
@@ -50,9 +57,10 @@ module Prawn
     # dimensions of an image object if needed. 
     # (See also: Prawn::Images::PNG , Prawn::Images::JPG)
     # 
-    def image(file, options={})     
-      Prawn.verify_options [:at,:position, :height, :width, :scale], options
-      
+    def image(file, options={})
+      Prawn.verify_options [:at, :position, :vposition, :height, 
+                            :width, :scale, :fit], options
+
       if file.respond_to?(:read)
         image_content = file.read
       else      
@@ -86,7 +94,8 @@ module Prawn
 
       # find where the image will be placed and how big it will be  
       w,h = calc_image_dimensions(info, options)
-      if options[:at]       
+
+      if options[:at]     
         x,y = translate(options[:at]) 
       else                  
         x,y = image_position(w,h,options) 
@@ -109,6 +118,7 @@ module Prawn
     
     def image_position(w,h,options)
       options[:position] ||= :left
+      
       x = case options[:position] 
       when :left
         bounds.absolute_left
@@ -118,8 +128,20 @@ module Prawn
         bounds.absolute_right - w
       when Numeric
         options[:position] + bounds.absolute_left
-      end       
-      
+      end
+
+      y = case options[:vposition]
+      when :top
+        bounds.absolute_top
+      when :center
+        bounds.absolute_top - (bounds.height - h) / 2.0
+      when :bottom
+        bounds.absolute_bottom + h
+      when Numeric
+        bounds.absolute_top - options[:vposition]
+      else
+        self.y
+      end
       return [x,y]
     end
 
@@ -127,10 +149,12 @@ module Prawn
       color_space = case jpg.channels
       when 1
         :DeviceGray
+      when 3
+        :DeviceRGB
       when 4
         :DeviceCMYK
       else
-        :DeviceRGB
+        raise ArgumentError, 'JPG uses an unsupported number of channels'
       end
       obj = ref(:Type       =&gt; :XObject,
           :Subtype          =&gt; :Image,
@@ -140,6 +164,14 @@ module Prawn
           :Width            =&gt; jpg.width,
           :Height           =&gt; jpg.height,
           :Length           =&gt; data.size ) 
+
+      # add extra decode params for CMYK images. By swapping the
+      # min and max values from the default, we invert the colours. See
+      # section 4.8.4 of the spec.
+      if color_space == :DeviceCMYK
+        obj.data[:Decode] = [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ]
+      end
+
       obj &lt;&lt; data
       return obj
     end
@@ -252,7 +284,6 @@ module Prawn
     end
 
     def calc_image_dimensions(info, options)
-      # TODO: allow the image to be aligned in a box
       w = options[:width] || info.width
       h = options[:height] || info.height
 
@@ -267,8 +298,20 @@ module Prawn
       elsif options[:scale] 
         w = info.width * options[:scale]
         h = info.height * options[:scale]
+      elsif options[:fit] 
+        bw, bh = options[:fit]
+        bp = bw / bh.to_f
+        ip = info.width / info.height.to_f
+        if ip &gt; bp
+          w = bw
+          h = bw / ip
+        else
+          h = bh
+          w = bh * ip
+        end
       end
-
+      info.scaled_width = w
+      info.scaled_height = h
       [w,h]
     end
 </diff>
      <filename>lib/prawn/images.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,8 @@ module Prawn
     # of a PNG image that we need to embed them in a PDF
     class JPG 
       attr_reader :width, :height, :bits, :channels
-
+      attr_accessor :scaled_width, :scaled_height
+      
       JPEG_SOF_BLOCKS = %W(\xc0 \xc1 \xc2 \xc3 \xc5 \xc6 \xc7 \xc9 \xca \xcb \xcd \xce \xcf)
       JPEG_APP_BLOCKS = %W(\xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef)
 </diff>
      <filename>lib/prawn/images/jpg.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,8 @@ module Prawn
       attr_reader :width, :height, :bits
       attr_reader :color_type, :compression_method, :filter_method
       attr_reader :interlace_method, :alpha_channel
-
+      attr_accessor :scaled_width, :scaled_height
+      
       # Process a new PNG image
       #
       # &lt;tt&gt;:data&lt;/tt&gt;:: A string containing a full PNG file</diff>
      <filename>lib/prawn/images/png.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,7 +34,10 @@ module Prawn
     when Numeric    then String(obj)
     when Array
       &quot;[&quot; &lt;&lt; obj.map { |e| PdfObject(e, in_content_stream) }.join(' ') &lt;&lt; &quot;]&quot;
-    when String     
+    when Prawn::LiteralString
+      obj = obj.gsub(/[\\\n\(\)]/) { |m| &quot;\\#{m}&quot; }
+      &quot;(#{obj})&quot;
+    when String
       obj = &quot;\xFE\xFF&quot; + obj.unpack(&quot;U*&quot;).pack(&quot;n*&quot;) unless in_content_stream
       &quot;&lt;&quot; &lt;&lt; obj.unpack(&quot;H*&quot;).first &lt;&lt; &quot;&gt;&quot;
     when Symbol                                                         
@@ -57,6 +60,10 @@ module Prawn
       output &lt;&lt; &quot;&gt;&gt;&quot;  
     when Prawn::Reference
       obj.to_s      
+    when Prawn::NameTree::Node
+      PdfObject(obj.to_hash)
+    when Prawn::NameTree::Value
+      PdfObject(obj.name) + &quot; &quot; + PdfObject(obj.value)
     else
       raise Prawn::Errors::FailedObjectConversion, 
         &quot;This object cannot be serialized to PDF&quot;</diff>
      <filename>lib/prawn/pdf_object.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,16 @@
 # encoding: utf-8
 
-require File.join(File.expand_path(File.dirname(__FILE__)), &quot;spec_helper&quot;)  
+require File.join(File.expand_path(File.dirname(__FILE__)), &quot;spec_helper&quot;) 
+
+describe &quot;The cursor&quot; do
+  it &quot;should equal pdf.y - bounds.absolute_bottom&quot; do
+    pdf = Prawn::Document.new
+    pdf.cursor.should == pdf.bounds.top
+    
+    pdf.y = 300
+    pdf.cursor.should == pdf.y - pdf.bounds.absolute_bottom 
+  end
+end 
                                
 describe &quot;When creating multi-page documents&quot; do 
  
@@ -38,7 +48,23 @@ describe &quot;When beginning each new page&quot; do
     pdf.render
     
     call_count.should == 3
-  end                   
+  end
+  describe &quot;Background template feature&quot; do
+    before(:each) do
+      @filename = &quot;#{Prawn::BASEDIR}/data/images/pigs.jpg&quot;
+      @pdf = Prawn::Document.new(:background =&gt; @filename)
+    end
+    it &quot;should place a background image if it is in options block&quot; do
+      output = @pdf.render
+      images = PDF::Inspector::XObject.analyze(output)
+      # there should be 2 images in the page resources
+      images.page_xobjects.first.size.should == 1
+    end
+    it &quot;should place a background image if it is in options block&quot; do
+      @pdf.instance_variable_defined?(:@background).should == true
+      @pdf.instance_variable_get(:@background).should == @filename
+    end
+  end
 
 end
 
@@ -84,6 +110,17 @@ describe &quot;When ending each page&quot; do
     pdf.render
   end
 
+  it &quot;should result in a smaller file size when compressed&quot; do
+    doc_uncompressed = Prawn::Document.new
+    doc_compressed   = Prawn::Document.new(:compress =&gt; true)
+    [doc_compressed, doc_uncompressed].each do |pdf|
+       pdf.font &quot;#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf&quot;
+       pdf.text &quot;&#26356;&#21487;&#24597;&#30340;&#26159;&#65292;&#21516;&#36136;&#21270;&#31454;&#20105;&#23545;&#25163;&#21487;&#20197;&#25353;&#29031;URL&#20013;&#21518;&#38754;&#36825;&#20010;ID&#26469;&#36941;&#21382;&quot; * 10
+    end
+
+    doc_compressed.render.length.should.be &lt; doc_uncompressed.render.length
+  end 
+
 end                                 
 
 describe &quot;When setting page size&quot; do</diff>
      <filename>spec/document_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -70,6 +70,28 @@ describe &quot;font style support&quot; do
       
 end
 
+describe &quot;Transactional font handling&quot; do
+  before(:each) { create_pdf }
+  
+  it &quot;should allow setting of size directly when font is created&quot; do
+    @pdf.font &quot;Courier&quot;, :size =&gt; 16
+    @pdf.font.size.should == 16 
+  end
+  
+  it &quot;should allow temporary setting of a new font using a transaction&quot; do
+    original = @pdf.font
+    
+    @pdf.font &quot;Courier&quot;, :size =&gt; 16 do
+      @pdf.font.name.should == &quot;Courier&quot;
+      @pdf.font.size.should == 16
+    end
+    
+    @pdf.font.should == original  
+  end
+  
+end
+
+
 describe &quot;Document#page_fonts&quot; do
   before(:each) { create_pdf } 
   </diff>
      <filename>spec/font_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,58 +1,70 @@
 # encoding: utf-8
 
-require File.join(File.expand_path(File.dirname(__FILE__)), &quot;spec_helper&quot;)  
-  
+require File.join(File.expand_path(File.dirname(__FILE__)), &quot;spec_helper&quot;)
+
 describe &quot;When drawing a line&quot; do
-   
+
   before(:each) { create_pdf }
- 
+
   it &quot;should draw a line from (100,600) to (100,500)&quot; do
     @pdf.line([100,600],[100,500])
-    
+
     line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
-    
-    line_drawing.points.should == [[100,600],[100,500]]       
-  end  
-  
+
+    line_drawing.points.should == [[100,600],[100,500]]
+  end
+
   it &quot;should draw two lines at (100,600) to (100,500) &quot; +
-     &quot;and (75,100) to (50,125)&quot; do 
-    @pdf.line(100,600,100,500) 
+     &quot;and (75,100) to (50,125)&quot; do
+    @pdf.line(100,600,100,500)
     @pdf.line(75,100,50,125)
-    
+
     line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
-    
-    line_drawing.points.should == 
+
+    line_drawing.points.should ==
       [[100.0, 600.0], [100.0, 500.0], [75.0, 100.0], [50.0, 125.0]]
   end
 
   it &quot;should properly set line width via line_width=&quot; do
      @pdf.line_width = 10
-     line = PDF::Inspector::Graphics::Line.analyze(@pdf.render) 
-     line.widths.first.should == 10 
-  end  
-  
+     line = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
+     line.widths.first.should == 10
+  end
+
   it &quot;should properly set line width via line_width(width)&quot; do
      @pdf.line_width(10)
-     line = PDF::Inspector::Graphics::Line.analyze(@pdf.render) 
-     line.widths.first.should == 10 
-  end 
-  
-  describe &quot;(Horizontally)&quot; do  
-   
-    before :each do
-      @pdf = Prawn::Document.new
+     line = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
+     line.widths.first.should == 10
+  end
+
+  describe &quot;(Horizontally)&quot; do
+    it &quot;should draw from [x1,pdf.y],[x2,pdf.y]&quot; do
       @pdf.horizontal_line(100,150)
       @line = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
-    end
-   
-    it &quot;should draw from [x1,pdf.y],[x2,pdf.y]&quot; do
       @line.points.should == [[100.0 + @pdf.bounds.absolute_left, @pdf.y],
                               [150.0 + @pdf.bounds.absolute_left, @pdf.y]]
-    end      
-    
+    end
+
+    it &quot;should draw a line from (200, 250) to (300, 250)&quot; do
+      @pdf.horizontal_line(200,300,:at =&gt; 250)
+      line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
+      line_drawing.points.should == [[200,250],[300,250]]
+    end
+  end
+
+  describe &quot;(Vertically)&quot; do
+    it &quot;should draw a line from (350, 300) to (350, 400)&quot; do
+      @pdf.vertical_line(300,400,:at =&gt; 350)
+      line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
+      line_drawing.points.should == [[350,300],[350,400]]
+    end
+    it &quot;should require a y coordinate&quot; do
+      lambda { @pdf.vertical_line(400,500) }.
+        should.raise(ArgumentError)
+    end
   end
-        
-end                            
+
+end
 
 describe &quot;When drawing a polygon&quot; do
 
@@ -61,11 +73,11 @@ describe &quot;When drawing a polygon&quot; do
   it &quot;should draw each line passed to polygon()&quot; do
     @pdf.polygon([100,500],[100,400],[200,400])
 
-    line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render) 
+    line_drawing = PDF::Inspector::Graphics::Line.analyze(@pdf.render)
     line_drawing.points.should == [[100,500],[100,400],[200,400],[100,500]]
   end
 
-end                                
+end
 
 describe &quot;When drawing a rectangle&quot; do
 
@@ -83,53 +95,53 @@ describe &quot;When drawing a rectangle&quot; do
 
   end
 
-end  
+end
+
+describe &quot;When drawing a curve&quot; do
 
-describe &quot;When drawing a curve&quot; do  
-    
   before(:each) { create_pdf }
-  
+
   it &quot;should draw a bezier curve from 50,50 to 100,100&quot; do
     @pdf.move_to  [50,50]
     @pdf.curve_to [100,100],:bounds =&gt; [[20,90], [90,70]]
     curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
-    curve.coords.should == [50.0, 50.0, 20.0, 90.0, 90.0, 70.0, 100.0, 100.0] 
-  end                             
-  
+    curve.coords.should == [50.0, 50.0, 20.0, 90.0, 90.0, 70.0, 100.0, 100.0]
+  end
+
   it &quot;should draw a bezier curve from 100,100 to 50,50&quot; do
-    @pdf.curve [100,100], [50,50], :bounds =&gt; [[20,90], [90,75]] 
-    curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)  
-    curve.coords.should == [100.0, 100.0, 20.0, 90.0, 90.0, 75.0, 50.0, 50.0] 
+    @pdf.curve [100,100], [50,50], :bounds =&gt; [[20,90], [90,75]]
+    curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
+    curve.coords.should == [100.0, 100.0, 20.0, 90.0, 90.0, 75.0, 50.0, 50.0]
   end
-  
-end 
+
+end
 
 describe &quot;When drawing an ellipse&quot; do
-  before(:each) do 
+  before(:each) do
     create_pdf
     @pdf.ellipse_at [100,100], 25, 50
-    @curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)  
-  end       
-  
+    @curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
+  end
+
   it &quot;should move the pointer to the center of the ellipse after drawing&quot; do
     @curve.coords[-2..-1].should == [100,100]
-  end 
-  
-end    
+  end
+
+end
 
 describe &quot;When drawing a circle&quot; do
-  before(:each) do 
+  before(:each) do
     create_pdf
-    @pdf.circle_at [100,100], :radius =&gt; 25 
+    @pdf.circle_at [100,100], :radius =&gt; 25
     @pdf.ellipse_at [100,100], 25, 25
-    @curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)        
-  end       
-  
-  it &quot;should stroke the same path as the equivalent ellipse&quot; do 
+    @curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
+  end
+
+  it &quot;should stroke the same path as the equivalent ellipse&quot; do
     middle = @curve.coords.length / 2
-    @curve.coords[0...middle].should == @curve.coords[middle..-1] 
+    @curve.coords[0...middle].should == @curve.coords[middle..-1]
   end
-end    
+end
 
 describe &quot;When setting colors&quot; do
 
@@ -144,54 +156,54 @@ describe &quot;When setting colors&quot; do
 
   it &quot;should set fill colors&quot; do
     @pdf.fill_color &quot;ccff00&quot;
-    colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render) 
+    colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
     # 80% red, 100% green, 0% blue
     colors.fill_color.should == [0.8,1.0,0]
-  end   
-  
+  end
+
   it &quot;should reset the colors on each new page if they have been defined&quot; do
     @pdf.fill_color &quot;ccff00&quot;
-    colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render) 
-    
-    colors.fill_color_count.should == 2   
+    colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
+
+    colors.fill_color_count.should == 2
     colors.stroke_color_count.should == 1
-    @pdf.start_new_page                
-    @pdf.stroke_color &quot;ff00cc&quot;  
-    
-    colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render) 
-    colors.fill_color_count.should == 3  
+    @pdf.start_new_page
+    @pdf.stroke_color &quot;ff00cc&quot;
+
+    colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
+    colors.fill_color_count.should == 3
     colors.stroke_color_count.should == 3
-    
+
     @pdf.start_new_page
-    colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render) 
+    colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
     colors.fill_color_count.should == 4
     colors.stroke_color_count.should == 4
-    
+
     colors.fill_color.should   == [0.8,1.0,0.0]
-    colors.stroke_color.should == [1.0,0.0,0.8] 
-  end    
+    colors.stroke_color.should == [1.0,0.0,0.8]
+  end
 
 end
 
 describe &quot;When using painting shortcuts&quot; do
   before(:each) { create_pdf }
- 
+
   it &quot;should convert stroke_some_method(args) into some_method(args); stroke&quot; do
     @pdf.expects(:line_to).with([100,100])
     @pdf.expects(:stroke)
-    
+
     @pdf.stroke_line_to [100,100]
-  end  
-  
+  end
+
   it &quot;should convert fill_some_method(args) into some_method(args); fill&quot; do
-    @pdf.expects(:line_to).with([100,100]) 
+    @pdf.expects(:line_to).with([100,100])
     @pdf.expects(:fill)
-    
+
     @pdf.fill_line_to [100,100]
   end
-  
+
   it &quot;should not break method_missing&quot; do
     lambda { @pdf.i_have_a_pretty_girlfriend_named_jia }.
-      should.raise(NoMethodError) 
+      should.raise(NoMethodError)
   end
-end
\ No newline at end of file
+end</diff>
      <filename>spec/graphics_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,6 @@ describe &quot;the image() function&quot; do
     images = PDF::Inspector::XObject.analyze(output)
     # there should be 2 images in the page resources
     images.page_xobjects.first.size.should == 2
-
     # but only 1 image xobject
     output.scan(/\/Type \/XObject/).size.should == 1
   end  
@@ -36,5 +35,34 @@ describe &quot;the image() function&quot; do
     
     info.height.should == 453
   end
+
+  describe &quot;:fit option&quot; do
+    it &quot;should fit inside the defined constraints&quot; do
+      info = @pdf.image @filename, :fit =&gt; [100,400]
+      info.scaled_width.should &lt;= 100
+      info.scaled_height.should &lt;= 400
+
+      info = @pdf.image @filename, :fit =&gt; [400,100]
+      info.scaled_width.should &lt;= 400
+      info.scaled_height.should &lt;= 100
+
+      info = @pdf.image @filename, :fit =&gt; [604,453]
+      info.scaled_width.should == 604
+      info.scaled_height.should == 453
+    end
+    it &quot;should move text position&quot; do
+      @y = @pdf.y
+      info = @pdf.image @filename, :fit =&gt; [100,400]
+      @pdf.y.should &lt; @y
+    end
+  end
+  describe &quot;:at option&quot; do
+    it &quot;should not move text position&quot; do
+      @y = @pdf.y
+      info = @pdf.image @filename, :at =&gt; [100,400]
+      @pdf.y.should == @y
+    end
+  end
+
 end
 </diff>
      <filename>spec/images_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,13 @@
 # encoding: utf-8
 
-require File.join(File.expand_path(File.dirname(__FILE__)), &quot;spec_helper&quot;)   
+require File.join(File.expand_path(File.dirname(__FILE__)), &quot;spec_helper&quot;)  
+require &quot;iconv&quot;
 
 describe &quot;adobe font metrics&quot; do
   
   setup do
     @times = Prawn::Font::Metrics[&quot;Times-Roman&quot;]
-    @iconv = Iconv.new('ISO-8859-1', 'utf-8')
+    @iconv = ::Iconv.new('ISO-8859-1', 'utf-8')
   end
   
   it &quot;should calculate string width taking into account accented characters&quot; do</diff>
      <filename>spec/metrics_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -58,14 +58,15 @@ describe &quot;PDF Object Serialization&quot; do
   end  
 
   it &quot;should convert a Ruby array to PDF Array when outside a content stream&quot; do
+    bar = &quot;\xFE\xFF&quot; + &quot;Bar&quot;.unpack(&quot;U*&quot;).pack(&quot;n*&quot;)
     Prawn::PdfObject([1,2,3]).should == &quot;[1 2 3]&quot;
     PDF::Inspector.parse(Prawn::PdfObject([[1,2],:foo,&quot;Bar&quot;], false)).should ==  
-      [[1,2],:foo, &quot;\xFE\xFF\x00B\x00a\x00r&quot;]
+      [[1,2],:foo, bar]
   end  
  
   it &quot;should convert a Ruby hash to a PDF Dictionary when inside a content stream&quot; do
     dict = Prawn::PdfObject( {:foo  =&gt; :bar, 
-                              &quot;baz&quot;  =&gt; [1,2,3], 
+                              &quot;baz&quot; =&gt; [1,2,3], 
                               :bang =&gt; {:a =&gt; &quot;what&quot;, :b =&gt; [:you, :say] }}, true )     
 
     res = PDF::Inspector.parse(dict)           
@@ -77,15 +78,16 @@ describe &quot;PDF Object Serialization&quot; do
   end      
 
   it &quot;should convert a Ruby hash to a PDF Dictionary when outside a content stream&quot; do
+    what = &quot;\xFE\xFF&quot; + &quot;what&quot;.unpack(&quot;U*&quot;).pack(&quot;n*&quot;)
     dict = Prawn::PdfObject( {:foo  =&gt; :bar, 
-                              &quot;baz&quot;  =&gt; [1,2,3], 
+                              &quot;baz&quot; =&gt; [1,2,3], 
                               :bang =&gt; {:a =&gt; &quot;what&quot;, :b =&gt; [:you, :say] }}, false )
 
     res = PDF::Inspector.parse(dict)           
 
     res[:foo].should == :bar
     res[:baz].should == [1,2,3]
-    res[:bang].should == { :a =&gt; &quot;\xFE\xFF\x00w\x00h\x00a\x00t&quot;, :b =&gt; [:you, :say] }
+    res[:bang].should == { :a =&gt; what, :b =&gt; [:you, :say] }
 
   end      
   
@@ -98,5 +100,13 @@ describe &quot;PDF Object Serialization&quot; do
     ref = Prawn::Reference(1,true)
     Prawn::PdfObject(ref).should == ref.to_s
   end
-  
+
+  it &quot;should convert a NameTree::Node to a PDF hash&quot; do
+    node = Prawn::NameTree::Node.new(Prawn::Document.new, 10)
+    node.add &quot;hello&quot;, 1.0
+    node.add &quot;world&quot;, 2.0
+    data = Prawn::PdfObject(node)
+    res = PDF::Inspector.parse(data)
+    res.should == {:Names =&gt; [&quot;hello&quot;, 1.0, &quot;world&quot;, 2.0]}
+  end
 end</diff>
      <filename>spec/pdf_object_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,13 +9,15 @@ $LOAD_PATH &lt;&lt; File.join(File.dirname(__FILE__), '..', 'lib')
 $LOAD_PATH &lt;&lt; File.join(File.dirname(__FILE__), '..', 'vendor','pdf-inspector','lib')
 require &quot;prawn&quot;
 
+Prawn.debug = true
+
 gem 'pdf-reader', &quot;&gt;=0.7.3&quot;
 require &quot;pdf/reader&quot;          
 require &quot;pdf/inspector&quot;
 
-def create_pdf
-  @pdf = Prawn::Document.new(:left_margin   =&gt; 0,
-                             :right_margin  =&gt; 0,
-                             :top_margin    =&gt; 0,
-                             :bottom_margin =&gt; 0)
-end    
\ No newline at end of file
+def create_pdf(klass=Prawn::Document)
+  @pdf = klass.new(:left_margin   =&gt; 0,
+                   :right_margin  =&gt; 0,
+                   :top_margin    =&gt; 0,
+                   :bottom_margin =&gt; 0)
+end    </diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -75,6 +75,29 @@ end
 
 describe &quot;A table's content&quot; do
 
+  it &quot;should not cause an error if rendering the very first row causes a page break&quot; do
+    Prawn::Document.new( :page_layout =&gt; :portrait ) do
+      arr = Array(1..5).collect{|i| [&quot;cell #{i}&quot;] }
+
+      move_down( y - (bounds.absolute_bottom + 3) )
+
+      lambda {
+        table( arr,
+            :font_size          =&gt; 9, 
+            :horizontal_padding =&gt; 3,
+            :vertical_padding   =&gt; 3,
+            :border_width       =&gt; 0.05,
+            :border_style       =&gt; :none,
+            :row_colors         =&gt; %w{ffffff eeeeee},
+            :widths             =&gt; {0 =&gt;110},
+            :position           =&gt; :left,
+            :headers            =&gt; [&quot;exploding header&quot;],
+            :align              =&gt; :left,
+            :align_headers      =&gt; :center)
+      }.should.not.raise
+    end
+  end
+
   it &quot;should output content cell by cell, row by row&quot; do
     data = [[&quot;foo&quot;,&quot;bar&quot;],[&quot;baz&quot;,&quot;bang&quot;]]
     @pdf = Prawn::Document.new
@@ -136,4 +159,21 @@ describe &quot;An invalid table&quot; do
       @pdf.table(@bad_data)
     end
   end
+
+  it &quot;should raise an EmptyTableError with empty table data&quot; do
+    lambda {
+      data = []
+      @pdf = Prawn::Document.new
+      @pdf.table(data)
+    }.should.raise( Prawn::Errors::EmptyTable )
+  end   
+
+  it &quot;should raise an EmptyTableError with nil table data&quot; do
+    lambda {
+      data = nil
+      @pdf = Prawn::Document.new
+      @pdf.table(data)
+    }.should.raise( Prawn::Errors::EmptyTable )
+  end   
+
 end</diff>
      <filename>spec/table_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -112,23 +112,23 @@ describe &quot;when drawing text&quot; do
      it &quot;should raise an exception when a utf-8 incompatible string is rendered&quot; do
        str = &quot;Blah \xDD&quot;
        str.force_encoding(&quot;ASCII-8BIT&quot;)
-       lambda { @pdf.text str }.should.raise(Prawn::Errors::IncompatibleStringEncoding)
+       lambda { @pdf.text str }.should.raise(ArgumentError)
      end
      it &quot;should not raise an exception when a shift-jis string is rendered&quot; do 
        datafile = &quot;#{Prawn::BASEDIR}/data/shift_jis_text.txt&quot;  
        sjis_str = File.open(datafile, &quot;r:shift_jis&quot;) { |f| f.gets } 
        @pdf.font(&quot;#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf&quot;)
-       lambda { @pdf.text sjis_str }.should.not.raise(Prawn::Errors::IncompatibleStringEncoding)
+       lambda { @pdf.text sjis_str }.should.not.raise(ArgumentError)
      end
    else
      # Handle non utf-8 string encodings in a sane way on non-M17N aware VMs
      it &quot;should raise an exception when a corrupt utf-8 string is rendered&quot; do
        str = &quot;Blah \xDD&quot;
-       lambda { @pdf.text str }.should.raise(Prawn::Errors::IncompatibleStringEncoding)
+       lambda { @pdf.text str }.should.raise(ArgumentError)
      end
      it &quot;should raise an exception when a shift-jis string is rendered&quot; do
        sjis_str = File.read(&quot;#{Prawn::BASEDIR}/data/shift_jis_text.txt&quot;)
-       lambda { @pdf.text sjis_str }.should.raise(Prawn::Errors::IncompatibleStringEncoding)
+       lambda { @pdf.text sjis_str }.should.raise(ArgumentError)
      end
    end 
 </diff>
      <filename>spec/text_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@
 &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
 &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=UTF-8&quot; /&gt;
 &lt;link href=&quot;prawn.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
+&lt;link href=&quot;twilight.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
 &lt;/head&gt;
 &lt;body&gt; 
 
@@ -26,7 +27,7 @@
 &lt;/div&gt;
 
 &lt;h2&gt;Building printable documents doesn't have to be hard&lt;/h2&gt; 
-&lt;img src=&quot;/media/prawn_logo.png&quot; style=&quot;float: right;&quot;&gt;
+&lt;img src=&quot;media/prawn_logo.png&quot; style=&quot;float: right;&quot;&gt;
 &lt;p&gt;
    If you've ever needed to produce PDF documents before, in Ruby or another language, you probably know how much it can suck.  &lt;span style=&quot;color: #eeff44&quot;&gt;&lt;b&gt;&lt;i&gt;Prawn takes the pain out of generating beautiful printable documents&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;, while still remaining fast, tiny and nimble.  It is also named after a majestic sea creature, and that has to count for something.     
 &lt;/p&gt;
@@ -43,8 +44,17 @@ a taste of what Prawn based programs looks like, &lt;span style=&quot;color: #eeff44&quot;&gt;&lt;b
 Internationalized text in Prawn is as simple as providing UTF-8 strings for it to render, assuming you've got a Unicode aware TTF font handy.  For those who are running on Ruby 1.9, any encoding that can be converted to UTF-8 will work out of the box!
 &lt;/p&gt;     
 
-&lt;a href=&quot;media/utf8.pdf&quot;&gt;&lt;img src=&quot;media/utf8.png&quot; style=&quot;padding-left: 1.5em;&quot;/&gt;&lt;/a&gt;
-         
+&lt;a href=&quot;media/utf8.pdf&quot;&gt;
+&lt;!-- begin dump from pastie.org/311073 --&gt;
+		&lt;pre class=&quot;textmate-source&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class='support support_class support_class_ruby'&gt;Prawn&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;::&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;Document&lt;/span&gt;&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_with-arguments meta_function-call_method_with-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;generate&lt;/span&gt;&lt;/span&gt;(&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;utf8.pdf&amp;quot;&lt;/span&gt;) &lt;span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'&gt;do&lt;/span&gt;
+  font &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;&lt;span class='source source_ruby source_ruby_embedded source_ruby_embedded_source'&gt;#{&lt;span class='support support_class support_class_ruby'&gt;Prawn&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;::&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;BASEDIR&lt;/span&gt;&lt;/span&gt;}&lt;/span&gt;/data/fonts/DejaVuSans.ttf&amp;quot;&lt;/span&gt;
+  text &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;&#8021;&#945;&#955;&#959;&#957; &#981;&#945;&#947;&#949;&#8150;&#957; &#948;&#973;&#957;&#945;&#956;&#945;&#953;&#183; &#964;&#959;&#8166;&#964;&#959; &#959;&#8020; &#956;&#949; &#946;&#955;&#940;&#960;&#964;&#949;&#953;.&amp;quot;&lt;/span&gt; &lt;span class='keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby'&gt;*&lt;/span&gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;20&lt;/span&gt;
+&lt;span class='keyword keyword_control keyword_control_ruby'&gt;end&lt;/span&gt;
+&lt;/pre&gt;&lt;/pre&gt;
+
+&lt;!-- end pastie dump --&gt;
+&lt;/a&gt;
+
 &lt;h3&gt;-- Easy image embedding&lt;/h3&gt;
   
 &lt;p&gt;
@@ -52,7 +62,22 @@ Prawn makes embedding JPEG and PNG images a breeze.  With support for alpha tran
 including all the graphics you need in your documents.
 &lt;/p&gt;  
 
-&lt;a href=&quot;media/image.pdf&quot;&gt;&lt;img src=&quot;media/images.png&quot; style=&quot;padding-left: 1.5em;&quot;/&gt;&lt;/a&gt;  
+&lt;a href=&quot;media/image.pdf&quot;&gt;
+
+&lt;!-- begin dump from pastie.org/311068 --&gt;
+
+		&lt;pre class=&quot;textmate-source&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class='support support_class support_class_ruby'&gt;Prawn&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;::&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;Document&lt;/span&gt;&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_with-arguments meta_function-call_method_with-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;generate&lt;/span&gt;&lt;/span&gt;(&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;image2.pdf&amp;quot;&lt;/span&gt;, &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:page_layout&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:landscape&lt;/span&gt;) &lt;span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'&gt;do     &lt;/span&gt;
+  pigs &lt;span class='keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby'&gt;=&lt;/span&gt; &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;&lt;span class='source source_ruby source_ruby_embedded source_ruby_embedded_source'&gt;#{&lt;span class='support support_class support_class_ruby'&gt;Prawn&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;::&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;BASEDIR&lt;/span&gt;&lt;/span&gt;}&lt;/span&gt;/data/images/pigs.jpg&amp;quot;&lt;/span&gt; 
+  image pigs, &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:at&lt;/span&gt; =&amp;gt; [&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;50&lt;/span&gt;,&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;450&lt;/span&gt;], &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:width&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;450&lt;/span&gt;                                      
+
+  dice &lt;span class='keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby'&gt;=&lt;/span&gt; &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;&lt;span class='source source_ruby source_ruby_embedded source_ruby_embedded_source'&gt;#{&lt;span class='support support_class support_class_ruby'&gt;Prawn&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;::&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;BASEDIR&lt;/span&gt;&lt;/span&gt;}&lt;/span&gt;/data/images/dice.png&amp;quot;&lt;/span&gt;
+  image dice, &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:at&lt;/span&gt; =&amp;gt; [&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;50&lt;/span&gt;, &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;450&lt;/span&gt;], &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:scale&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;0.75&lt;/span&gt; 
+&lt;span class='keyword keyword_control keyword_control_ruby'&gt;end&lt;/span&gt;
+&lt;/pre&gt;&lt;/pre&gt;
+
+&lt;!-- end pastie dump --&gt;
+
+&lt;/a&gt;
 
 &lt;h3&gt;-- Flexible table drawing&lt;/h3&gt;
 
@@ -63,7 +88,27 @@ documents rather than forcing them to write a ton of low level graphics drawing
 code.
 &lt;/p&gt;   
 
-&lt;a href=&quot;media/fancy_table.pdf&quot;&gt;&lt;img src=&quot;media/tables.png&quot; style=&quot;padding-left: 1.5em;&quot;/&gt;&lt;/a&gt;   
+&lt;a href=&quot;media/fancy_table.pdf&quot;&gt;
+&lt;!-- begin dump from pastie.org/311075 --&gt;  
+
+		&lt;pre class=&quot;textmate-source&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class='support support_class support_class_ruby'&gt;Prawn&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;::&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;Document&lt;/span&gt;&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_with-arguments meta_function-call_method_with-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;generate&lt;/span&gt;&lt;/span&gt;(&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;fancy_table.pdf&amp;quot;&lt;/span&gt;) &lt;span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'&gt;do&lt;/span&gt;
+
+  data &lt;span class='keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby'&gt;=&lt;/span&gt; [[&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;Gregory Brown&amp;quot;&lt;/span&gt;, &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;gregory.t.brown@fakemail.test&amp;quot;&lt;/span&gt; ],
+          [&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;James Healy&amp;quot;&lt;/span&gt;  , &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;jimmy@fakemail.test&amp;quot;&lt;/span&gt;           ],
+          [&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;Ross Perot&amp;quot;&lt;/span&gt;   , &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;ross@fakemail.test&amp;quot;&lt;/span&gt;            ],
+          [&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;Al Gore&amp;quot;&lt;/span&gt;      , &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;al@fakemail.test&amp;quot;&lt;/span&gt;              ],
+          [&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;Ralph Nader&amp;quot;&lt;/span&gt;  , &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;ralph@fakemail.test&amp;quot;&lt;/span&gt;           ]]
+
+  table data,
+    &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:position&lt;/span&gt;           =&amp;gt; &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:center&lt;/span&gt;,
+    &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:headers&lt;/span&gt;            =&amp;gt; [&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;, &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;Email&amp;quot;&lt;/span&gt;],
+    &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:row_colors&lt;/span&gt;         =&amp;gt; [&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;ffffff&amp;quot;&lt;/span&gt;,&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;ffff00&amp;quot;&lt;/span&gt;],
+    &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:vertical_padding&lt;/span&gt;   =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;5&lt;/span&gt;,
+    &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:horizontal_padding&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;3&lt;/span&gt;
+&lt;span class='keyword keyword_control keyword_control_ruby'&gt;end&lt;/span&gt;
+&lt;/pre&gt;&lt;/pre&gt;
+&lt;!-- end pastie dump --&gt;
+&lt;/a&gt;   
 
 &lt;h3&gt;-- Simplified content positioning&lt;/h3&gt;
                                                         
@@ -74,7 +119,34 @@ Text can also be flowed within these sectioned off bounding boxes, so this
 makes it trivial to generate columns of text on the fly.
 &lt;/p&gt;              
 
-&lt;a href=&quot;media/bounding_boxes.pdf&quot;&gt;&lt;img src=&quot;media/bounding_boxes.png&quot;/&gt;&lt;/a&gt;
+&lt;a href=&quot;media/bounding_boxes.pdf&quot;&gt;
+  &lt;!-- begin dump from pastie.org/311081 --&gt;    
+  &lt;pre class=&quot;textmate-source&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class='support support_class support_class_ruby'&gt;Prawn&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;::&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;Document&lt;/span&gt;&lt;/span&gt;&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_with-arguments meta_function-call_method_with-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;generate&lt;/span&gt;&lt;/span&gt;(&lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;bounding_boxes.pdf&amp;quot;&lt;/span&gt;) &lt;span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'&gt;do   &lt;/span&gt;
+
+  bounding_box [&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;100&lt;/span&gt;,&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;600&lt;/span&gt;], &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:width&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;200&lt;/span&gt; &lt;span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'&gt;do&lt;/span&gt;
+    text &lt;span class='string string_quoted string_quoted_double string_quoted_double_ruby'&gt;&amp;quot;The rain in spain falls mainly on the plains &amp;quot;&lt;/span&gt; &lt;span class='keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby'&gt;*&lt;/span&gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;5&lt;/span&gt;
+    stroke &lt;span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'&gt;do&lt;/span&gt;
+      line bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;top_left&lt;/span&gt;&lt;/span&gt;,    bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;top_right&lt;/span&gt;&lt;/span&gt;
+      line bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;bottom_left&lt;/span&gt;&lt;/span&gt;, bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;bottom_right&lt;/span&gt;&lt;/span&gt;
+    &lt;span class='keyword keyword_control keyword_control_ruby'&gt;end&lt;/span&gt;
+  &lt;span class='keyword keyword_control keyword_control_ruby'&gt;end&lt;/span&gt;
+
+  bounding_box [&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;100&lt;/span&gt;,&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;500&lt;/span&gt;], &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:width&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;200&lt;/span&gt;, &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:height&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;200&lt;/span&gt; &lt;span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'&gt;do&lt;/span&gt;
+    stroke &lt;span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'&gt;do&lt;/span&gt;
+      circle_at [&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;100&lt;/span&gt;,&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;100&lt;/span&gt;], &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:radius&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;100&lt;/span&gt;
+      line bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;top_left&lt;/span&gt;&lt;/span&gt;, bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;bottom_right&lt;/span&gt;&lt;/span&gt;
+      line bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;top_right&lt;/span&gt;&lt;/span&gt;, bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;bottom_left&lt;/span&gt;&lt;/span&gt;
+    &lt;span class='keyword keyword_control keyword_control_ruby'&gt;end&lt;/span&gt;   
+
+    bounding_box [&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;50&lt;/span&gt;,&lt;span class='constant constant_numeric constant_numeric_ruby'&gt;150&lt;/span&gt;], &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:width&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;100&lt;/span&gt;, &lt;span class='constant constant_other constant_other_symbol constant_other_symbol_ruby'&gt;:height&lt;/span&gt; =&amp;gt; &lt;span class='constant constant_numeric constant_numeric_ruby'&gt;100&lt;/span&gt; &lt;span class='keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block'&gt;do&lt;/span&gt;
+      stroke_rectangle bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;top_left&lt;/span&gt;&lt;/span&gt;, bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;width&lt;/span&gt;&lt;/span&gt;, bounds&lt;span class='meta meta_function-call meta_function-call_method meta_function-call_method_without-arguments meta_function-call_method_without-arguments_ruby'&gt;.&lt;span class='entity entity_name entity_name_function entity_name_function_ruby'&gt;height&lt;/span&gt;&lt;/span&gt;
+    &lt;span class='keyword keyword_control keyword_control_ruby'&gt;end&lt;/span&gt;   
+  &lt;span class='keyword keyword_control keyword_control_ruby'&gt;end&lt;/span&gt;
+&lt;span class='keyword keyword_control keyword_control_ruby'&gt;end&lt;/span&gt;
+  &lt;/pre&gt;&lt;/pre&gt;
+
+  &lt;!-- end pastie dump --&gt;  
+&lt;/a&gt;
 
 &lt;h3&gt;-- And loads more to come&lt;/h3&gt;
 </diff>
      <filename>www/index.html</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>bugs/table_suppress_newline.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/datatypes.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/encodings.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/exceptions.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/file.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/fontchunk.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/cmap.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/cvt.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/fpgm.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/gasp.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/glyf.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/head.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/hhea.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/hmtx.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/kern.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/loca.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/maxp.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/name.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/os2.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/post.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/prep.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/vhea.rb</filename>
    </removed>
    <removed>
      <filename>vendor/font_ttf/ttf/table/vmtx.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>97ccf8c5c73731e85b31721d0498f4fd207418b8</id>
    </parent>
    <parent>
      <id>12b6d86f0c776d1bff574522fe23a41fb9701507</id>
    </parent>
  </parents>
  <author>
    <name>Gregory Brown</name>
    <email>gregory.t.brown@gmail.com</email>
  </author>
  <url>http://github.com/sandal/prawn/commit/b9a29efbeadd596653c9bf30328e5ae086a72ebb</url>
  <id>b9a29efbeadd596653c9bf30328e5ae086a72ebb</id>
  <committed-date>2008-12-15T20:08:29-08:00</committed-date>
  <authored-date>2008-12-15T20:08:29-08:00</authored-date>
  <message>Resolve conflicts</message>
  <tree>3d83ce9a0e22e00e80a0f05a884e90263d8d8c18</tree>
  <committer>
    <name>Gregory Brown</name>
    <email>gregory.t.brown@gmail.com</email>
  </committer>
</commit>
