public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
And now our text powers have aligned
sandal (author)
Thu Jul 24 14:42:59 -0700 2008
commit  68c7b1347810db4e12bbd6d24f4d306d167151ab
tree    eff8f538c1b18a0c36f7c20d6f11563a31e8246e
parent  34f1e35fbe793282542243234adb150a8d4c0251
...
41
42
43
44
45
46
47
...
157
158
159
160
 
 
161
162
163
...
171
172
173
 
 
 
 
 
 
 
 
 
 
 
174
175
176
177
178
 
179
180
181
...
41
42
43
 
44
45
46
...
156
157
158
 
159
160
161
162
163
...
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
 
189
190
191
192
0
@@ -41,7 +41,6 @@ module Prawn
0
       # wanted it usually means the current font doesn't include that character.
0
       #
0
       def text(text,options={})
0
-
0
         # check the string is encoded sanely
0
         normalize_encoding(text)
0
 
0
@@ -157,7 +156,8 @@ module Prawn
0
       end
0
 
0
       # TODO: Get kerning working with wrapped text
0
-      def wrapped_text(text,options)
0
+      def wrapped_text(text,options) 
0
+        options[:align] ||= :left
0
         font_size(options[:size] || current_font_size) do
0
           font_name = font_registry[fonts[@font]]
0
 
0
@@ -171,11 +171,22 @@ module Prawn
0
             move_text_position(@font_metrics.font_height(current_font_size) +
0
                            @font_metrics.descender / 1000.0 * current_font_size)  
0
                                
0
+                           
0
+            line_width = text_width(e,font_size)
0
+            case(options[:align]) 
0
+            when :left
0
+              x = @bounding_box.absolute_left
0
+            when :center
0
+              x = @bounding_box.absolute_left + 
0
+                (@bounding_box.width - line_width) / 2.0
0
+            when :right
0
+              x = @bounding_box.absolute_right - line_width
0
+            end
0
                                
0
             add_content %Q{
0
               BT
0
               /#{font_name} #{current_font_size} Tf
0
-              #{@bounding_box.absolute_left} #{y} Td
0
+              #{x} #{y} Td
0
             }    
0
              
0
            add_content Prawn::PdfObject(@font_metrics.convert_text(e,options)) << 

Comments