public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
Add text_options and show it in example [#67]
sandal (author)
Wed Aug 20 14:57:14 -0700 2008
commit  a0ab8506c98b78e95e4e7f07031a68a2d8127c21
tree    69dc18d18910c9c8c8c71bdcc9f4cc51d0037a27
parent  120aad1401ec1d51f655b4ca71af7621428d86b8
...
5
6
7
8
 
 
9
10
 
 
 
 
 
 
11
...
5
6
7
 
8
9
10
 
11
12
13
14
15
16
17
0
@@ -5,7 +5,13 @@ require "prawn"
0
 
0
 start = Time.now
0
 Prawn::Document.generate("chinese_flow.pdf") do  
0
-  font "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
0
+  font "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"   
0
+  text_options.update(:wrap => :character, :size => 16)
0
   long_text = "更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事"                                                       
0
-  text long_text, :wrap => :character 
0
+  text long_text
0
+  
0
+  # be sure to restore space based wrapping when dealing with latin scripts
0
+  text_options.update(:wrap => :spaces)
0
+  long_text = "Text with some spaces " * 25
0
+  text long_text
0
 end
...
21
22
23
24
 
25
26
27
...
79
80
81
 
82
83
84
...
21
22
23
 
24
25
26
27
...
79
80
81
82
83
84
85
0
@@ -21,7 +21,7 @@ module Prawn
0
     include PageGeometry                             
0
     
0
     attr_accessor :y, :margin_box
0
-    attr_reader   :margins, :page_size, :page_layout
0
+    attr_reader   :margins, :page_size, :page_layout, :text_options
0
       
0
     # Creates and renders a PDF document. 
0
     #
0
@@ -79,6 +79,7 @@ module Prawn
0
        @page_layout     = options[:page_layout] || :portrait
0
        @compress        = options[:compress] || false                
0
        @skip_encoding   = options[:skip_encoding]
0
+       @text_options    = options[:text_options] || {}
0
              
0
        @margins = { :left   => options[:left_margin]   || 36,
0
                     :right  => options[:right_margin]  || 36,  
...
42
43
44
45
 
46
47
48
49
 
 
50
51
52
...
42
43
44
 
45
46
47
48
49
50
51
52
53
54
0
@@ -42,11 +42,13 @@ module Prawn
0
       # If an empty box is rendered to your PDF instead of the character you 
0
       # wanted it usually means the current font doesn't include that character.
0
       #
0
-      def text(text,options={})
0
+      def text(text,options={})            
0
         # we'll be messing with the strings encoding, don't change the users
0
         # original string
0
         text = text.dup                    
0
         
0
+        options = text_options.merge(options)  
0
+        
0
         original_font  = font.name                                              
0
         
0
         if options[:style]  

Comments