prawn 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +7 -5
- data/lib/prawn.rb +4 -4
- data/lib/prawn/document.rb +47 -46
- data/lib/prawn/document/bounding_box.rb +13 -19
- data/lib/prawn/document/column_box.rb +3 -5
- data/lib/prawn/document/internals.rb +0 -1
- data/lib/prawn/document/span.rb +12 -12
- data/lib/prawn/errors.rb +32 -33
- data/lib/prawn/font.rb +29 -36
- data/lib/prawn/font/afm.rb +20 -20
- data/lib/prawn/font/dfont.rb +0 -1
- data/lib/prawn/font/ttf.rb +30 -27
- data/lib/prawn/font_metric_cache.rb +4 -8
- data/lib/prawn/graphics.rb +37 -42
- data/lib/prawn/graphics/cap_style.rb +1 -1
- data/lib/prawn/graphics/color.rb +21 -23
- data/lib/prawn/graphics/dash.rb +5 -6
- data/lib/prawn/graphics/join_style.rb +1 -2
- data/lib/prawn/graphics/patterns.rb +25 -21
- data/lib/prawn/graphics/transformation.rb +4 -5
- data/lib/prawn/graphics/transparency.rb +6 -8
- data/lib/prawn/grid.rb +21 -14
- data/lib/prawn/image_handler.rb +2 -2
- data/lib/prawn/images.rb +29 -31
- data/lib/prawn/images/image.rb +1 -1
- data/lib/prawn/images/jpg.rb +10 -12
- data/lib/prawn/images/png.rb +13 -13
- data/lib/prawn/measurements.rb +7 -14
- data/lib/prawn/outline.rb +6 -6
- data/lib/prawn/repeater.rb +1 -5
- data/lib/prawn/security.rb +17 -25
- data/lib/prawn/security/arcfour.rb +1 -1
- data/lib/prawn/soft_mask.rb +11 -12
- data/lib/prawn/stamp.rb +16 -8
- data/lib/prawn/text.rb +23 -20
- data/lib/prawn/text/box.rb +3 -6
- data/lib/prawn/text/formatted/arranger.rb +9 -12
- data/lib/prawn/text/formatted/box.rb +23 -22
- data/lib/prawn/text/formatted/fragment.rb +0 -4
- data/lib/prawn/text/formatted/line_wrap.rb +13 -24
- data/lib/prawn/text/formatted/parser.rb +16 -20
- data/lib/prawn/text/formatted/wrap.rb +2 -7
- data/lib/prawn/utilities.rb +6 -3
- data/lib/prawn/version.rb +1 -1
- data/manual/basic_concepts/basic_concepts.rb +0 -2
- data/manual/basic_concepts/view.rb +1 -1
- data/manual/bounding_box/bounding_box.rb +0 -3
- data/manual/bounding_box/russian_boxes.rb +7 -8
- data/manual/bounding_box/stretchy.rb +0 -1
- data/manual/contents.rb +2 -2
- data/manual/cover.rb +11 -12
- data/manual/document_and_page_options/document_and_page_options.rb +2 -5
- data/manual/document_and_page_options/metadata.rb +10 -10
- data/manual/document_and_page_options/page_size.rb +0 -1
- data/manual/graphics/fill_rules.rb +5 -4
- data/manual/graphics/graphics.rb +0 -3
- data/manual/graphics/lines_and_curves.rb +1 -1
- data/manual/graphics/rotate.rb +0 -2
- data/manual/graphics/scale.rb +4 -2
- data/manual/graphics/soft_masks.rb +0 -1
- data/manual/graphics/stroke_cap.rb +1 -1
- data/manual/graphics/stroke_join.rb +1 -1
- data/manual/graphics/translate.rb +3 -3
- data/manual/graphics/transparency.rb +0 -1
- data/manual/how_to_read_this_manual.rb +0 -1
- data/manual/images/images.rb +0 -3
- data/manual/layout/boxes.rb +5 -5
- data/manual/layout/content.rb +2 -2
- data/manual/layout/layout.rb +0 -3
- data/manual/outline/outline.rb +0 -3
- data/manual/repeatable_content/page_numbering.rb +1 -1
- data/manual/repeatable_content/repeatable_content.rb +0 -3
- data/manual/repeatable_content/repeater.rb +6 -6
- data/manual/security/encryption.rb +0 -2
- data/manual/security/permissions.rb +0 -2
- data/manual/security/security.rb +0 -3
- data/manual/text/alignment.rb +3 -3
- data/manual/text/color.rb +0 -1
- data/manual/text/column_box.rb +0 -1
- data/manual/text/fallback_fonts.rb +2 -2
- data/manual/text/formatted_callbacks.rb +3 -2
- data/manual/text/paragraph_indentation.rb +2 -3
- data/manual/text/registering_families.rb +13 -9
- data/manual/text/rotation.rb +0 -1
- data/manual/text/text.rb +0 -3
- data/manual/text/text_box_overflow.rb +7 -5
- data/manual/text/utf8.rb +1 -1
- data/manual/text/win_ansi_charset.rb +2 -2
- data/prawn.gemspec +4 -4
- data/spec/acceptance/png.rb +6 -7
- data/spec/annotations_spec.rb +21 -28
- data/spec/bounding_box_spec.rb +100 -109
- data/spec/column_box_spec.rb +26 -32
- data/spec/destinations_spec.rb +2 -4
- data/spec/document_spec.rb +145 -151
- data/spec/extensions/mocha.rb +0 -1
- data/spec/font_metric_cache_spec.rb +7 -7
- data/spec/font_spec.rb +103 -102
- data/spec/formatted_text_arranger_spec.rb +76 -74
- data/spec/formatted_text_box_spec.rb +170 -159
- data/spec/formatted_text_fragment_spec.rb +57 -56
- data/spec/graphics_spec.rb +158 -175
- data/spec/grid_spec.rb +28 -29
- data/spec/image_handler_spec.rb +4 -5
- data/spec/images_spec.rb +50 -36
- data/spec/inline_formatted_text_parser_spec.rb +397 -393
- data/spec/jpg_spec.rb +4 -6
- data/spec/line_wrap_spec.rb +54 -55
- data/spec/measurement_units_spec.rb +12 -15
- data/spec/outline_spec.rb +77 -98
- data/spec/png_spec.rb +55 -65
- data/spec/reference_spec.rb +3 -3
- data/spec/repeater_spec.rb +20 -26
- data/spec/security_spec.rb +42 -49
- data/spec/soft_mask_spec.rb +4 -5
- data/spec/span_spec.rb +5 -6
- data/spec/spec_helper.rb +2 -4
- data/spec/stamp_spec.rb +41 -22
- data/spec/stroke_styles_spec.rb +36 -39
- data/spec/text_at_spec.rb +28 -29
- data/spec/text_box_spec.rb +160 -165
- data/spec/text_rendering_mode_spec.rb +9 -9
- data/spec/text_spacing_spec.rb +13 -13
- data/spec/text_spec.rb +116 -124
- data/spec/text_with_inline_formatting_spec.rb +5 -5
- data/spec/transparency_spec.rb +20 -20
- data/spec/view_spec.rb +0 -1
- metadata +7 -7
@@ -40,7 +40,7 @@ module Prawn
|
|
40
40
|
# pdf.stroke_rectangle([x, y], width, height)
|
41
41
|
# end
|
42
42
|
#
|
43
|
-
def rotate(angle, options={}, &block)
|
43
|
+
def rotate(angle, options = {}, &block)
|
44
44
|
Prawn.verify_options(:origin, options)
|
45
45
|
rad = degree_to_rad(angle)
|
46
46
|
cos = Math.cos(rad)
|
@@ -48,7 +48,7 @@ module Prawn
|
|
48
48
|
if options[:origin].nil?
|
49
49
|
transformation_matrix(cos, sin, -sin, cos, 0, 0, &block)
|
50
50
|
else
|
51
|
-
|
51
|
+
fail Prawn::Errors::BlockRequired unless block_given?
|
52
52
|
x = options[:origin][0] + bounds.absolute_left
|
53
53
|
y = options[:origin][1] + bounds.absolute_bottom
|
54
54
|
x_prime = x * cos - y * sin
|
@@ -112,12 +112,12 @@ module Prawn
|
|
112
112
|
# pdf.stroke_rectangle([x, y], width, height)
|
113
113
|
# end
|
114
114
|
#
|
115
|
-
def scale(factor, options={}, &block)
|
115
|
+
def scale(factor, options = {}, &block)
|
116
116
|
Prawn.verify_options(:origin, options)
|
117
117
|
if options[:origin].nil?
|
118
118
|
transformation_matrix(factor, 0, 0, factor, 0, 0, &block)
|
119
119
|
else
|
120
|
-
|
120
|
+
fail Prawn::Errors::BlockRequired unless block_given?
|
121
121
|
x = options[:origin][0] + bounds.absolute_left
|
122
122
|
y = options[:origin][1] + bounds.absolute_bottom
|
123
123
|
x_prime = factor * x
|
@@ -151,7 +151,6 @@ module Prawn
|
|
151
151
|
restore_graphics_state
|
152
152
|
end
|
153
153
|
end
|
154
|
-
|
155
154
|
end
|
156
155
|
end
|
157
156
|
end
|
@@ -9,7 +9,6 @@
|
|
9
9
|
|
10
10
|
module Prawn
|
11
11
|
module Graphics
|
12
|
-
|
13
12
|
# The Prawn::Transparency module is used to place transparent
|
14
13
|
# content on the page. It has the capacity for separate
|
15
14
|
# transparency values for stroked content and all other content.
|
@@ -29,7 +28,6 @@ module Prawn
|
|
29
28
|
# end
|
30
29
|
#
|
31
30
|
module Transparency
|
32
|
-
|
33
31
|
# @group Stable API
|
34
32
|
|
35
33
|
# Sets the <tt>opacity</tt> and <tt>stroke_opacity</tt> for all
|
@@ -53,7 +51,7 @@ module Prawn
|
|
53
51
|
# pdf.fill_and_stroke_circle([x, y], 25)
|
54
52
|
# end
|
55
53
|
#
|
56
|
-
def transparent(opacity, stroke_opacity=opacity, &block)
|
54
|
+
def transparent(opacity, stroke_opacity = opacity, &block)
|
57
55
|
renderer.min_version(1.4)
|
58
56
|
|
59
57
|
opacity = [[opacity, 0.0].max, 1.0].min
|
@@ -82,10 +80,11 @@ module Prawn
|
|
82
80
|
dictionary = opacity_dictionary_registry[key][:obj]
|
83
81
|
dictionary_name = opacity_dictionary_registry[key][:name]
|
84
82
|
else
|
85
|
-
dictionary = ref!(
|
86
|
-
|
87
|
-
|
88
|
-
|
83
|
+
dictionary = ref!(
|
84
|
+
:Type => :ExtGState,
|
85
|
+
:CA => stroke_opacity,
|
86
|
+
:ca => opacity
|
87
|
+
)
|
89
88
|
|
90
89
|
dictionary_name = "Tr#{next_opacity_dictionary_id}"
|
91
90
|
opacity_dictionary_registry[key] = { :name => dictionary_name,
|
@@ -95,7 +94,6 @@ module Prawn
|
|
95
94
|
page.ext_gstates.merge!(dictionary_name => dictionary)
|
96
95
|
dictionary_name
|
97
96
|
end
|
98
|
-
|
99
97
|
end
|
100
98
|
end
|
101
99
|
end
|
data/lib/prawn/grid.rb
CHANGED
@@ -33,17 +33,21 @@ module Prawn
|
|
33
33
|
#
|
34
34
|
def grid(*args)
|
35
35
|
@boxes ||= {}
|
36
|
-
@boxes[args]
|
37
|
-
|
36
|
+
return @boxes[args] if @boxes[args]
|
37
|
+
|
38
|
+
if args.empty?
|
39
|
+
@boxes[args] = @grid
|
38
40
|
else
|
39
41
|
g1, g2 = args
|
40
|
-
|
41
|
-
|
42
|
-
multi_box(single_box(*g1), single_box(*g2))
|
42
|
+
|
43
|
+
if g1.class == Array && g2.class == Array && g1.length == 2 && g2.length == 2
|
44
|
+
@boxes[args] = multi_box(single_box(*g1), single_box(*g2))
|
43
45
|
else
|
44
|
-
single_box(g1, g2)
|
46
|
+
@boxes[args] = single_box(g1, g2)
|
45
47
|
end
|
46
48
|
end
|
49
|
+
|
50
|
+
@boxes[args]
|
47
51
|
end
|
48
52
|
|
49
53
|
# A Grid represents the entire grid system of a Page and calculates
|
@@ -69,14 +73,14 @@ module Prawn
|
|
69
73
|
|
70
74
|
# Calculates the base height of boxes.
|
71
75
|
def row_height
|
72
|
-
|
76
|
+
@row_height ||= subdivide(pdf.bounds.height, rows, row_gutter)
|
73
77
|
end
|
74
78
|
|
75
79
|
# Diagnostic tool to show all of the grids. Defaults to gray.
|
76
80
|
def show_all(color = "CCCCCC")
|
77
81
|
self.rows.times do |i|
|
78
82
|
self.columns.times do |j|
|
79
|
-
pdf.grid(i,j).show(color)
|
83
|
+
pdf.grid(i, j).show(color)
|
80
84
|
end
|
81
85
|
end
|
82
86
|
end
|
@@ -88,7 +92,7 @@ module Prawn
|
|
88
92
|
end
|
89
93
|
|
90
94
|
def set_gutter(options)
|
91
|
-
if options.
|
95
|
+
if options.key?(:gutter)
|
92
96
|
@gutter = options[:gutter].to_f
|
93
97
|
@row_gutter, @column_gutter = @gutter, @gutter
|
94
98
|
else
|
@@ -199,6 +203,7 @@ module Prawn
|
|
199
203
|
end
|
200
204
|
|
201
205
|
private
|
206
|
+
|
202
207
|
def grid
|
203
208
|
pdf.grid
|
204
209
|
end
|
@@ -214,7 +219,7 @@ module Prawn
|
|
214
219
|
end
|
215
220
|
|
216
221
|
def name
|
217
|
-
@bs.map
|
222
|
+
@bs.map(&:name).join(":")
|
218
223
|
end
|
219
224
|
|
220
225
|
def total_height
|
@@ -250,24 +255,26 @@ module Prawn
|
|
250
255
|
end
|
251
256
|
|
252
257
|
private
|
258
|
+
|
253
259
|
def left_box
|
254
|
-
@left_box ||= @bs.min {|a,b| a.left <=> b.left}
|
260
|
+
@left_box ||= @bs.min { |a, b| a.left <=> b.left }
|
255
261
|
end
|
256
262
|
|
257
263
|
def right_box
|
258
|
-
@right_box ||= @bs.max {|a,b| a.right <=> b.right}
|
264
|
+
@right_box ||= @bs.max { |a, b| a.right <=> b.right }
|
259
265
|
end
|
260
266
|
|
261
267
|
def top_box
|
262
|
-
@top_box ||= @bs.max {|a,b| a.top <=> b.top}
|
268
|
+
@top_box ||= @bs.max { |a, b| a.top <=> b.top }
|
263
269
|
end
|
264
270
|
|
265
271
|
def bottom_box
|
266
|
-
@bottom_box ||= @bs.min {|a,b| a.bottom <=> b.bottom}
|
272
|
+
@bottom_box ||= @bs.min { |a, b| a.bottom <=> b.bottom }
|
267
273
|
end
|
268
274
|
end
|
269
275
|
|
270
276
|
private
|
277
|
+
|
271
278
|
def single_box(i, j)
|
272
279
|
GridBox.new(self, i, j)
|
273
280
|
end
|
data/lib/prawn/image_handler.rb
CHANGED
data/lib/prawn/images.rb
CHANGED
@@ -9,7 +9,6 @@ require 'digest/sha1'
|
|
9
9
|
require 'pathname'
|
10
10
|
|
11
11
|
module Prawn
|
12
|
-
|
13
12
|
module Images
|
14
13
|
# @group Stable API
|
15
14
|
|
@@ -60,7 +59,7 @@ module Prawn
|
|
60
59
|
# dimensions of an image object if needed.
|
61
60
|
# (See also: Prawn::Images::PNG , Prawn::Images::JPG)
|
62
61
|
#
|
63
|
-
def image(file, options={})
|
62
|
+
def image(file, options = {})
|
64
63
|
Prawn.verify_options [:at, :position, :vposition, :height,
|
65
64
|
:width, :scale, :fit], options
|
66
65
|
|
@@ -70,7 +69,6 @@ module Prawn
|
|
70
69
|
info
|
71
70
|
end
|
72
71
|
|
73
|
-
|
74
72
|
# Builds an info object (Prawn::Images::*) and a PDF reference representing
|
75
73
|
# the given image. Return a pair: [pdf_obj, info].
|
76
74
|
#
|
@@ -93,7 +91,7 @@ module Prawn
|
|
93
91
|
|
94
92
|
# Add the image to the PDF and register it in case we see it again.
|
95
93
|
image_obj = info.build_pdf_object(self)
|
96
|
-
image_registry[image_sha1] = {:obj => image_obj, :info => info}
|
94
|
+
image_registry[image_sha1] = { :obj => image_obj, :info => info }
|
97
95
|
end
|
98
96
|
|
99
97
|
[image_obj, info]
|
@@ -107,12 +105,12 @@ module Prawn
|
|
107
105
|
# @private
|
108
106
|
def embed_image(pdf_obj, info, options)
|
109
107
|
# find where the image will be placed and how big it will be
|
110
|
-
w,h = info.calc_image_dimensions(options)
|
108
|
+
w, h = info.calc_image_dimensions(options)
|
111
109
|
|
112
110
|
if options[:at]
|
113
|
-
x,y = map_to_absolute(options[:at])
|
111
|
+
x, y = map_to_absolute(options[:at])
|
114
112
|
else
|
115
|
-
x,y = image_position(w,h,options)
|
113
|
+
x, y = image_position(w, h, options)
|
116
114
|
move_text_position h
|
117
115
|
end
|
118
116
|
|
@@ -141,39 +139,39 @@ module Prawn
|
|
141
139
|
end
|
142
140
|
# String or Pathname
|
143
141
|
io_or_path = Pathname.new(io_or_path)
|
144
|
-
|
142
|
+
fail ArgumentError, "#{io_or_path} not found" unless io_or_path.file?
|
145
143
|
io = io_or_path.open('rb')
|
146
144
|
io
|
147
145
|
end
|
148
146
|
|
149
|
-
def image_position(w,h,options)
|
147
|
+
def image_position(w, h, options)
|
150
148
|
options[:position] ||= :left
|
151
149
|
|
152
150
|
y = case options[:vposition]
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
151
|
+
when :top
|
152
|
+
bounds.absolute_top
|
153
|
+
when :center
|
154
|
+
bounds.absolute_top - (bounds.height - h) / 2.0
|
155
|
+
when :bottom
|
156
|
+
bounds.absolute_bottom + h
|
157
|
+
when Numeric
|
158
|
+
bounds.absolute_top - options[:vposition]
|
159
|
+
else
|
160
|
+
determine_y_with_page_flow(h)
|
161
|
+
end
|
164
162
|
|
165
163
|
x = case options[:position]
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
return [x,y]
|
164
|
+
when :left
|
165
|
+
bounds.left_side
|
166
|
+
when :center
|
167
|
+
bounds.left_side + (bounds.width - w) / 2.0
|
168
|
+
when :right
|
169
|
+
bounds.right_side - w
|
170
|
+
when Numeric
|
171
|
+
options[:position] + bounds.left_side
|
172
|
+
end
|
173
|
+
|
174
|
+
return [x, y]
|
177
175
|
end
|
178
176
|
|
179
177
|
def determine_y_with_page_flow(h)
|
data/lib/prawn/images/image.rb
CHANGED
data/lib/prawn/images/jpg.rb
CHANGED
@@ -10,7 +10,6 @@ require 'stringio'
|
|
10
10
|
|
11
11
|
module Prawn
|
12
12
|
module Images
|
13
|
-
|
14
13
|
# A convenience class that wraps the logic for extracting the parts
|
15
14
|
# of a JPG image that we need to embed them in a PDF
|
16
15
|
#
|
@@ -39,7 +38,7 @@ module Prawn
|
|
39
38
|
d.seek(2) # Skip the first two bytes of JPEG identifier.
|
40
39
|
loop do
|
41
40
|
marker, code, length = d.read(4).unpack('CCn')
|
42
|
-
|
41
|
+
fail "JPEG marker not found!" if marker != c_marker
|
43
42
|
|
44
43
|
if JPEG_SOF_BLOCKS.include?(code)
|
45
44
|
@bits, @height, @width, @channels = d.read(6).unpack("CnnC")
|
@@ -55,15 +54,15 @@ module Prawn
|
|
55
54
|
#
|
56
55
|
def build_pdf_object(document)
|
57
56
|
color_space = case channels
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
57
|
+
when 1
|
58
|
+
:DeviceGray
|
59
|
+
when 3
|
60
|
+
:DeviceRGB
|
61
|
+
when 4
|
62
|
+
:DeviceCMYK
|
63
|
+
else
|
64
|
+
fail ArgumentError, 'JPG uses an unsupported number of channels'
|
65
|
+
end
|
67
66
|
|
68
67
|
obj = document.ref!(
|
69
68
|
:Type => :XObject,
|
@@ -85,7 +84,6 @@ module Prawn
|
|
85
84
|
obj.stream.filters << :DCTDecode
|
86
85
|
obj
|
87
86
|
end
|
88
|
-
|
89
87
|
end
|
90
88
|
end
|
91
89
|
end
|
data/lib/prawn/images/png.rb
CHANGED
@@ -68,9 +68,9 @@ module Prawn
|
|
68
68
|
@transparency = {}
|
69
69
|
case @color_type
|
70
70
|
when 3
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
fail Errors::UnsupportedImageType,
|
72
|
+
"Pallete-based transparency in PNG is not currently supported.\n" \
|
73
|
+
"See https://github.com/prawnpdf/prawn/issues/783"
|
74
74
|
when 0
|
75
75
|
# Greyscale. Corresponding to entries in the PLTE chunk.
|
76
76
|
# Grey is two bytes, range 0 .. (2 ^ bit-depth) - 1
|
@@ -121,18 +121,18 @@ module Prawn
|
|
121
121
|
#
|
122
122
|
def build_pdf_object(document)
|
123
123
|
if compression_method != 0
|
124
|
-
|
125
|
-
|
124
|
+
fail Errors::UnsupportedImageType,
|
125
|
+
'PNG uses an unsupported compression method'
|
126
126
|
end
|
127
127
|
|
128
128
|
if filter_method != 0
|
129
|
-
|
130
|
-
|
129
|
+
fail Errors::UnsupportedImageType,
|
130
|
+
'PNG uses an unsupported filter method'
|
131
131
|
end
|
132
132
|
|
133
133
|
if interlace_method != 0
|
134
|
-
|
135
|
-
|
134
|
+
fail Errors::UnsupportedImageType,
|
135
|
+
'PNG uses unsupported interlace method'
|
136
136
|
end
|
137
137
|
|
138
138
|
# some PNG types store the colour and alpha channel data together,
|
@@ -145,8 +145,8 @@ module Prawn
|
|
145
145
|
when 3
|
146
146
|
color = :DeviceRGB
|
147
147
|
else
|
148
|
-
|
149
|
-
|
148
|
+
fail Errors::UnsupportedImageType,
|
149
|
+
"PNG uses an unsupported number of colors (#{png.colors})"
|
150
150
|
end
|
151
151
|
|
152
152
|
# build the image dict
|
@@ -181,7 +181,7 @@ module Prawn
|
|
181
181
|
# build the color space array for the image
|
182
182
|
obj.data[:ColorSpace] = [:Indexed,
|
183
183
|
:DeviceRGB,
|
184
|
-
(palette.size / 3) -1,
|
184
|
+
(palette.size / 3) - 1,
|
185
185
|
palette_obj]
|
186
186
|
end
|
187
187
|
|
@@ -203,7 +203,7 @@ module Prawn
|
|
203
203
|
# - An array with N elements, where N is two times the number of color
|
204
204
|
# components.
|
205
205
|
rgb = transparency[:rgb]
|
206
|
-
obj.data[:Mask] = rgb.collect { |x| [x,x] }.flatten
|
206
|
+
obj.data[:Mask] = rgb.collect { |x| [x, x] }.flatten
|
207
207
|
end
|
208
208
|
|
209
209
|
# For PNG color types 4 and 6, the transparency data is stored as a alpha
|
data/lib/prawn/measurements.rb
CHANGED
@@ -7,37 +7,30 @@ module Prawn
|
|
7
7
|
# @group Stable API
|
8
8
|
|
9
9
|
module Measurements
|
10
|
-
|
11
|
-
# ============================================================================
|
12
|
-
#metric conversions
|
10
|
+
# metric conversions
|
13
11
|
def cm2mm(cm)
|
14
|
-
return cm*10
|
12
|
+
return cm * 10
|
15
13
|
end
|
16
14
|
|
17
15
|
def dm2mm(dm)
|
18
|
-
return dm*100
|
16
|
+
return dm * 100
|
19
17
|
end
|
20
18
|
|
21
19
|
def m2mm(m)
|
22
|
-
return m*1000
|
20
|
+
return m * 1000
|
23
21
|
end
|
24
22
|
|
25
|
-
# ============================================================================
|
26
23
|
# imperial conversions
|
27
24
|
# from http://en.wikipedia.org/wiki/Imperial_units
|
28
|
-
|
29
25
|
def ft2in(ft)
|
30
26
|
return ft * 12
|
31
27
|
end
|
32
28
|
|
33
29
|
def yd2in(yd)
|
34
|
-
return yd*36
|
30
|
+
return yd * 36
|
35
31
|
end
|
36
32
|
|
37
|
-
|
38
|
-
# ============================================================================
|
39
33
|
# PostscriptPoint-converisons
|
40
|
-
|
41
34
|
def pt2pt(pt)
|
42
35
|
return pt
|
43
36
|
end
|
@@ -55,7 +48,7 @@ module Prawn
|
|
55
48
|
end
|
56
49
|
|
57
50
|
def mm2pt(mm)
|
58
|
-
|
51
|
+
return mm * (72 / 25.4)
|
59
52
|
end
|
60
53
|
|
61
54
|
def cm2pt(cm)
|
@@ -71,7 +64,7 @@ module Prawn
|
|
71
64
|
end
|
72
65
|
|
73
66
|
def pt2mm(pt)
|
74
|
-
return pt * 1 / mm2pt(1)# (25.4 / 72)
|
67
|
+
return pt * 1 / mm2pt(1) # (25.4 / 72)
|
75
68
|
end
|
76
69
|
end
|
77
70
|
end
|