public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
build page resources on the fly
James Healy (author)
Thu Jul 17 05:21:44 -0700 2008
sandal (committer)
Thu Jul 24 09:11:21 -0700 2008
commit  8ea4927409c573f37f29a05d5e21100b4ad37a31
tree    d1ee62500354a86e514ea4aae2bcb9871138bf98
parent  5af67a2ddeff41a17a695e5718ec82054e06e06c
...
118
119
120
121
122
123
 
124
125
126
...
250
251
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
254
255
...
118
119
120
 
 
 
121
122
123
124
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
0
@@ -118,9 +118,7 @@ module Prawn
0
        @current_page = ref(:Type      => :Page, 
0
                            :Parent    => @pages, 
0
                            :MediaBox  => page_dimensions, 
0
-                           :Contents  => @page_content,
0
-                           :ProcSet   => font_proc,
0
-                           :Resources => { :Font => {} } ) 
0
+                           :Contents  => @page_content)
0
        set_current_font    
0
        update_colors
0
        @pages.data[:Kids] << @current_page
0
@@ -250,6 +248,26 @@ module Prawn
0
     def add_content(str)
0
      @page_content << str << "\n"
0
     end  
0
+
0
+    # Add a new type to the current pages ProcSet
0
+    def register_proc(type)
0
+      @current_page.data[:ProcSet] ||= ref([])
0
+      unless @current_page.data[:ProcSet].data.include?(type)
0
+        @current_page.data[:ProcSet].data << type
0
+      end
0
+    end
0
+
0
+    def page_resources
0
+      @current_page.data[:Resources] ||= {}
0
+    end
0
+
0
+    def page_fonts
0
+      page_resources[:Font] ||= {}
0
+    end
0
+
0
+    def page_xobjects
0
+      page_resources[:XObject] ||= {}
0
+    end
0
     
0
     def finish_page_content     
0
       @page_stop_proc[self] if @page_stop_proc
...
96
97
98
 
 
99
100
101
...
297
298
299
300
 
301
302
303
...
310
311
312
313
314
315
316
317
318
319
...
96
97
98
99
100
101
102
103
...
299
300
301
 
302
303
304
305
...
312
313
314
 
 
 
 
315
316
317
0
@@ -96,6 +96,8 @@ module Prawn
0
       # more portable.
0
       #
0
       def font(name)
0
+        register_proc :PDF
0
+        register_proc :Text
0
         @font_metrics = Prawn::Font::Metrics[name]
0
         case(name)
0
         when /\.ttf$/
0
@@ -297,7 +299,7 @@ module Prawn
0
         return if @font.nil?
0
         font_registry[fonts[@font]] ||= :"F#{font_registry.size + 1}"
0
 
0
-        @current_page.data[:Resources][:Font].merge!(
0
+        page_fonts.merge!(
0
           font_registry[fonts[@font]] => fonts[@font]
0
         )
0
       end
0
@@ -310,10 +312,6 @@ module Prawn
0
         @font_registry ||= {}
0
       end
0
 
0
-      def font_proc #:nodoc:
0
-        @font_proc ||= ref [:PDF, :Text]
0
-      end
0
-
0
       def fonts #:nodoc:
0
         @fonts ||= {}
0
       end

Comments