giga-fast-kit 0.0.1

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.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/giga-fast-kit.gemspec +12 -0
  3. data/prawn-2.5.0/COPYING +2 -0
  4. data/prawn-2.5.0/GPLv2 +339 -0
  5. data/prawn-2.5.0/GPLv3 +674 -0
  6. data/prawn-2.5.0/LICENSE +56 -0
  7. data/prawn-2.5.0/data/fonts/Courier-Bold.afm +342 -0
  8. data/prawn-2.5.0/data/fonts/Courier-BoldOblique.afm +342 -0
  9. data/prawn-2.5.0/data/fonts/Courier-Oblique.afm +342 -0
  10. data/prawn-2.5.0/data/fonts/Courier.afm +342 -0
  11. data/prawn-2.5.0/data/fonts/Helvetica-Bold.afm +2827 -0
  12. data/prawn-2.5.0/data/fonts/Helvetica-BoldOblique.afm +2827 -0
  13. data/prawn-2.5.0/data/fonts/Helvetica-Oblique.afm +3051 -0
  14. data/prawn-2.5.0/data/fonts/Helvetica.afm +3051 -0
  15. data/prawn-2.5.0/data/fonts/MustRead.html +19 -0
  16. data/prawn-2.5.0/data/fonts/Symbol.afm +213 -0
  17. data/prawn-2.5.0/data/fonts/Times-Bold.afm +2588 -0
  18. data/prawn-2.5.0/data/fonts/Times-BoldItalic.afm +2384 -0
  19. data/prawn-2.5.0/data/fonts/Times-Italic.afm +2667 -0
  20. data/prawn-2.5.0/data/fonts/Times-Roman.afm +2419 -0
  21. data/prawn-2.5.0/data/fonts/ZapfDingbats.afm +225 -0
  22. data/prawn-2.5.0/lib/prawn/document/bounding_box.rb +625 -0
  23. data/prawn-2.5.0/lib/prawn/document/column_box.rb +177 -0
  24. data/prawn-2.5.0/lib/prawn/document/internals.rb +76 -0
  25. data/prawn-2.5.0/lib/prawn/document/span.rb +65 -0
  26. data/prawn-2.5.0/lib/prawn/document.rb +846 -0
  27. data/prawn-2.5.0/lib/prawn/encoding.rb +85 -0
  28. data/prawn-2.5.0/lib/prawn/errors.rb +73 -0
  29. data/prawn-2.5.0/lib/prawn/font.rb +567 -0
  30. data/prawn-2.5.0/lib/prawn/font_metric_cache.rb +50 -0
  31. data/prawn-2.5.0/lib/prawn/fonts/afm.rb +332 -0
  32. data/prawn-2.5.0/lib/prawn/fonts/dfont.rb +42 -0
  33. data/prawn-2.5.0/lib/prawn/fonts/otf.rb +14 -0
  34. data/prawn-2.5.0/lib/prawn/fonts/to_unicode_cmap.rb +151 -0
  35. data/prawn-2.5.0/lib/prawn/fonts/ttc.rb +41 -0
  36. data/prawn-2.5.0/lib/prawn/fonts/ttf.rb +615 -0
  37. data/prawn-2.5.0/lib/prawn/fonts.rb +14 -0
  38. data/prawn-2.5.0/lib/prawn/graphics/blend_mode.rb +62 -0
  39. data/prawn-2.5.0/lib/prawn/graphics/cap_style.rb +44 -0
  40. data/prawn-2.5.0/lib/prawn/graphics/color.rb +257 -0
  41. data/prawn-2.5.0/lib/prawn/graphics/dash.rb +123 -0
  42. data/prawn-2.5.0/lib/prawn/graphics/join_style.rb +60 -0
  43. data/prawn-2.5.0/lib/prawn/graphics/patterns.rb +389 -0
  44. data/prawn-2.5.0/lib/prawn/graphics/transformation.rb +172 -0
  45. data/prawn-2.5.0/lib/prawn/graphics/transparency.rb +79 -0
  46. data/prawn-2.5.0/lib/prawn/graphics.rb +791 -0
  47. data/prawn-2.5.0/lib/prawn/grid.rb +449 -0
  48. data/prawn-2.5.0/lib/prawn/image_handler.rb +61 -0
  49. data/prawn-2.5.0/lib/prawn/images/image.rb +48 -0
  50. data/prawn-2.5.0/lib/prawn/images/jpg.rb +121 -0
  51. data/prawn-2.5.0/lib/prawn/images/png.rb +383 -0
  52. data/prawn-2.5.0/lib/prawn/images.rb +195 -0
  53. data/prawn-2.5.0/lib/prawn/measurement_extensions.rb +82 -0
  54. data/prawn-2.5.0/lib/prawn/measurements.rb +129 -0
  55. data/prawn-2.5.0/lib/prawn/outline.rb +316 -0
  56. data/prawn-2.5.0/lib/prawn/repeater.rb +140 -0
  57. data/prawn-2.5.0/lib/prawn/security/arcfour.rb +54 -0
  58. data/prawn-2.5.0/lib/prawn/security.rb +308 -0
  59. data/prawn-2.5.0/lib/prawn/soft_mask.rb +105 -0
  60. data/prawn-2.5.0/lib/prawn/stamp.rb +147 -0
  61. data/prawn-2.5.0/lib/prawn/text/box.rb +192 -0
  62. data/prawn-2.5.0/lib/prawn/text/formatted/arranger.rb +396 -0
  63. data/prawn-2.5.0/lib/prawn/text/formatted/box.rb +725 -0
  64. data/prawn-2.5.0/lib/prawn/text/formatted/fragment.rb +373 -0
  65. data/prawn-2.5.0/lib/prawn/text/formatted/line_wrap.rb +335 -0
  66. data/prawn-2.5.0/lib/prawn/text/formatted/parser.rb +284 -0
  67. data/prawn-2.5.0/lib/prawn/text/formatted/wrap.rb +166 -0
  68. data/prawn-2.5.0/lib/prawn/text/formatted.rb +82 -0
  69. data/prawn-2.5.0/lib/prawn/text.rb +701 -0
  70. data/prawn-2.5.0/lib/prawn/transformation_stack.rb +63 -0
  71. data/prawn-2.5.0/lib/prawn/utilities.rb +34 -0
  72. data/prawn-2.5.0/lib/prawn/version.rb +6 -0
  73. data/prawn-2.5.0/lib/prawn/view.rb +116 -0
  74. data/prawn-2.5.0/lib/prawn.rb +83 -0
  75. metadata +114 -0
@@ -0,0 +1,177 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'bounding_box'
4
+
5
+ module Prawn
6
+ class Document # rubocop: disable Style/Documentation
7
+ # @group Experimental API
8
+
9
+ # A column box is a bounding box with the additional property that when
10
+ # text flows past the bottom, it will wrap first to another column on the
11
+ # same page, and only flow to the next page when all the columns are
12
+ # filled.
13
+ #
14
+ # `column_box` accepts the same parameters as {bounding_box}, as well as the
15
+ # number of `:columns` and a `:spacer` (in points) between columns. If
16
+ # resetting the top margin is desired on a new page (e.g. to allow for
17
+ # initial page wide column titles) the option `reflow_margins: true` can be
18
+ # set.
19
+ #
20
+ # @overload column_box(point, options = {})
21
+ # @param point [Array(Number, Number)]
22
+ # @param options [Hash{Symbol => any}]
23
+ # @option options :width [Number]
24
+ # width of the new column box, must be specified.
25
+ # @option options :height [Number]
26
+ # height of the new column box, stretchy box if omitted.
27
+ # @option options :hold_position [Boolean]
28
+ # whether to put cursor at the bottom of the column box.
29
+ # @option options :columns [Integer] (3)
30
+ # @option options :spacer [Number] (font_size)
31
+ # @option options :reflow_margins [Boolean] (false)
32
+ # @yieldparam parent_box [BoundingBox] parent bounding box
33
+ # @return [void]
34
+ def column_box(*args, &block)
35
+ init_column_box(block) do |parent_box|
36
+ map_to_absolute!(args[0])
37
+ @bounding_box = ColumnBox.new(self, parent_box, *args)
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def init_column_box(user_block, options = {})
44
+ parent_box = @bounding_box
45
+
46
+ yield(parent_box)
47
+
48
+ self.y = @bounding_box.absolute_top
49
+ user_block.call
50
+ self.y = @bounding_box.absolute_bottom unless options[:hold_position]
51
+
52
+ @bounding_box = parent_box
53
+ end
54
+
55
+ # Implements the necessary functionality to allow {Document#column_box} to
56
+ # work.
57
+ #
58
+ class ColumnBox < BoundingBox
59
+ # @param point [Array(Number, Number)]
60
+ # @param options [Hash{Symbol => any}]
61
+ # @option options :width [Number]
62
+ # width of the new column box, must be specified.
63
+ # @option options :height [Number]
64
+ # height of the new column box, stretchy box if omitted.
65
+ # @option options :columns [Integer] (3)
66
+ # @option options :spacer [Number] (font_size)
67
+ # @option options :reflow_margins [Boolean] (false)
68
+ def initialize(document, parent, point, options = {})
69
+ super
70
+ @columns = options[:columns] || 3
71
+ @spacer = options[:spacer] || @document.font_size
72
+ @current_column = 0
73
+ @reflow_margins = options[:reflow_margins]
74
+ end
75
+
76
+ # The column width, not the width of the whole box, before left and/or
77
+ # right padding.
78
+ #
79
+ # @return [Number]
80
+ def bare_column_width
81
+ (@width - (@spacer * (@columns - 1))) / @columns
82
+ end
83
+
84
+ # The column width after padding. Used to calculate how long a line of
85
+ # text can be.
86
+ #
87
+ # @return [Number]
88
+ def width
89
+ bare_column_width - (@total_left_padding + @total_right_padding)
90
+ end
91
+
92
+ # Column width including the spacer.
93
+ #
94
+ # @return [Number]
95
+ def width_of_column
96
+ bare_column_width + @spacer
97
+ end
98
+
99
+ # x coordinate of the left edge of the current column.
100
+ #
101
+ # @return [Number]
102
+ def left_side
103
+ absolute_left + (width_of_column * @current_column)
104
+ end
105
+
106
+ # Relative position of the left edge of the current column.
107
+ #
108
+ # @return [Number]
109
+ def left
110
+ width_of_column * @current_column
111
+ end
112
+
113
+ # x coordinate of the right edge of the current column.
114
+ #
115
+ # @return [Number]
116
+ def right_side
117
+ columns_from_right = @columns - (1 + @current_column)
118
+ absolute_right - (width_of_column * columns_from_right)
119
+ end
120
+
121
+ # Relative position of the right edge of the current column.
122
+ #
123
+ # @return [Number]
124
+ def right
125
+ left + width
126
+ end
127
+
128
+ # Moves to the next column or starts a new page if currently positioned at
129
+ # the rightmost column.
130
+ #
131
+ # @return [void]
132
+ def move_past_bottom
133
+ @current_column = (@current_column + 1) % @columns
134
+ @document.y = @y
135
+ if @current_column.zero?
136
+ if @reflow_margins
137
+ @y = @parent.absolute_top
138
+ end
139
+ @document.start_new_page
140
+ end
141
+ end
142
+
143
+ # Override the padding functions so as not to split the padding amount
144
+ # between all columns on the page.
145
+
146
+ # @private
147
+ # @param left_padding [Number]
148
+ # @return [void]
149
+ def add_left_padding(left_padding)
150
+ @total_left_padding += left_padding
151
+ @x += left_padding
152
+ end
153
+
154
+ # @private
155
+ # @param left_padding [Number]
156
+ # @return [void]
157
+ def subtract_left_padding(left_padding)
158
+ @total_left_padding -= left_padding
159
+ @x -= left_padding
160
+ end
161
+
162
+ # @private
163
+ # @param right_padding [Number]
164
+ # @return [void]
165
+ def add_right_padding(right_padding)
166
+ @total_right_padding += right_padding
167
+ end
168
+
169
+ # @private
170
+ # @param right_padding [Number]
171
+ # @return [void]
172
+ def subtract_right_padding(right_padding)
173
+ @total_right_padding -= right_padding
174
+ end
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ module Prawn
6
+ class Document
7
+ # This module exposes a few low-level PDF features for those who want
8
+ # to extend Prawn's core functionality. If you are not comfortable with
9
+ # low level PDF functionality as defined by Adobe's specification, chances
10
+ # are you won't need anything you find here.
11
+ #
12
+ # @private
13
+ module Internals
14
+ extend Forwardable
15
+
16
+ # These methods are not officially part of Prawn's public API,
17
+ # but they are used in documentation and possibly in extensions.
18
+ # Perhaps they will become part of the extension API?
19
+ # Anyway, for now it's not clear what we should do w. them.
20
+ delegate %i[
21
+ graphic_state
22
+ on_page_create
23
+ ] => :renderer
24
+
25
+ # Save current graphics state.
26
+ #
27
+ # @yield Restores graphic state after the block.
28
+ # @return [void]
29
+ def save_graphics_state(state = nil, &block)
30
+ save_transformation_stack
31
+ renderer.save_graphics_state(state, &block)
32
+ restore_transformation_stack if block
33
+ end
34
+
35
+ # Restore graphic state.
36
+ #
37
+ # @return [void]
38
+ def restore_graphics_state
39
+ restore_transformation_stack
40
+ renderer.restore_graphics_state
41
+ end
42
+
43
+ # @devnote
44
+ # FIXME: This is a circular reference, because in theory Prawn should be
45
+ # passing instances of renderer to PDF::Core::Page, but it's passing
46
+ # Prawn::Document objects instead.
47
+ #
48
+ # A proper design would probably not require Prawn to directly instantiate
49
+ # PDF::Core::Page objects at all!
50
+ delegate [:compression_enabled?] => :renderer
51
+
52
+ # @devnote
53
+ # FIXME: More circular references in PDF::Core::Page.
54
+ delegate %i[ref ref! deref] => :renderer
55
+
56
+ # @devnote
57
+ # FIXME: Another circular reference, because we mix in a module from
58
+ # PDF::Core to provide destinations, which in theory should not rely on
59
+ # a Prawn::Document object but is currently wired up that way.
60
+ delegate [:names] => :renderer
61
+
62
+ # @devnote
63
+ # FIXME: Circular reference because we mix PDF::Core::Text into
64
+ # Prawn::Document. PDF::Core::Text should either be split up or moved in
65
+ # its entirety back up into Prawn.
66
+ delegate [:add_content] => :renderer
67
+
68
+ # Document renderer.
69
+ #
70
+ # @return [PDF::Core::Renderer]
71
+ def renderer
72
+ @renderer ||= PDF::Core::Renderer.new(state)
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ # span.rb : Implements text columns
4
+ #
5
+ # Copyright September 2008, Gregory Brown. All Rights Reserved.
6
+ #
7
+ # This is free software. Please see the LICENSE and COPYING files for details.
8
+
9
+ module Prawn
10
+ class Document # rubocop: disable Style/Documentation
11
+ # @group Stable API
12
+
13
+ # A span is a special purpose bounding box that allows a column of elements
14
+ # to be positioned relative to the margin_box.
15
+ #
16
+ # This method is typically used for flowing a column of text from one page
17
+ # to the next.
18
+ #
19
+ # @example
20
+ # span(350, position: :center) do
21
+ # text "Here's some centered text in a 350 point column. " * 100
22
+ # end
23
+ #
24
+ # @param width [Number] The width of the column in PDF points
25
+ # @param options [Hash{Symbol => any }]
26
+ # @option options :position [:left, :center, :right, Number]
27
+ # position of the span relative to the page margins.
28
+ # @yield
29
+ # @return [void]
30
+ # @raise [ArgumentError] For unsupported `:position` value.
31
+ def span(width, options = {})
32
+ Prawn.verify_options([:position], options)
33
+ original_position = y
34
+
35
+ # FIXME: Any way to move this upstream?
36
+ left_boundary =
37
+ case options.fetch(:position, :left)
38
+ when :left
39
+ margin_box.absolute_left
40
+ when :center
41
+ margin_box.absolute_left + (margin_box.width / 2.0) - (width / 2.0)
42
+ when :right
43
+ margin_box.absolute_right - width
44
+ when Numeric
45
+ margin_box.absolute_left + options[:position]
46
+ else
47
+ raise ArgumentError, 'Invalid option for :position'
48
+ end
49
+
50
+ # we need to bust out of whatever nested bounding boxes we're in.
51
+ canvas do
52
+ bounding_box(
53
+ [
54
+ left_boundary,
55
+ margin_box.absolute_top,
56
+ ],
57
+ width: width,
58
+ ) do
59
+ self.y = original_position
60
+ yield
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end