public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
Cleanup more minor issues
sandal (author)
Mon Jul 21 13:09:59 -0700 2008
commit  a22c3b568dd29e29bea254e2d99f89d87809e48a
tree    c6f9ad67d55cbbe20c988a373a61835596cae77d
parent  fbf50793597f1ebaed9b77395e9cacfc86b78bed
...
101
102
103
 
 
104
105
106
...
101
102
103
104
105
106
107
108
0
@@ -101,6 +101,8 @@ module Prawn
0
        )                                 
0
              
0
        # update bounding box if not flowing from the previous page
0
+       # TODO: This may have a bug where the old margin is restored
0
+       # when the bounding box exits.
0
        @bounding_box = @margin_box if old_margin_box == @bounding_box              
0
      end
0
             
...
172
173
174
175
176
177
178
179
180
181
 
 
 
 
 
 
 
 
182
183
184
 
185
186
187
...
191
192
193
194
195
196
197
...
202
203
204
205
206
207
208
...
172
173
174
 
 
 
 
 
 
 
175
176
177
178
179
180
181
182
183
184
 
185
186
187
188
...
192
193
194
 
195
196
197
...
202
203
204
 
205
206
207
0
@@ -172,16 +172,17 @@ module Prawn
0
           renderable_data.each_with_index do |row,index|
0
             c = Prawn::Graphics::CellBlock.new(@document)
0
             row.each_with_index do |e,i|
0
-              c << Prawn::Graphics::Cell.new(:document => @document, 
0
-                                             :text     => e, 
0
-                                             :width    => @col_widths[i],
0
-                                             :horizontal_padding => @horizontal_padding,
0
-                                             :vertical_padding => @vertical_padding,
0
-                                             :border   => @border,
0
-                                             :border_style => :sides )
0
+              c << Prawn::Graphics::Cell.new(
0
+                :document => @document, 
0
+                :text     => e, 
0
+                :width    => @col_widths[i],
0
+                :horizontal_padding => @horizontal_padding,
0
+                :vertical_padding => @vertical_padding,
0
+                :border   => @border,
0
+                :border_style => :sides )    
0
             end
0
 
0
-            if c.height > (x= y_pos - @document.margin_box.absolute_bottom)
0
+            if c.height > y_pos - @document.margin_box.absolute_bottom
0
               draw_page(page_contents)
0
               @document.start_new_page
0
               if @headers
0
@@ -191,7 +192,6 @@ module Prawn
0
                 page_contents = []
0
                 y_pos = @document.y
0
               end
0
-
0
             end
0
 
0
             page_contents << c
0
@@ -202,7 +202,6 @@ module Prawn
0
               draw_page(page_contents)
0
             end
0
 
0
-
0
           end
0
           @document.y -= @vertical_padding
0
         end
...
78
79
80
 
81
82
83
...
167
168
169
170
171
172
173
 
174
175
176
...
187
188
189
190
 
 
191
192
 
193
194
195
...
78
79
80
81
82
83
84
...
168
169
170
 
 
 
 
171
172
173
174
...
185
186
187
 
188
189
190
 
191
192
193
194
0
@@ -78,6 +78,7 @@ module Prawn
0
         font "Helvetica" unless fonts[@font]
0
 
0
         return wrapped_text(text,options) unless options[:at]
0
+        
0
         x,y = translate(options[:at])
0
         font_size(options[:size] || current_font_size) do
0
           font_name = font_registry[fonts[@font]]          
0
@@ -167,10 +168,7 @@ module Prawn
0
       private
0
 
0
       def move_text_position(dy)
0
-         if (y - dy) < @margin_box.absolute_bottom
0
-           return start_new_page
0
-         end
0
-         self.y -= dy
0
+         (y - dy) < @margin_box.absolute_bottom ? start_new_page : self.y -= dy       
0
       end
0
 
0
       def text_width(text,size)
0
@@ -187,9 +185,10 @@ module Prawn
0
 
0
           lines = text.lines
0
 
0
-          lines.each do |e|
0
+          lines.each do |e|    
0
+            
0
             move_text_position(@font_metrics.font_height(current_font_size) +
0
-                               @font_metrics.descender / 1000.0 * current_font_size)  
0
+                           @font_metrics.descender / 1000.0 * current_font_size)  
0
                                
0
                                
0
             add_content %Q{
...
357
358
359
360
 
 
361
362
363
...
357
358
359
 
360
361
362
363
364
0
@@ -357,7 +357,8 @@ module Prawn
0
         def kern_pairs_table
0
           return @kern_pairs_table if @kern_pairs_table
0
           
0
-          table = @ttf.get_table(:kern).subtables.find { |s| s.is_a? ::Font::TTF::Table::Kern::KerningSubtable0 }
0
+          table = @ttf.get_table(:kern).subtables.find { |s| 
0
+            s.is_a? ::Font::TTF::Table::Kern::KerningSubtable0 }
0
           
0
           if table
0
             @kern_pairs_table ||= table.kerning_pairs.inject({}) do |h,p|
...
17
18
19
20
 
 
21
22
23
...
17
18
19
 
20
21
22
23
24
0
@@ -17,7 +17,8 @@ module Prawn
0
           segments = line.scan(/\S+|\s+/)
0
                                         
0
           segments.each do |segment|    
0
-            segment_width = string_width(segment, font_size, :kerning => options[:kerning]) 
0
+            segment_width = string_width(segment, font_size, 
0
+              :kerning => options[:kerning]) 
0
       
0
             if (accumulated_width + segment_width).round > line_width.round
0
               output << "\n"
...
70
71
72
73
 
 
 
 
 
74
75
76
...
84
85
86
87
88
89
90
91
92
93
94
...
70
71
72
 
73
74
75
76
77
78
79
80
...
88
89
90
 
 
 
 
 
91
92
93
0
@@ -70,7 +70,11 @@ module Prawn
0
       x,y = translate(point)
0
       add_content("%.3f %.3f %.3f %.3f re" % [ x, y - height, width, height ])      
0
     end
0
-                         
0
+       
0
+    ###########################################################
0
+    #  Higher level functions: May use relative coords        #   
0
+    ########################################################### 
0
+      
0
     # Sets line thickness to the <tt>width</tt> specified.
0
     #
0
     def line_width=(width)
0
@@ -84,11 +88,6 @@ module Prawn
0
       @line_width || 1
0
     end
0
        
0
-    ###########################################################
0
-    #  Higher level functions: May use relative coords        #   
0
-    ########################################################### 
0
-     
0
-     
0
     # Draws a line from one point to another. Points may be specified as 
0
     # tuples or flattened argument list:
0
     #
...
14
15
16
17
 
 
18
19
20
...
191
192
193
194
 
 
195
196
197
...
14
15
16
 
17
18
19
20
21
...
192
193
194
 
195
196
197
198
199
0
@@ -14,7 +14,8 @@ module Prawn
0
     #    end
0
     #
0
     def cell(point, options={})
0
-      Prawn::Graphics::Cell.new(options.merge(:document => self, :point => point)).draw
0
+      Prawn::Graphics::Cell.new(
0
+        options.merge(:document => self, :point => point)).draw
0
     end
0
   end
0
 
0
@@ -191,7 +192,8 @@ module Prawn
0
         end
0
 
0
         @cells.each do |e|
0
-          e.point  = [x - @document.bounds.absolute_left, y - @document.bounds.absolute_bottom]
0
+          e.point  = [x - @document.bounds.absolute_left, 
0
+                      y - @document.bounds.absolute_bottom]
0
           e.height = @height
0
           e.draw
0
           x += e.width

Comments