prawn 1.1.0 → 2.4.0
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/.yardopts +1 -0
- data/GPLv2 +20 -21
- data/Gemfile +3 -9
- data/Rakefile +9 -40
- data/lib/prawn/document/bounding_box.rb +54 -40
- data/lib/prawn/document/column_box.rb +8 -10
- data/lib/prawn/document/internals.rb +39 -146
- data/lib/prawn/document/span.rb +23 -17
- data/lib/prawn/document.rb +217 -182
- data/lib/prawn/encoding.rb +69 -101
- data/lib/prawn/errors.rb +47 -43
- data/lib/prawn/font.rb +124 -104
- data/lib/prawn/font_metric_cache.rb +23 -21
- data/lib/prawn/fonts/afm.rb +292 -0
- data/lib/prawn/{font → fonts}/dfont.rb +5 -12
- data/lib/prawn/fonts/otf.rb +11 -0
- data/lib/prawn/fonts/ttc.rb +36 -0
- data/lib/prawn/{font → fonts}/ttf.rb +140 -88
- data/lib/prawn/graphics/blend_mode.rb +65 -0
- data/lib/prawn/graphics/cap_style.rb +5 -5
- data/lib/prawn/graphics/color.rb +46 -44
- data/lib/prawn/graphics/dash.rb +27 -11
- data/lib/prawn/graphics/join_style.rb +11 -6
- data/lib/prawn/graphics/patterns.rb +220 -78
- data/lib/prawn/graphics/transformation.rb +20 -12
- data/lib/prawn/graphics/transparency.rb +20 -18
- data/lib/prawn/graphics.rb +153 -115
- data/lib/prawn/grid.rb +93 -50
- data/lib/prawn/image_handler.rb +4 -4
- data/lib/prawn/images/image.rb +3 -2
- data/lib/prawn/images/jpg.rb +31 -24
- data/lib/prawn/images/png.rb +101 -68
- data/lib/prawn/images.rb +64 -56
- data/lib/prawn/measurement_extensions.rb +10 -9
- data/lib/prawn/measurements.rb +20 -23
- data/lib/prawn/outline.rb +96 -75
- data/lib/prawn/repeater.rb +16 -16
- data/lib/prawn/security/arcfour.rb +2 -2
- data/lib/prawn/security.rb +100 -85
- data/lib/prawn/soft_mask.rb +37 -38
- data/lib/prawn/stamp.rb +28 -13
- data/lib/prawn/text/box.rb +24 -29
- data/lib/prawn/text/formatted/arranger.rb +108 -63
- data/lib/prawn/text/formatted/box.rb +187 -124
- data/lib/prawn/text/formatted/fragment.rb +24 -20
- data/lib/prawn/text/formatted/line_wrap.rb +133 -73
- data/lib/prawn/text/formatted/parser.rb +147 -127
- data/lib/prawn/text/formatted/wrap.rb +48 -35
- data/lib/prawn/text/formatted.rb +5 -5
- data/lib/prawn/text.rb +103 -68
- data/lib/prawn/transformation_stack.rb +44 -0
- data/lib/prawn/utilities.rb +10 -22
- data/lib/prawn/version.rb +5 -0
- data/lib/prawn/view.rb +101 -0
- data/lib/prawn.rb +39 -54
- data/manual/basic_concepts/adding_pages.rb +6 -7
- data/manual/basic_concepts/basic_concepts.rb +34 -25
- data/manual/basic_concepts/creation.rb +10 -11
- data/manual/basic_concepts/cursor.rb +4 -5
- data/manual/basic_concepts/measurement.rb +8 -9
- data/manual/basic_concepts/origin.rb +5 -6
- data/manual/basic_concepts/other_cursor_helpers.rb +11 -12
- data/manual/basic_concepts/view.rb +48 -0
- data/manual/bounding_box/bounding_box.rb +30 -28
- data/manual/bounding_box/bounds.rb +12 -13
- data/manual/bounding_box/canvas.rb +7 -8
- data/manual/bounding_box/creation.rb +6 -7
- data/manual/bounding_box/indentation.rb +14 -15
- data/manual/bounding_box/nesting.rb +25 -18
- data/manual/bounding_box/russian_boxes.rb +18 -18
- data/manual/bounding_box/stretchy.rb +12 -14
- data/manual/contents.rb +28 -22
- data/manual/cover.rb +33 -32
- data/manual/document_and_page_options/background.rb +15 -13
- data/manual/document_and_page_options/document_and_page_options.rb +24 -22
- data/manual/document_and_page_options/metadata.rb +20 -18
- data/manual/document_and_page_options/page_margins.rb +18 -20
- data/manual/document_and_page_options/page_size.rb +13 -13
- data/manual/document_and_page_options/print_scaling.rb +18 -15
- data/manual/example_helper.rb +5 -4
- data/manual/graphics/blend_mode.rb +52 -0
- data/manual/graphics/circle_and_ellipse.rb +4 -5
- data/manual/graphics/color.rb +7 -9
- data/manual/graphics/common_lines.rb +7 -8
- data/manual/graphics/fill_and_stroke.rb +5 -6
- data/manual/graphics/fill_rules.rb +12 -11
- data/manual/graphics/gradients.rb +27 -21
- data/manual/graphics/graphics.rb +46 -40
- data/manual/graphics/helper.rb +19 -9
- data/manual/graphics/line_width.rb +8 -7
- data/manual/graphics/lines_and_curves.rb +8 -9
- data/manual/graphics/polygon.rb +6 -8
- data/manual/graphics/rectangle.rb +4 -5
- data/manual/graphics/rotate.rb +6 -9
- data/manual/graphics/scale.rb +14 -13
- data/manual/graphics/soft_masks.rb +4 -6
- data/manual/graphics/stroke_cap.rb +7 -8
- data/manual/graphics/stroke_dash.rb +15 -16
- data/manual/graphics/stroke_join.rb +6 -7
- data/manual/graphics/translate.rb +10 -10
- data/manual/graphics/transparency.rb +7 -9
- data/manual/how_to_read_this_manual.rb +8 -9
- data/manual/images/absolute_position.rb +6 -7
- data/manual/images/fit.rb +7 -8
- data/manual/images/horizontal.rb +10 -11
- data/manual/images/images.rb +28 -27
- data/manual/images/plain_image.rb +5 -6
- data/manual/images/scale.rb +9 -10
- data/manual/images/vertical.rb +16 -14
- data/manual/images/width_and_height.rb +10 -11
- data/manual/layout/boxes.rb +10 -11
- data/manual/layout/content.rb +9 -10
- data/manual/layout/layout.rb +17 -18
- data/manual/layout/simple_grid.rb +6 -7
- data/manual/outline/add_subsection_to.rb +20 -21
- data/manual/outline/insert_section_after.rb +15 -16
- data/manual/outline/outline.rb +22 -21
- data/manual/outline/sections_and_pages.rb +17 -18
- data/manual/repeatable_content/alternate_page_numbering.rb +36 -0
- data/manual/repeatable_content/page_numbering.rb +17 -16
- data/manual/repeatable_content/repeatable_content.rb +27 -23
- data/manual/repeatable_content/repeater.rb +15 -16
- data/manual/repeatable_content/stamp.rb +14 -15
- data/manual/security/encryption.rb +8 -11
- data/manual/security/permissions.rb +20 -15
- data/manual/security/security.rb +18 -18
- data/manual/table.rb +16 -0
- data/manual/text/alignment.rb +16 -17
- data/manual/text/color.rb +12 -12
- data/manual/text/column_box.rb +9 -11
- data/manual/text/fallback_fonts.rb +25 -21
- data/manual/text/font.rb +11 -12
- data/manual/text/font_size.rb +13 -14
- data/manual/text/font_style.rb +10 -8
- data/manual/text/formatted_callbacks.rb +33 -23
- data/manual/text/formatted_text.rb +36 -25
- data/manual/text/free_flowing_text.rb +22 -23
- data/manual/text/inline.rb +18 -19
- data/manual/text/kerning_and_character_spacing.rb +14 -15
- data/manual/text/leading.rb +7 -8
- data/manual/text/line_wrapping.rb +37 -18
- data/manual/text/paragraph_indentation.rb +15 -10
- data/manual/text/positioned_text.rb +16 -17
- data/manual/text/registering_families.rb +27 -24
- data/manual/text/rendering_and_color.rb +9 -10
- data/manual/text/right_to_left_text.rb +30 -19
- data/manual/text/rotation.rb +33 -24
- data/manual/text/single_usage.rb +8 -9
- data/manual/text/text.rb +56 -54
- data/manual/text/text_box_excess.rb +20 -17
- data/manual/text/text_box_extensions.rb +18 -15
- data/manual/text/text_box_overflow.rb +24 -17
- data/manual/text/utf8.rb +12 -13
- data/manual/text/win_ansi_charset.rb +28 -25
- data/prawn.gemspec +45 -50
- data/spec/extensions/encoding_helpers.rb +3 -3
- data/spec/prawn/document/bounding_box_spec.rb +550 -0
- data/spec/prawn/document/column_box_spec.rb +75 -0
- data/spec/prawn/document/security_spec.rb +176 -0
- data/spec/prawn/document_annotations_spec.rb +76 -0
- data/spec/prawn/document_destinations_spec.rb +15 -0
- data/spec/prawn/document_grid_spec.rb +99 -0
- data/spec/prawn/document_reference_spec.rb +27 -0
- data/spec/prawn/document_span_spec.rb +44 -0
- data/spec/prawn/document_spec.rb +805 -0
- data/spec/prawn/font_metric_cache_spec.rb +54 -0
- data/spec/prawn/font_spec.rb +544 -0
- data/spec/prawn/graphics/blend_mode_spec.rb +63 -0
- data/spec/prawn/graphics/transparency_spec.rb +81 -0
- data/spec/prawn/graphics_spec.rb +872 -0
- data/spec/prawn/graphics_stroke_styles_spec.rb +229 -0
- data/spec/prawn/image_handler_spec.rb +53 -0
- data/spec/prawn/images/jpg_spec.rb +20 -0
- data/spec/prawn/images/png_spec.rb +283 -0
- data/spec/prawn/images_spec.rb +229 -0
- data/spec/prawn/measurements_extensions_spec.rb +24 -0
- data/spec/prawn/outline_spec.rb +512 -0
- data/spec/prawn/repeater_spec.rb +166 -0
- data/spec/prawn/soft_mask_spec.rb +74 -0
- data/spec/prawn/stamp_spec.rb +173 -0
- data/spec/prawn/text/box_spec.rb +1110 -0
- data/spec/prawn/text/formatted/arranger_spec.rb +466 -0
- data/spec/prawn/text/formatted/box_spec.rb +849 -0
- data/spec/prawn/text/formatted/fragment_spec.rb +343 -0
- data/spec/prawn/text/formatted/line_wrap_spec.rb +495 -0
- data/spec/prawn/text/formatted/parser_spec.rb +697 -0
- data/spec/prawn/text_draw_text_spec.rb +150 -0
- data/spec/prawn/text_rendering_mode_spec.rb +48 -0
- data/spec/prawn/text_spacing_spec.rb +95 -0
- data/spec/prawn/text_spec.rb +603 -0
- data/spec/prawn/text_with_inline_formatting_spec.rb +35 -0
- data/spec/prawn/transformation_stack_spec.rb +66 -0
- data/spec/prawn/view_spec.rb +63 -0
- data/spec/prawn_manual_spec.rb +35 -0
- data/spec/spec_helper.rb +19 -25
- data.tar.gz.sig +0 -0
- metadata +113 -276
- metadata.gz.sig +0 -0
- data/data/encodings/win_ansi.txt +0 -29
- data/data/images/16bit.alpha +0 -0
- data/data/images/16bit.color +0 -0
- data/data/images/16bit.png +0 -0
- data/data/images/arrow.png +0 -0
- data/data/images/arrow2.png +0 -0
- data/data/images/dice.alpha +0 -0
- data/data/images/dice.color +0 -0
- data/data/images/dice.png +0 -0
- data/data/images/dice_interlaced.png +0 -0
- data/data/images/fractal.jpg +0 -0
- data/data/images/indexed_color.dat +0 -0
- data/data/images/indexed_color.png +0 -0
- data/data/images/letterhead.jpg +0 -0
- data/data/images/license.md +0 -8
- data/data/images/page_white_text.alpha +0 -0
- data/data/images/page_white_text.color +0 -0
- data/data/images/page_white_text.png +0 -0
- data/data/images/pigs.jpg +0 -0
- data/data/images/prawn.png +0 -0
- data/data/images/ruport.png +0 -0
- data/data/images/ruport_data.dat +0 -0
- data/data/images/ruport_transparent.png +0 -0
- data/data/images/ruport_type0.png +0 -0
- data/data/images/stef.jpg +0 -0
- data/data/images/tru256.bmp +0 -0
- data/data/images/web-links.dat +0 -1
- data/data/images/web-links.png +0 -0
- data/data/pdfs/complex_template.pdf +0 -0
- data/data/pdfs/contains_ttf_font.pdf +0 -0
- data/data/pdfs/encrypted.pdf +0 -0
- data/data/pdfs/form.pdf +1 -819
- data/data/pdfs/hexagon.pdf +0 -61
- data/data/pdfs/indirect_reference.pdf +0 -86
- data/data/pdfs/multipage_template.pdf +0 -127
- data/data/pdfs/nested_pages.pdf +0 -118
- data/data/pdfs/page_without_mediabox.pdf +0 -193
- data/data/pdfs/resources_as_indirect_object.pdf +0 -83
- data/data/pdfs/two_hexagons.pdf +0 -90
- data/data/pdfs/version_1_6.pdf +0 -61
- data/data/shift_jis_text.txt +0 -1
- data/lib/prawn/document/graphics_state.rb +0 -73
- data/lib/prawn/font/afm.rb +0 -247
- data/lib/prawn/table/cell/image.rb +0 -69
- data/lib/prawn/table/cell/in_table.rb +0 -33
- data/lib/prawn/table/cell/span_dummy.rb +0 -93
- data/lib/prawn/table/cell/subtable.rb +0 -66
- data/lib/prawn/table/cell/text.rb +0 -154
- data/lib/prawn/table/cell.rb +0 -772
- data/lib/prawn/table/cells.rb +0 -255
- data/lib/prawn/table/column_width_calculator.rb +0 -182
- data/lib/prawn/table.rb +0 -644
- data/manual/table/basic_block.rb +0 -53
- data/manual/table/before_rendering_page.rb +0 -26
- data/manual/table/cell_border_lines.rb +0 -24
- data/manual/table/cell_borders_and_bg.rb +0 -31
- data/manual/table/cell_dimensions.rb +0 -30
- data/manual/table/cell_text.rb +0 -38
- data/manual/table/column_widths.rb +0 -30
- data/manual/table/content_and_subtables.rb +0 -39
- data/manual/table/creation.rb +0 -27
- data/manual/table/filtering.rb +0 -36
- data/manual/table/flow_and_header.rb +0 -17
- data/manual/table/image_cells.rb +0 -33
- data/manual/table/position.rb +0 -29
- data/manual/table/row_colors.rb +0 -20
- data/manual/table/span.rb +0 -30
- data/manual/table/style.rb +0 -22
- data/manual/table/table.rb +0 -52
- data/manual/table/width.rb +0 -27
- data/spec/acceptance/png.rb +0 -25
- data/spec/annotations_spec.rb +0 -74
- data/spec/bounding_box_spec.rb +0 -510
- data/spec/cell_spec.rb +0 -629
- data/spec/column_box_spec.rb +0 -65
- data/spec/destinations_spec.rb +0 -15
- data/spec/document_spec.rb +0 -730
- data/spec/extensions/mocha.rb +0 -46
- data/spec/font_metric_cache_spec.rb +0 -52
- data/spec/font_spec.rb +0 -449
- data/spec/formatted_text_arranger_spec.rb +0 -421
- data/spec/formatted_text_box_spec.rb +0 -639
- data/spec/formatted_text_fragment_spec.rb +0 -298
- data/spec/graphics_spec.rb +0 -669
- data/spec/grid_spec.rb +0 -96
- data/spec/image_handler_spec.rb +0 -54
- data/spec/images_spec.rb +0 -153
- data/spec/inline_formatted_text_parser_spec.rb +0 -564
- data/spec/jpg_spec.rb +0 -25
- data/spec/line_wrap_spec.rb +0 -344
- data/spec/measurement_units_spec.rb +0 -25
- data/spec/outline_spec.rb +0 -430
- data/spec/png_spec.rb +0 -237
- data/spec/reference_spec.rb +0 -25
- data/spec/repeater_spec.rb +0 -160
- data/spec/security_spec.rb +0 -158
- data/spec/soft_mask_spec.rb +0 -79
- data/spec/span_spec.rb +0 -44
- data/spec/stamp_spec.rb +0 -160
- data/spec/stroke_styles_spec.rb +0 -211
- data/spec/table/span_dummy_spec.rb +0 -17
- data/spec/table_spec.rb +0 -1527
- data/spec/text_at_spec.rb +0 -115
- data/spec/text_box_spec.rb +0 -1034
- data/spec/text_rendering_mode_spec.rb +0 -45
- data/spec/text_spacing_spec.rb +0 -93
- data/spec/text_spec.rb +0 -437
- data/spec/text_with_inline_formatting_spec.rb +0 -35
- data/spec/transparency_spec.rb +0 -91
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d64c2da1e4be48e40f4fa6fa4de35e04c75debf0119e8c59b3fba9d944c112db
|
4
|
+
data.tar.gz: 393bbdd1a5df657d5c6190d4bd10ecd7353522e714b2f60c8d9c5f70e5bc1ce9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4980639ca24796d577be790ed0f6fa85c985f1a6eb147e4c5db1df261c5d50afe8a466f06b65588b71a897e22e8d2b7b01daceed1714f6164124057154d2d28
|
7
|
+
data.tar.gz: e0fd560d4a80f2827736d599266bcb2e2fe19abedcde639520fba8bd19a2f12fe2cf0e8a60a91b87dbac4336d25c680f94b2341e5f9ce3d6d24f2e65f24e24a3
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/.yardopts
CHANGED
data/GPLv2
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
2
|
+
Version 2, June 1991
|
3
3
|
|
4
|
-
Copyright (C) 1989, 1991 Free Software Foundation, Inc
|
5
|
-
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6
6
|
Everyone is permitted to copy and distribute verbatim copies
|
7
7
|
of this license document, but changing it is not allowed.
|
8
8
|
|
9
|
-
|
9
|
+
Preamble
|
10
10
|
|
11
11
|
The licenses for most software are designed to take away your
|
12
12
|
freedom to share and change it. By contrast, the GNU General Public
|
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
|
|
15
15
|
General Public License applies to most of the Free Software
|
16
16
|
Foundation's software and to any other program whose authors commit to
|
17
17
|
using it. (Some other Free Software Foundation software is covered by
|
18
|
-
the GNU
|
18
|
+
the GNU Lesser General Public License instead.) You can apply it to
|
19
19
|
your programs, too.
|
20
20
|
|
21
21
|
When we speak of free software, we are referring to freedom, not
|
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
|
|
55
55
|
|
56
56
|
The precise terms and conditions for copying, distribution and
|
57
57
|
modification follow.
|
58
|
-
|
59
|
-
|
58
|
+
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
60
60
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61
61
|
|
62
62
|
0. This License applies to any program or other work which contains
|
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
|
|
110
110
|
License. (Exception: if the Program itself is interactive but
|
111
111
|
does not normally print such an announcement, your work based on
|
112
112
|
the Program is not required to print an announcement.)
|
113
|
-
|
113
|
+
|
114
114
|
These requirements apply to the modified work as a whole. If
|
115
115
|
identifiable sections of that work are not derived from the Program,
|
116
116
|
and can be reasonably considered independent and separate works in
|
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
|
|
168
168
|
access to copy the source code from the same place counts as
|
169
169
|
distribution of the source code, even though third parties are not
|
170
170
|
compelled to copy the source along with the object code.
|
171
|
-
|
171
|
+
|
172
172
|
4. You may not copy, modify, sublicense, or distribute the Program
|
173
173
|
except as expressly provided under this License. Any attempt
|
174
174
|
otherwise to copy, modify, sublicense or distribute the Program is
|
@@ -225,7 +225,7 @@ impose that choice.
|
|
225
225
|
|
226
226
|
This section is intended to make thoroughly clear what is believed to
|
227
227
|
be a consequence of the rest of this License.
|
228
|
-
|
228
|
+
|
229
229
|
8. If the distribution and/or use of the Program is restricted in
|
230
230
|
certain countries either by patents or by copyrighted interfaces, the
|
231
231
|
original copyright holder who places the Program under this License
|
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
|
|
255
255
|
of preserving the free status of all derivatives of our free software and
|
256
256
|
of promoting the sharing and reuse of software generally.
|
257
257
|
|
258
|
-
|
258
|
+
NO WARRANTY
|
259
259
|
|
260
260
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261
261
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
277
277
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278
278
|
POSSIBILITY OF SUCH DAMAGES.
|
279
279
|
|
280
|
-
|
281
|
-
|
282
|
-
|
280
|
+
END OF TERMS AND CONDITIONS
|
281
|
+
|
282
|
+
How to Apply These Terms to Your New Programs
|
283
283
|
|
284
284
|
If you develop a new program, and you want it to be of the greatest
|
285
285
|
possible use to the public, the best way to achieve this is to make it
|
@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found.
|
|
303
303
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304
304
|
GNU General Public License for more details.
|
305
305
|
|
306
|
-
You should have received a copy of the GNU General Public License
|
307
|
-
|
308
|
-
|
309
|
-
|
306
|
+
You should have received a copy of the GNU General Public License along
|
307
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
310
309
|
|
311
310
|
Also add information on how to contact you by electronic and paper mail.
|
312
311
|
|
313
312
|
If the program is interactive, make it output a short notice like this
|
314
313
|
when it starts in an interactive mode:
|
315
314
|
|
316
|
-
Gnomovision version 69, Copyright (C) year
|
315
|
+
Gnomovision version 69, Copyright (C) year name of author
|
317
316
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
318
317
|
This is free software, and you are welcome to redistribute it
|
319
318
|
under certain conditions; type `show c' for details.
|
@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names:
|
|
336
335
|
This General Public License does not permit incorporating your program into
|
337
336
|
proprietary programs. If your program is a subroutine library, you may
|
338
337
|
consider it more useful to permit linking proprietary applications with the
|
339
|
-
library. If this is what you want to do, use the GNU
|
338
|
+
library. If this is what you want to do, use the GNU Lesser General
|
340
339
|
Public License instead of this License.
|
data/Gemfile
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
|
6
|
-
platforms :rbx do
|
7
|
-
gem "rubysl-singleton", "~> 2.0"
|
8
|
-
gem "rubysl-digest", "~> 2.0"
|
9
|
-
gem "rubysl-enumerator", "~> 2.0"
|
10
|
-
end
|
11
|
-
end
|
5
|
+
gemspec
|
data/Rakefile
CHANGED
@@ -1,48 +1,19 @@
|
|
1
|
-
|
2
|
-
Bundler.setup
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
require '
|
6
|
-
require 'yard'
|
7
|
-
require 'rubygems/package_task'
|
8
|
-
require 'rubocop/rake_task'
|
9
|
-
|
10
|
-
task :default => [:rubocop, :spec]
|
11
|
-
|
12
|
-
desc "Run all rspec files"
|
13
|
-
RSpec::Core::RakeTask.new("spec") do |c|
|
14
|
-
c.rspec_opts = "-t ~unresolved"
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Show library's code statistics"
|
18
|
-
task :stats do
|
19
|
-
require 'code_statistics'
|
20
|
-
CodeStatistics::TEST_TYPES << "Specs"
|
21
|
-
CodeStatistics.new( ["Prawn", "lib"],
|
22
|
-
["Specs", "spec"] ).to_s
|
23
|
-
end
|
24
|
-
|
25
|
-
YARD::Rake::YardocTask.new do |t|
|
26
|
-
t.options = ['--output-dir', 'doc/html']
|
27
|
-
end
|
28
|
-
task :docs => :yard
|
3
|
+
GEMSPEC = File.expand_path('prawn.gemspec', __dir__)
|
4
|
+
require 'prawn/dev/tasks'
|
29
5
|
|
6
|
+
task default: %i[spec rubocop]
|
30
7
|
|
31
8
|
desc "Generate the 'Prawn by Example' manual"
|
32
9
|
task :manual do
|
33
|
-
puts
|
34
|
-
require File.expand_path(File.join(
|
35
|
-
|
36
|
-
puts
|
10
|
+
puts 'Building manual...'
|
11
|
+
require File.expand_path(File.join(__dir__, %w[manual contents]))
|
12
|
+
prawn_manual_document.render_file('manual.pdf')
|
13
|
+
puts 'The Prawn manual is available at manual.pdf. Happy Prawning!'
|
37
14
|
end
|
38
15
|
|
39
|
-
|
40
|
-
Gem::PackageTask.new(spec) do |pkg|
|
41
|
-
pkg.need_zip = true
|
42
|
-
pkg.need_tar = true
|
43
|
-
end
|
44
|
-
|
45
|
-
desc "Run a console with Prawn loaded"
|
16
|
+
desc 'Run a console with Prawn loaded'
|
46
17
|
task :console do
|
47
18
|
require 'irb'
|
48
19
|
require 'irb/completion'
|
@@ -52,5 +23,3 @@ task :console do
|
|
52
23
|
ARGV.clear
|
53
24
|
IRB.start
|
54
25
|
end
|
55
|
-
|
56
|
-
Rubocop::RakeTask.new
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# bounding_box.rb : Implements a mechanism for shifting the coordinate space
|
4
4
|
#
|
@@ -155,10 +155,10 @@ module Prawn
|
|
155
155
|
# Of course, if you use canvas, you will be responsible for ensuring that
|
156
156
|
# you remain within the printable area of your document.
|
157
157
|
#
|
158
|
-
def bounding_box(
|
158
|
+
def bounding_box(point, *args, &block)
|
159
159
|
init_bounding_box(block) do |parent_box|
|
160
|
-
|
161
|
-
@bounding_box = BoundingBox.new(self, parent_box,
|
160
|
+
point = map_to_absolute(point)
|
161
|
+
@bounding_box = BoundingBox.new(self, parent_box, point, *args)
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -170,28 +170,31 @@ module Prawn
|
|
170
170
|
# end
|
171
171
|
#
|
172
172
|
def canvas(&block)
|
173
|
-
init_bounding_box(block, :
|
173
|
+
init_bounding_box(block, hold_position: true) do |_|
|
174
174
|
# Canvas bbox acts like margin_box in that its parent bounds are unset.
|
175
|
-
@bounding_box = BoundingBox.new(
|
176
|
-
|
177
|
-
|
175
|
+
@bounding_box = BoundingBox.new(
|
176
|
+
self,
|
177
|
+
nil,
|
178
|
+
[0, page.dimensions[3]],
|
179
|
+
width: page.dimensions[2],
|
180
|
+
height: page.dimensions[3]
|
178
181
|
)
|
179
182
|
end
|
180
183
|
end
|
181
184
|
|
182
185
|
private
|
183
186
|
|
184
|
-
def init_bounding_box(user_block, options={}
|
187
|
+
def init_bounding_box(user_block, options = {})
|
185
188
|
unless user_block
|
186
189
|
raise ArgumentError,
|
187
|
-
|
190
|
+
'bounding boxes require a block to be drawn within the box'
|
188
191
|
end
|
189
192
|
|
190
193
|
parent_box = @bounding_box
|
191
194
|
|
192
195
|
original_ypos = y
|
193
196
|
|
194
|
-
|
197
|
+
yield(parent_box)
|
195
198
|
|
196
199
|
self.y = @bounding_box.absolute_top
|
197
200
|
user_block.call
|
@@ -208,9 +211,10 @@ module Prawn
|
|
208
211
|
self.y = @bounding_box.absolute_bottom
|
209
212
|
end
|
210
213
|
|
211
|
-
created_box
|
214
|
+
created_box = @bounding_box
|
215
|
+
@bounding_box = parent_box
|
212
216
|
|
213
|
-
|
217
|
+
created_box
|
214
218
|
end
|
215
219
|
|
216
220
|
# Low level layout helper that simplifies coordinate math.
|
@@ -219,16 +223,23 @@ module Prawn
|
|
219
223
|
# is used for.
|
220
224
|
#
|
221
225
|
class BoundingBox
|
226
|
+
class NoReferenceBounds < StandardError
|
227
|
+
def initialize(message = "Can't find reference bounds: my parent is unset")
|
228
|
+
super
|
229
|
+
end
|
230
|
+
end
|
222
231
|
|
223
|
-
|
232
|
+
# @private
|
233
|
+
def initialize(document, parent, point, options = {})
|
224
234
|
unless options[:width]
|
225
|
-
raise ArgumentError,
|
235
|
+
raise ArgumentError, 'BoundingBox needs the :width option to be set'
|
226
236
|
end
|
227
237
|
|
228
238
|
@document = document
|
229
239
|
@parent = parent
|
230
240
|
@x, @y = point
|
231
|
-
@width
|
241
|
+
@width = options[:width]
|
242
|
+
@height = options[:height]
|
232
243
|
@total_left_padding = 0
|
233
244
|
@total_right_padding = 0
|
234
245
|
@stretched_height = nil
|
@@ -264,7 +275,6 @@ module Prawn
|
|
264
275
|
0
|
265
276
|
end
|
266
277
|
|
267
|
-
|
268
278
|
# Temporarily adjust the @x coordinate to allow for left_padding
|
269
279
|
#
|
270
280
|
# Example:
|
@@ -281,7 +291,7 @@ module Prawn
|
|
281
291
|
# end
|
282
292
|
#
|
283
293
|
# @private
|
284
|
-
def indent(left_padding, right_padding = 0
|
294
|
+
def indent(left_padding, right_padding = 0)
|
285
295
|
add_left_padding(left_padding)
|
286
296
|
add_right_padding(right_padding)
|
287
297
|
yield
|
@@ -320,7 +330,8 @@ module Prawn
|
|
320
330
|
@width += right_padding
|
321
331
|
end
|
322
332
|
|
323
|
-
# Relative right x-coordinate of the bounding box. (Equal to the box
|
333
|
+
# Relative right x-coordinate of the bounding box. (Equal to the box
|
334
|
+
# width)
|
324
335
|
#
|
325
336
|
# Example, position some text 3 pts from the right of the containing box:
|
326
337
|
#
|
@@ -360,7 +371,7 @@ module Prawn
|
|
360
371
|
# end
|
361
372
|
#
|
362
373
|
def top_left
|
363
|
-
[left,top]
|
374
|
+
[left, top]
|
364
375
|
end
|
365
376
|
|
366
377
|
# Relative top-right point of the bounding box
|
@@ -373,7 +384,7 @@ module Prawn
|
|
373
384
|
# end
|
374
385
|
#
|
375
386
|
def top_right
|
376
|
-
[right,top]
|
387
|
+
[right, top]
|
377
388
|
end
|
378
389
|
|
379
390
|
# Relative bottom-right point of the bounding box
|
@@ -385,7 +396,7 @@ module Prawn
|
|
385
396
|
# end
|
386
397
|
#
|
387
398
|
def bottom_right
|
388
|
-
[right,bottom]
|
399
|
+
[right, bottom]
|
389
400
|
end
|
390
401
|
|
391
402
|
# Relative bottom-left point of the bounding box
|
@@ -397,7 +408,7 @@ module Prawn
|
|
397
408
|
# end
|
398
409
|
#
|
399
410
|
def bottom_left
|
400
|
-
[left,bottom]
|
411
|
+
[left, bottom]
|
401
412
|
end
|
402
413
|
|
403
414
|
# Absolute left x-coordinate of the bounding box
|
@@ -449,10 +460,7 @@ module Prawn
|
|
449
460
|
end
|
450
461
|
|
451
462
|
# Width of the bounding box
|
452
|
-
|
453
|
-
def width
|
454
|
-
@width
|
455
|
-
end
|
463
|
+
attr_reader :width
|
456
464
|
|
457
465
|
# Height of the bounding box. If the box is 'stretchy' (unspecified
|
458
466
|
# height attribute), height is calculated as the distance from the top of
|
@@ -460,8 +468,11 @@ module Prawn
|
|
460
468
|
#
|
461
469
|
def height
|
462
470
|
return @height if @height
|
463
|
-
|
464
|
-
|
471
|
+
|
472
|
+
@stretched_height = [
|
473
|
+
(absolute_top - @document.y),
|
474
|
+
@stretched_height.to_f
|
475
|
+
].max
|
465
476
|
end
|
466
477
|
|
467
478
|
# an alias for absolute_left
|
@@ -489,8 +500,9 @@ module Prawn
|
|
489
500
|
end
|
490
501
|
end
|
491
502
|
|
492
|
-
# Returns +false+ when the box has a defined height, +true+ when the
|
493
|
-
# is being calculated on the fly based on the current vertical
|
503
|
+
# Returns +false+ when the box has a defined height, +true+ when the
|
504
|
+
# height is being calculated on the fly based on the current vertical
|
505
|
+
# position.
|
494
506
|
#
|
495
507
|
def stretchy?
|
496
508
|
!@height
|
@@ -500,14 +512,15 @@ module Prawn
|
|
500
512
|
#
|
501
513
|
def reference_bounds
|
502
514
|
if stretchy?
|
503
|
-
raise
|
515
|
+
raise NoReferenceBounds unless @parent
|
516
|
+
|
504
517
|
@parent.reference_bounds
|
505
518
|
else
|
506
519
|
self
|
507
520
|
end
|
508
521
|
end
|
509
522
|
|
510
|
-
|
523
|
+
alias update_height height
|
511
524
|
|
512
525
|
# Returns a deep copy of these bounds (including all parent bounds but
|
513
526
|
# not copying the reference to the Document).
|
@@ -516,10 +529,13 @@ module Prawn
|
|
516
529
|
def deep_copy
|
517
530
|
copy = dup
|
518
531
|
# Deep-copy the parent bounds
|
519
|
-
copy.instance_variable_set(
|
520
|
-
|
521
|
-
|
522
|
-
|
532
|
+
copy.instance_variable_set(
|
533
|
+
'@parent',
|
534
|
+
if @parent.is_a?(BoundingBox)
|
535
|
+
@parent.deep_copy
|
536
|
+
end
|
537
|
+
)
|
538
|
+
copy.instance_variable_set('@document', nil)
|
523
539
|
copy
|
524
540
|
end
|
525
541
|
|
@@ -529,11 +545,9 @@ module Prawn
|
|
529
545
|
#
|
530
546
|
# @private
|
531
547
|
def self.restore_deep_copy(bounds, document)
|
532
|
-
bounds.instance_variable_set(
|
548
|
+
bounds.instance_variable_set('@document', document)
|
533
549
|
bounds
|
534
550
|
end
|
535
|
-
|
536
551
|
end
|
537
|
-
|
538
552
|
end
|
539
553
|
end
|
@@ -1,16 +1,15 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# column_box.rb: Extends BoundingBox to allow for columns of text
|
4
4
|
#
|
5
5
|
# Author Paul Ostazeski.
|
6
6
|
#
|
7
7
|
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
8
|
|
9
|
-
require_relative
|
9
|
+
require_relative 'bounding_box'
|
10
10
|
|
11
11
|
module Prawn
|
12
12
|
class Document
|
13
|
-
|
14
13
|
# @group Experimental API
|
15
14
|
|
16
15
|
# A column box is a bounding box with the additional property that when
|
@@ -37,10 +36,10 @@ module Prawn
|
|
37
36
|
|
38
37
|
private
|
39
38
|
|
40
|
-
def init_column_box(user_block, options={}
|
39
|
+
def init_column_box(user_block, options = {})
|
41
40
|
parent_box = @bounding_box
|
42
41
|
|
43
|
-
|
42
|
+
yield(parent_box)
|
44
43
|
|
45
44
|
self.y = @bounding_box.absolute_top
|
46
45
|
user_block.call
|
@@ -53,11 +52,10 @@ module Prawn
|
|
53
52
|
# work.
|
54
53
|
#
|
55
54
|
class ColumnBox < BoundingBox
|
56
|
-
|
57
|
-
def initialize(document, parent, point, options={}) #:nodoc:
|
55
|
+
def initialize(document, parent, point, options = {}) #:nodoc:
|
58
56
|
super
|
59
57
|
@columns = options[:columns] || 3
|
60
|
-
@spacer
|
58
|
+
@spacer = options[:spacer] || @document.font_size
|
61
59
|
@current_column = 0
|
62
60
|
@reflow_margins = options[:reflow_margins]
|
63
61
|
end
|
@@ -111,7 +109,7 @@ module Prawn
|
|
111
109
|
def move_past_bottom
|
112
110
|
@current_column = (@current_column + 1) % @columns
|
113
111
|
@document.y = @y
|
114
|
-
if
|
112
|
+
if @current_column.zero?
|
115
113
|
if @reflow_margins
|
116
114
|
@y = @parent.absolute_top
|
117
115
|
end
|