prawn-fillform 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -77,10 +77,13 @@ module Prawn
77
77
  end
78
78
 
79
79
  def font_size
80
+ return 12.0 unless deref(@dictionary[:DA])
80
81
  deref(@dictionary[:DA]).split(" ")[1].to_f
81
82
  end
82
83
 
83
84
  def font_style
85
+ return :normal unless deref(@dictionary[:DA])
86
+
84
87
  style = case deref(@dictionary[:DA]).split(" ")[0].split(",").last.to_s.downcase
85
88
  when "bold" then :bold
86
89
  when "italic" then :italic
@@ -93,6 +96,7 @@ module Prawn
93
96
  end
94
97
 
95
98
  def font_color
99
+ return "0000" unless deref(@dictionary[:DA])
96
100
  Prawn::Graphics::Color.rgb2hex(deref(@dictionary[:DA]).split(" ")[3..5].collect { |e| e.to_f * 255 }).to_s
97
101
  end
98
102
 
@@ -214,8 +218,11 @@ module Prawn
214
218
  fields.each do |field|
215
219
  number = page.to_s.split("_").last.to_i
216
220
  go_to_page(number)
217
- value = data[page][field.name].fetch(:value) rescue nil
218
- options = data[page][field.name].fetch(:options) rescue nil
221
+
222
+ field_hash = data[page].try(:[], field.name) || data[field.name]
223
+
224
+ value = field_hash.fetch(:value) rescue nil
225
+ options = field_hash.fetch(:options) rescue nil
219
226
  options ||= {}
220
227
 
221
228
  if value
@@ -231,7 +238,9 @@ module Prawn
231
238
  :width => options[:width] || field.width,
232
239
  :height => options[:height] || field.height,
233
240
  :valign => options[:valign] || :center,
234
- :size => options[:font_size] || field.font_size,
241
+
242
+ # Default to the document font size if the field size is 0
243
+ :size => options[:font_size] || ((size = field.font_size) > 0.0 ? size : font_size),
235
244
  :style => options[:font_style] || field.font_style
236
245
  elsif field.type == :button
237
246
 
@@ -1,7 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Prawn
3
3
  module Fillform
4
- VERSION = "0.0.15"
4
+ VERSION = "0.0.16"
5
5
  end
6
6
  end
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-fillform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-16 00:00:00.000000000 Z
12
+ date: 2013-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: prawn