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
data/data/pdfs/two_hexagons.pdf
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
%PDF-1.3
|
2
|
-
%����
|
3
|
-
1 0 obj
|
4
|
-
<< /Creator (Prawn)
|
5
|
-
/Producer (Prawn)
|
6
|
-
>>
|
7
|
-
endobj
|
8
|
-
2 0 obj
|
9
|
-
<< /Count 2
|
10
|
-
/Kids [5 0 R 7 0 R]
|
11
|
-
/Type /Pages
|
12
|
-
>>
|
13
|
-
endobj
|
14
|
-
3 0 obj
|
15
|
-
<< /Type /Catalog
|
16
|
-
/Pages 2 0 R
|
17
|
-
>>
|
18
|
-
endobj
|
19
|
-
4 0 obj
|
20
|
-
<< /Length 195
|
21
|
-
>>
|
22
|
-
stream
|
23
|
-
0.000 0.000 0.000 rg
|
24
|
-
0.000 0.000 0.000 RG
|
25
|
-
q
|
26
|
-
1.000 0.000 0.000 rg
|
27
|
-
136.000 286.000 m
|
28
|
-
236.000 336.000 l
|
29
|
-
336.000 286.000 l
|
30
|
-
336.000 186.000 l
|
31
|
-
236.000 136.000 l
|
32
|
-
136.000 186.000 l
|
33
|
-
136.000 286.000 l
|
34
|
-
f
|
35
|
-
Q
|
36
|
-
|
37
|
-
endstream
|
38
|
-
endobj
|
39
|
-
5 0 obj
|
40
|
-
<< /Contents 4 0 R
|
41
|
-
/Parent 2 0 R
|
42
|
-
/MediaBox [0 0 612.0 792.0]
|
43
|
-
/Type /Page
|
44
|
-
>>
|
45
|
-
endobj
|
46
|
-
6 0 obj
|
47
|
-
<< /Length 195
|
48
|
-
>>
|
49
|
-
stream
|
50
|
-
1.000 0.000 0.000 rg
|
51
|
-
0.000 0.000 0.000 RG
|
52
|
-
q
|
53
|
-
1.000 0.000 0.000 rg
|
54
|
-
136.000 286.000 m
|
55
|
-
236.000 336.000 l
|
56
|
-
336.000 286.000 l
|
57
|
-
336.000 186.000 l
|
58
|
-
236.000 136.000 l
|
59
|
-
136.000 186.000 l
|
60
|
-
136.000 286.000 l
|
61
|
-
f
|
62
|
-
Q
|
63
|
-
|
64
|
-
endstream
|
65
|
-
endobj
|
66
|
-
7 0 obj
|
67
|
-
<< /Contents 6 0 R
|
68
|
-
/Parent 2 0 R
|
69
|
-
/MediaBox [0 0 612.0 792.0]
|
70
|
-
/Type /Page
|
71
|
-
>>
|
72
|
-
endobj
|
73
|
-
xref
|
74
|
-
0 8
|
75
|
-
0000000000 65535 f
|
76
|
-
0000000015 00000 n
|
77
|
-
0000000071 00000 n
|
78
|
-
0000000134 00000 n
|
79
|
-
0000000183 00000 n
|
80
|
-
0000000429 00000 n
|
81
|
-
0000000520 00000 n
|
82
|
-
0000000766 00000 n
|
83
|
-
trailer
|
84
|
-
<< /Info 1 0 R
|
85
|
-
/Root 3 0 R
|
86
|
-
/Size 8
|
87
|
-
>>
|
88
|
-
startxref
|
89
|
-
857
|
90
|
-
%%EOF
|
data/data/pdfs/version_1_6.pdf
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
%PDF-1.6
|
2
|
-
%????
|
3
|
-
1 0 obj
|
4
|
-
<< /Creator (Prawn)
|
5
|
-
/Producer (Prawn)
|
6
|
-
>>
|
7
|
-
endobj
|
8
|
-
2 0 obj
|
9
|
-
<< /Kids [5 0 R]
|
10
|
-
/Type /Pages
|
11
|
-
/Count 1
|
12
|
-
>>
|
13
|
-
endobj
|
14
|
-
3 0 obj
|
15
|
-
<< /Type /Catalog
|
16
|
-
/Pages 2 0 R
|
17
|
-
>>
|
18
|
-
endobj
|
19
|
-
4 0 obj
|
20
|
-
<< /Length 195
|
21
|
-
>>
|
22
|
-
stream
|
23
|
-
0.000 0.000 0.000 rg
|
24
|
-
0.000 0.000 0.000 RG
|
25
|
-
q
|
26
|
-
1.000 0.000 0.000 rg
|
27
|
-
136.000 286.000 m
|
28
|
-
236.000 336.000 l
|
29
|
-
336.000 286.000 l
|
30
|
-
336.000 186.000 l
|
31
|
-
236.000 136.000 l
|
32
|
-
136.000 186.000 l
|
33
|
-
136.000 286.000 l
|
34
|
-
f
|
35
|
-
Q
|
36
|
-
|
37
|
-
endstream
|
38
|
-
endobj
|
39
|
-
5 0 obj
|
40
|
-
<< /Contents 4 0 R
|
41
|
-
/Type /Page
|
42
|
-
/MediaBox [0 0 612.0 792.0]
|
43
|
-
/Parent 2 0 R
|
44
|
-
>>
|
45
|
-
endobj
|
46
|
-
xref
|
47
|
-
0 6
|
48
|
-
0000000000 65535 f
|
49
|
-
0000000015 00000 n
|
50
|
-
0000000071 00000 n
|
51
|
-
0000000128 00000 n
|
52
|
-
0000000177 00000 n
|
53
|
-
0000000423 00000 n
|
54
|
-
trailer
|
55
|
-
<< /Info 1 0 R
|
56
|
-
/Size 6
|
57
|
-
/Root 3 0 R
|
58
|
-
>>
|
59
|
-
startxref
|
60
|
-
514
|
61
|
-
%%EOF
|
data/data/shift_jis_text.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
���C���y�[�W
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# graphics_state.rb: Implements graphics state saving and restoring
|
4
|
-
#
|
5
|
-
# Copyright January 2010, Michael Witrant. All Rights Reserved.
|
6
|
-
#
|
7
|
-
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
-
#
|
9
|
-
|
10
|
-
module Prawn
|
11
|
-
class Document
|
12
|
-
module GraphicsState # @private
|
13
|
-
|
14
|
-
# Pushes the current graphics state on to the graphics state stack so we
|
15
|
-
# can restore it when finished with a change we want to isolate (such as
|
16
|
-
# modifying the transformation matrix). Used in pairs with
|
17
|
-
# restore_graphics_state or passed a block
|
18
|
-
#
|
19
|
-
# Example without a block:
|
20
|
-
#
|
21
|
-
# save_graphics_state
|
22
|
-
# rotate 30
|
23
|
-
# text "rotated text"
|
24
|
-
# restore_graphics_state
|
25
|
-
#
|
26
|
-
# Example with a block:
|
27
|
-
#
|
28
|
-
# save_graphics_state do
|
29
|
-
# rotate 30
|
30
|
-
# text "rotated text"
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
|
34
|
-
def open_graphics_state
|
35
|
-
add_content "q"
|
36
|
-
end
|
37
|
-
|
38
|
-
def close_graphics_state
|
39
|
-
add_content "Q"
|
40
|
-
end
|
41
|
-
|
42
|
-
def save_graphics_state(graphic_state = nil)
|
43
|
-
graphic_stack.save_graphic_state(graphic_state)
|
44
|
-
open_graphics_state
|
45
|
-
if block_given?
|
46
|
-
yield
|
47
|
-
restore_graphics_state
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# Pops the last saved graphics state off the graphics state stack and
|
52
|
-
# restores the state to those values
|
53
|
-
def restore_graphics_state
|
54
|
-
if graphic_stack.empty?
|
55
|
-
raise PDF::Core::Errors::EmptyGraphicStateStack,
|
56
|
-
"\n You have reached the end of the graphic state stack"
|
57
|
-
end
|
58
|
-
close_graphics_state
|
59
|
-
graphic_stack.restore_graphic_state
|
60
|
-
end
|
61
|
-
|
62
|
-
def graphic_stack
|
63
|
-
state.page.stack
|
64
|
-
end
|
65
|
-
|
66
|
-
def graphic_state
|
67
|
-
save_graphics_state unless graphic_stack.current_state
|
68
|
-
graphic_stack.current_state
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
data/lib/prawn/font/afm.rb
DELETED
@@ -1,247 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# prawn/font/afm.rb : Implements AFM font support for Prawn
|
4
|
-
#
|
5
|
-
# Copyright May 2008, Gregory Brown / James Healy. All Rights Reserved.
|
6
|
-
#
|
7
|
-
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
-
|
9
|
-
require_relative '../../prawn/encoding'
|
10
|
-
|
11
|
-
module Prawn
|
12
|
-
class Font
|
13
|
-
|
14
|
-
# @private
|
15
|
-
|
16
|
-
class AFM < Font
|
17
|
-
BUILT_INS = %w[ Courier Helvetica Times-Roman Symbol ZapfDingbats
|
18
|
-
Courier-Bold Courier-Oblique Courier-BoldOblique
|
19
|
-
Times-Bold Times-Italic Times-BoldItalic
|
20
|
-
Helvetica-Bold Helvetica-Oblique Helvetica-BoldOblique ]
|
21
|
-
|
22
|
-
def unicode?
|
23
|
-
false
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.metrics_path
|
27
|
-
if m = ENV['METRICS']
|
28
|
-
@metrics_path ||= m.split(':')
|
29
|
-
else
|
30
|
-
@metrics_path ||= [
|
31
|
-
".", "/usr/lib/afm",
|
32
|
-
"/usr/local/lib/afm",
|
33
|
-
"/usr/openwin/lib/fonts/afm",
|
34
|
-
Prawn::DATADIR+'/fonts']
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
attr_reader :attributes #:nodoc:
|
39
|
-
|
40
|
-
def initialize(document, name, options={}) #:nodoc:
|
41
|
-
unless BUILT_INS.include?(name)
|
42
|
-
raise Prawn::Errors::UnknownFont, "#{name} is not a known font."
|
43
|
-
end
|
44
|
-
|
45
|
-
super
|
46
|
-
|
47
|
-
@@winansi ||= Prawn::Encoding::WinAnsi.new # parse data/encodings/win_ansi.txt once only
|
48
|
-
@@font_data ||= SynchronizedCache.new # parse each ATM font file once only
|
49
|
-
|
50
|
-
file_name = @name.dup
|
51
|
-
file_name << ".afm" unless file_name =~ /\.afm$/
|
52
|
-
file_name = file_name[0] == ?/ ? file_name : find_font(file_name)
|
53
|
-
|
54
|
-
font_data = @@font_data[file_name] ||= parse_afm(file_name)
|
55
|
-
@glyph_widths = font_data[:glyph_widths]
|
56
|
-
@glyph_table = font_data[:glyph_table]
|
57
|
-
@bounding_boxes = font_data[:bounding_boxes]
|
58
|
-
@kern_pairs = font_data[:kern_pairs]
|
59
|
-
@kern_pair_table = font_data[:kern_pair_table]
|
60
|
-
@attributes = font_data[:attributes]
|
61
|
-
|
62
|
-
@ascender = @attributes["ascender"].to_i
|
63
|
-
@descender = @attributes["descender"].to_i
|
64
|
-
@line_gap = Float(bbox[3] - bbox[1]) - (@ascender - @descender)
|
65
|
-
end
|
66
|
-
|
67
|
-
# The font bbox, as an array of integers
|
68
|
-
#
|
69
|
-
def bbox
|
70
|
-
@bbox ||= @attributes['fontbbox'].split(/\s+/).map { |e| Integer(e) }
|
71
|
-
end
|
72
|
-
|
73
|
-
# NOTE: String *must* be encoded as WinAnsi
|
74
|
-
def compute_width_of(string, options={}) #:nodoc:
|
75
|
-
scale = (options[:size] || size) / 1000.0
|
76
|
-
|
77
|
-
if options[:kerning]
|
78
|
-
strings, numbers = kern(string).partition { |e| e.is_a?(String) }
|
79
|
-
total_kerning_offset = numbers.inject(0.0) { |s,r| s + r }
|
80
|
-
(unscaled_width_of(strings.join) - total_kerning_offset) * scale
|
81
|
-
else
|
82
|
-
unscaled_width_of(string) * scale
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Returns true if the font has kerning data, false otherwise
|
87
|
-
#
|
88
|
-
def has_kerning_data?
|
89
|
-
@kern_pairs.any?
|
90
|
-
end
|
91
|
-
|
92
|
-
# built-in fonts only work with winansi encoding, so translate the
|
93
|
-
# string. Changes the encoding in-place, so the argument itself
|
94
|
-
# is replaced with a string in WinAnsi encoding.
|
95
|
-
#
|
96
|
-
def normalize_encoding(text)
|
97
|
-
enc = @@winansi
|
98
|
-
text.unpack("U*").collect { |i| enc[i] }.pack("C*")
|
99
|
-
rescue ArgumentError
|
100
|
-
raise Prawn::Errors::IncompatibleStringEncoding,
|
101
|
-
"Arguments to text methods must be UTF-8 encoded"
|
102
|
-
end
|
103
|
-
|
104
|
-
# Returns the number of characters in +str+ (a WinAnsi-encoded string).
|
105
|
-
#
|
106
|
-
def character_count(str)
|
107
|
-
str.length
|
108
|
-
end
|
109
|
-
|
110
|
-
# Perform any changes to the string that need to happen
|
111
|
-
# before it is rendered to the canvas. Returns an array of
|
112
|
-
# subset "chunks", where each chunk is an array of two elements.
|
113
|
-
# The first element is the font subset number, and the second
|
114
|
-
# is either a string or an array (for kerned text).
|
115
|
-
#
|
116
|
-
# For Adobe fonts, there is only ever a single subset, so
|
117
|
-
# the first element of the array is "0", and the second is
|
118
|
-
# the string itself (or an array, if kerning is performed).
|
119
|
-
#
|
120
|
-
# The +text+ parameter must be in WinAnsi encoding (cp1252).
|
121
|
-
#
|
122
|
-
def encode_text(text, options={})
|
123
|
-
[[0, options[:kerning] ? kern(text) : text]]
|
124
|
-
end
|
125
|
-
|
126
|
-
def glyph_present?(char)
|
127
|
-
if char == "_"
|
128
|
-
true
|
129
|
-
else
|
130
|
-
normalize_encoding(char) != "_"
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
private
|
135
|
-
|
136
|
-
def register(subset)
|
137
|
-
font_dict = {:Type => :Font,
|
138
|
-
:Subtype => :Type1,
|
139
|
-
:BaseFont => name.to_sym}
|
140
|
-
|
141
|
-
# Symbolic AFM fonts (Symbol, ZapfDingbats) have their own encodings
|
142
|
-
font_dict.merge!(:Encoding => :WinAnsiEncoding) unless symbolic?
|
143
|
-
|
144
|
-
@document.ref!(font_dict)
|
145
|
-
end
|
146
|
-
|
147
|
-
def symbolic?
|
148
|
-
attributes["characterset"] == "Special"
|
149
|
-
end
|
150
|
-
|
151
|
-
def find_font(file)
|
152
|
-
self.class.metrics_path.find { |f| File.exist? "#{f}/#{file}" } + "/#{file}"
|
153
|
-
rescue NoMethodError
|
154
|
-
raise Prawn::Errors::UnknownFont,
|
155
|
-
"Couldn't find the font: #{file} in any of:\n" +
|
156
|
-
self.class.metrics_path.join("\n")
|
157
|
-
end
|
158
|
-
|
159
|
-
def parse_afm(file_name)
|
160
|
-
data = {:glyph_widths => {}, :bounding_boxes => {}, :kern_pairs => {}, :attributes => {}}
|
161
|
-
section = []
|
162
|
-
|
163
|
-
File.foreach(file_name) do |line|
|
164
|
-
case line
|
165
|
-
when /^Start(\w+)/
|
166
|
-
section.push $1
|
167
|
-
next
|
168
|
-
when /^End(\w+)/
|
169
|
-
section.pop
|
170
|
-
next
|
171
|
-
end
|
172
|
-
|
173
|
-
case section
|
174
|
-
when ["FontMetrics", "CharMetrics"]
|
175
|
-
next unless line =~ /^CH?\s/
|
176
|
-
|
177
|
-
name = line[/\bN\s+(\.?\w+)\s*;/, 1]
|
178
|
-
data[:glyph_widths][name] = line[/\bWX\s+(\d+)\s*;/, 1].to_i
|
179
|
-
data[:bounding_boxes][name] = line[/\bB\s+([^;]+);/, 1].to_s.rstrip
|
180
|
-
when ["FontMetrics", "KernData", "KernPairs"]
|
181
|
-
next unless line =~ /^KPX\s+(\.?\w+)\s+(\.?\w+)\s+(-?\d+)/
|
182
|
-
data[:kern_pairs][[$1, $2]] = $3.to_i
|
183
|
-
when ["FontMetrics", "KernData", "TrackKern"],
|
184
|
-
["FontMetrics", "Composites"]
|
185
|
-
next
|
186
|
-
else
|
187
|
-
parse_generic_afm_attribute(line, data)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
# process data parsed from AFM file to build tables which
|
192
|
-
# will be used when measuring and kerning text
|
193
|
-
data[:glyph_table] = (0..255).map do |i|
|
194
|
-
data[:glyph_widths][Encoding::WinAnsi::CHARACTERS[i]].to_i
|
195
|
-
end
|
196
|
-
|
197
|
-
character_hash = Hash[Encoding::WinAnsi::CHARACTERS.zip((0..Encoding::WinAnsi::CHARACTERS.size).to_a)]
|
198
|
-
data[:kern_pair_table] = data[:kern_pairs].inject({}) do |h,p|
|
199
|
-
h[p[0].map { |n| character_hash[n] }] = p[1]
|
200
|
-
h
|
201
|
-
end
|
202
|
-
|
203
|
-
data.each_value { |hash| hash.freeze }
|
204
|
-
data.freeze
|
205
|
-
end
|
206
|
-
|
207
|
-
def parse_generic_afm_attribute(line, hash)
|
208
|
-
line =~ /(^\w+)\s+(.*)/
|
209
|
-
key, value = $1.to_s.downcase, $2
|
210
|
-
|
211
|
-
hash[:attributes][key] = hash[:attributes][key] ? Array(hash[:attributes][key]) << value : value
|
212
|
-
end
|
213
|
-
|
214
|
-
# converts a string into an array with spacing offsets
|
215
|
-
# bewteen characters that need to be kerned
|
216
|
-
#
|
217
|
-
# String *must* be encoded as WinAnsi
|
218
|
-
#
|
219
|
-
def kern(string)
|
220
|
-
kerned = [[]]
|
221
|
-
last_byte = nil
|
222
|
-
|
223
|
-
string.each_byte do |byte|
|
224
|
-
if k = last_byte && @kern_pair_table[[last_byte, byte]]
|
225
|
-
kerned << -k << [byte]
|
226
|
-
else
|
227
|
-
kerned.last << byte
|
228
|
-
end
|
229
|
-
last_byte = byte
|
230
|
-
end
|
231
|
-
|
232
|
-
kerned.map { |e|
|
233
|
-
e = (Array === e ? e.pack("C*") : e)
|
234
|
-
e.respond_to?(:force_encoding) ? e.force_encoding(::Encoding::Windows_1252) : e
|
235
|
-
}
|
236
|
-
end
|
237
|
-
|
238
|
-
private
|
239
|
-
|
240
|
-
def unscaled_width_of(string)
|
241
|
-
string.bytes.inject(0) do |s,r|
|
242
|
-
s + @glyph_table[r]
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# image.rb: Table image cells.
|
4
|
-
#
|
5
|
-
# Copyright September 2010, Brad Ediger. All Rights Reserved.
|
6
|
-
#
|
7
|
-
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
-
module Prawn
|
9
|
-
class Table
|
10
|
-
class Cell
|
11
|
-
|
12
|
-
# @private
|
13
|
-
class Image < Cell
|
14
|
-
|
15
|
-
def initialize(pdf, point, options={})
|
16
|
-
@image_options = {}
|
17
|
-
super
|
18
|
-
|
19
|
-
@pdf_object, @image_info = @pdf.build_image_object(@file)
|
20
|
-
@natural_width, @natural_height = @image_info.calc_image_dimensions(
|
21
|
-
@image_options)
|
22
|
-
end
|
23
|
-
|
24
|
-
def image=(file)
|
25
|
-
@file = file
|
26
|
-
end
|
27
|
-
|
28
|
-
def scale=(s)
|
29
|
-
@image_options[:scale] = s
|
30
|
-
end
|
31
|
-
|
32
|
-
def fit=(f)
|
33
|
-
@image_options[:fit] = f
|
34
|
-
end
|
35
|
-
|
36
|
-
def image_height=(h)
|
37
|
-
@image_options[:height] = h
|
38
|
-
end
|
39
|
-
|
40
|
-
def image_width=(w)
|
41
|
-
@image_options[:width] = w
|
42
|
-
end
|
43
|
-
|
44
|
-
def position=(p)
|
45
|
-
@image_options[:position] = p
|
46
|
-
end
|
47
|
-
|
48
|
-
def vposition=(vp)
|
49
|
-
@image_options[:vposition] = vp
|
50
|
-
end
|
51
|
-
|
52
|
-
def natural_content_width
|
53
|
-
@natural_width
|
54
|
-
end
|
55
|
-
|
56
|
-
def natural_content_height
|
57
|
-
@natural_height
|
58
|
-
end
|
59
|
-
|
60
|
-
# Draw the image on the page.
|
61
|
-
#
|
62
|
-
def draw_content
|
63
|
-
@pdf.embed_image(@pdf_object, @image_info, @image_options)
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# Accessors for using a Cell inside a Table.
|
4
|
-
#
|
5
|
-
# Contributed by Brad Ediger.
|
6
|
-
#
|
7
|
-
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
-
|
9
|
-
module Prawn
|
10
|
-
class Table
|
11
|
-
|
12
|
-
class Cell
|
13
|
-
|
14
|
-
# This module extends Cell objects when they are used in a table (as
|
15
|
-
# opposed to standalone). Its properties apply to cells-in-tables but not
|
16
|
-
# cells themselves.
|
17
|
-
#
|
18
|
-
# @private
|
19
|
-
module InTable
|
20
|
-
|
21
|
-
# Row number (0-based).
|
22
|
-
#
|
23
|
-
attr_accessor :row
|
24
|
-
|
25
|
-
# Column number (0-based).
|
26
|
-
#
|
27
|
-
attr_accessor :column
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# span_dummy.rb: Placeholder for non-master spanned cells.
|
4
|
-
#
|
5
|
-
# Copyright December 2011, Brad Ediger. All Rights Reserved.
|
6
|
-
#
|
7
|
-
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
-
module Prawn
|
9
|
-
class Table
|
10
|
-
class Cell
|
11
|
-
|
12
|
-
# A Cell object used to represent all but the topmost cell in a span
|
13
|
-
# group.
|
14
|
-
#
|
15
|
-
# @private
|
16
|
-
class SpanDummy < Cell
|
17
|
-
def initialize(pdf, master_cell)
|
18
|
-
super(pdf, [0, pdf.cursor])
|
19
|
-
@master_cell = master_cell
|
20
|
-
@padding = [0, 0, 0, 0]
|
21
|
-
end
|
22
|
-
|
23
|
-
# By default, a span dummy will never increase the height demand.
|
24
|
-
#
|
25
|
-
def natural_content_height
|
26
|
-
0
|
27
|
-
end
|
28
|
-
|
29
|
-
# By default, a span dummy will never increase the width demand.
|
30
|
-
#
|
31
|
-
def natural_content_width
|
32
|
-
0
|
33
|
-
end
|
34
|
-
|
35
|
-
def avg_spanned_min_width
|
36
|
-
@master_cell.avg_spanned_min_width
|
37
|
-
end
|
38
|
-
|
39
|
-
# Dummy cells have nothing to draw.
|
40
|
-
#
|
41
|
-
def draw_borders(pt)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Dummy cells have nothing to draw.
|
45
|
-
#
|
46
|
-
def draw_bounded_content(pt)
|
47
|
-
end
|
48
|
-
|
49
|
-
def padding_right=(val)
|
50
|
-
@master_cell.padding_right = val if rightmost?
|
51
|
-
end
|
52
|
-
|
53
|
-
def padding_bottom=(val)
|
54
|
-
@master_cell.padding_bottom = val if bottommost?
|
55
|
-
end
|
56
|
-
|
57
|
-
def border_right_color=(val)
|
58
|
-
@master_cell.border_right_color = val if rightmost?
|
59
|
-
end
|
60
|
-
|
61
|
-
def border_bottom_color=(val)
|
62
|
-
@master_cell.border_bottom_color = val if bottommost?
|
63
|
-
end
|
64
|
-
|
65
|
-
def border_right_width=(val)
|
66
|
-
@master_cell.border_right_width = val if rightmost?
|
67
|
-
end
|
68
|
-
|
69
|
-
def border_bottom_width=(val)
|
70
|
-
@master_cell.border_bottom_width = val if bottommost?
|
71
|
-
end
|
72
|
-
|
73
|
-
def background_color
|
74
|
-
@master_cell.background_color
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
# Are we on the right border of the span?
|
80
|
-
#
|
81
|
-
def rightmost?
|
82
|
-
@column == @master_cell.column + @master_cell.colspan - 1
|
83
|
-
end
|
84
|
-
|
85
|
-
# Are we on the bottom border of the span?
|
86
|
-
#
|
87
|
-
def bottommost?
|
88
|
-
@row == @master_cell.row + @master_cell.rowspan - 1
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|