public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
Kern also prepares the string for the TJ operator now.  Perhaps it needs a 
better name?
sandal (author)
Mon Jul 21 10:52:38 -0700 2008
commit  5b085020154b07cd031951b877b14858900ca90e
tree    506582d52c2bc468dbc1b40503207512176b68fb
parent  aeb22386528574317e9babd84904fc3ef0c458fd
...
107
108
109
110
111
112
113
114
 
 
 
115
116
117
...
142
143
144
145
146
 
 
147
148
149
...
151
152
153
154
 
 
 
 
155
156
157
...
107
108
109
 
 
 
 
 
110
111
112
113
114
115
...
140
141
142
 
 
143
144
145
146
147
...
149
150
151
 
152
153
154
155
156
157
158
0
@@ -107,11 +107,9 @@ module Prawn
0
         
0
         @row_colors = ["ffffff","cccccc"] if @row_colors == :pdf_writer
0
 
0
-        @original_row_colors = @row_colors.dup if @row_colors
0
-        calculate_column_widths
0
-        (options[:widths] || {}).each do |index,width| 
0
-          @col_widths[index] = width
0
-        end
0
+        @original_row_colors = @row_colors.dup if @row_colors  
0
+        
0
+        calculate_column_widths(options[:widths])
0
       end
0
       
0
       # Width of the table in PDF points
0
@@ -142,8 +140,8 @@ module Prawn
0
 
0
       private
0
 
0
-      def calculate_column_widths
0
-        @col_widths = [0] * @data[0].length
0
+      def calculate_column_widths(manual_widths=nil)
0
+        @col_widths = [0] * @data[0].length    
0
         renderable_data.each do |row|
0
           row.each_with_index do |cell,i|
0
             length = cell.lines.map { |e| 
0
@@ -151,7 +149,10 @@ module Prawn
0
                 2*@horizontal_padding
0
             @col_widths[i] = length if length > @col_widths[i]
0
           end
0
-        end
0
+        end  
0
+        
0
+        # TODO: Could optimize here
0
+        manual_widths.each { |k,v| @col_widths[k] = v } if manual_widths           
0
       end
0
 
0
       def renderable_data
...
93
94
95
96
 
97
98
99
100
 
 
101
102
103
...
93
94
95
 
96
97
98
 
 
99
100
101
102
103
0
@@ -93,11 +93,11 @@ module Prawn
0
           scale = font_size / 1000.0
0
           
0
           if options[:kerning]
0
-            kern(string).inject(0) do |s,r|
0
+            kern(string).inject(0) do |s,r|   
0
               if r.is_a? String
0
                 s + string_width(r, font_size, :kerning => false)
0
-              else
0
-                s + (r * scale)
0
+              else 
0
+                s - (r * scale)
0
               end
0
             end
0
           else
...
17
18
19
20
21
22
23
 
 
 
 
24
25
26
...
41
42
43
44
 
45
46
47
48
49
50
51
52
 
 
 
 
 
53
54
55
56
...
17
18
19
 
 
 
 
20
21
22
23
24
25
26
...
41
42
43
 
44
45
46
47
48
49
50
 
 
51
52
53
54
55
56
57
58
59
0
@@ -17,10 +17,10 @@ describe "adobe font metrics" do
0
   end
0
   
0
   it "should kern a string" do
0
-    @times.kern("To").should == ["T", -80, "o"]
0
-    @times.kern("Télé").should == ["T", -70, "élé"]
0
-    @times.kern("Technology").should == ["T", -70, "echnology"]
0
-    @times.kern("Technology...").should == ["T", -70, "echnology", -65, "..."]
0
+    @times.kern("To").should == ["T", 80, "o"]
0
+    @times.kern("Télé").should == ["T", 70, "élé"]
0
+    @times.kern("Technology").should == ["T", 70, "echnology"]
0
+    @times.kern("Technology...").should == ["T", 70, "echnology", 65, "..."]
0
   end
0
   
0
 end
0
@@ -41,15 +41,18 @@ describe "ttf font metrics" do
0
   end
0
   
0
   it "should kern a string" do
0
-    @activa.kern("To").should == ["T", -186, "o"]
0
+    @activa.kern("To").should == ["\0007", 186.0, "\000R"]
0
     
0
     # Does activa use kerning classes here? Ruby/TTF doesn't support
0
     # format 2 kerning tables, so don't bother for now.
0
     
0
     # @activa.kern("Télé").should == ["T", -186, "élé"]
0
     
0
-    @activa.kern("Technology").should == ["T", -186, "echnology"]
0
-    @activa.kern("Technology...").should == ["T", -186, "echnology", -88, "..."]
0
+    @activa.kern("Technology").should == ["\0007", 186.0, 
0
+      "\000H\000F\000K\000Q\000R\000O\000R\000J\000\\"]
0
+    @activa.kern("Technology...").should == ["\0007", 186.0,
0
+       "\000H\000F\000K\000Q\000R\000O\000R\000J\000\\", 88.0, 
0
+       "\000\021\000\021\000\021"] 
0
   end
0
   
0
 end
0
\ No newline at end of file

Comments