prawn 2.2.2 → 2.3.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.tar.gz.sig +0 -0
- data/GPLv2 +20 -21
- data/Gemfile +2 -0
- data/Rakefile +10 -3
- data/lib/prawn.rb +9 -3
- data/lib/prawn/document.rb +40 -18
- data/lib/prawn/document/bounding_box.rb +9 -4
- data/lib/prawn/document/column_box.rb +2 -0
- data/lib/prawn/document/internals.rb +6 -4
- data/lib/prawn/document/span.rb +2 -0
- data/lib/prawn/encoding.rb +4 -1
- data/lib/prawn/errors.rb +2 -0
- data/lib/prawn/font.rb +34 -17
- data/lib/prawn/font_metric_cache.rb +8 -3
- data/lib/prawn/{font → fonts}/afm.rb +14 -7
- data/lib/prawn/{font → fonts}/dfont.rb +3 -1
- data/lib/prawn/fonts/otf.rb +11 -0
- data/lib/prawn/{font → fonts}/ttc.rb +3 -1
- data/lib/prawn/{font → fonts}/ttf.rb +23 -12
- data/lib/prawn/graphics.rb +24 -26
- data/lib/prawn/graphics/blend_mode.rb +2 -0
- data/lib/prawn/graphics/cap_style.rb +2 -0
- data/lib/prawn/graphics/color.rb +8 -3
- data/lib/prawn/graphics/dash.rb +3 -1
- data/lib/prawn/graphics/join_style.rb +2 -0
- data/lib/prawn/graphics/patterns.rb +7 -2
- data/lib/prawn/graphics/transformation.rb +5 -1
- data/lib/prawn/graphics/transparency.rb +2 -0
- data/lib/prawn/grid.rb +39 -38
- data/lib/prawn/image_handler.rb +2 -0
- data/lib/prawn/images.rb +21 -19
- data/lib/prawn/images/image.rb +2 -0
- data/lib/prawn/images/jpg.rb +2 -0
- data/lib/prawn/images/png.rb +9 -9
- data/lib/prawn/measurement_extensions.rb +2 -0
- data/lib/prawn/measurements.rb +5 -0
- data/lib/prawn/outline.rb +2 -0
- data/lib/prawn/repeater.rb +2 -0
- data/lib/prawn/security.rb +26 -24
- data/lib/prawn/security/arcfour.rb +2 -0
- data/lib/prawn/soft_mask.rb +3 -1
- data/lib/prawn/stamp.rb +4 -1
- data/lib/prawn/text.rb +14 -12
- data/lib/prawn/text/box.rb +3 -1
- data/lib/prawn/text/formatted.rb +2 -0
- data/lib/prawn/text/formatted/arranger.rb +12 -12
- data/lib/prawn/text/formatted/box.rb +23 -13
- data/lib/prawn/text/formatted/fragment.rb +2 -0
- data/lib/prawn/text/formatted/line_wrap.rb +10 -8
- data/lib/prawn/text/formatted/parser.rb +8 -10
- data/lib/prawn/text/formatted/wrap.rb +4 -2
- data/lib/prawn/transformation_stack.rb +5 -2
- data/lib/prawn/utilities.rb +2 -2
- data/lib/prawn/version.rb +3 -1
- data/lib/prawn/view.rb +15 -7
- data/manual/basic_concepts/adding_pages.rb +2 -0
- data/manual/basic_concepts/basic_concepts.rb +4 -2
- data/manual/basic_concepts/creation.rb +2 -0
- data/manual/basic_concepts/cursor.rb +2 -0
- data/manual/basic_concepts/measurement.rb +3 -1
- data/manual/basic_concepts/origin.rb +2 -0
- data/manual/basic_concepts/other_cursor_helpers.rb +2 -0
- data/manual/basic_concepts/view.rb +2 -0
- data/manual/bounding_box/bounding_box.rb +4 -2
- data/manual/bounding_box/bounds.rb +6 -4
- data/manual/bounding_box/canvas.rb +2 -0
- data/manual/bounding_box/creation.rb +2 -0
- data/manual/bounding_box/indentation.rb +2 -0
- data/manual/bounding_box/nesting.rb +2 -0
- data/manual/bounding_box/russian_boxes.rb +6 -4
- data/manual/bounding_box/stretchy.rb +2 -0
- data/manual/contents.rb +2 -0
- data/manual/cover.rb +10 -7
- data/manual/document_and_page_options/background.rb +2 -0
- data/manual/document_and_page_options/document_and_page_options.rb +4 -2
- data/manual/document_and_page_options/metadata.rb +2 -0
- data/manual/document_and_page_options/page_margins.rb +2 -0
- data/manual/document_and_page_options/page_size.rb +2 -0
- data/manual/document_and_page_options/print_scaling.rb +2 -0
- data/manual/example_helper.rb +5 -2
- data/manual/graphics/blend_mode.rb +6 -4
- data/manual/graphics/circle_and_ellipse.rb +2 -0
- data/manual/graphics/color.rb +2 -0
- data/manual/graphics/common_lines.rb +2 -0
- data/manual/graphics/fill_and_stroke.rb +2 -0
- data/manual/graphics/fill_rules.rb +2 -0
- data/manual/graphics/gradients.rb +2 -0
- data/manual/graphics/graphics.rb +4 -2
- data/manual/graphics/helper.rb +2 -0
- data/manual/graphics/line_width.rb +3 -0
- data/manual/graphics/lines_and_curves.rb +2 -0
- data/manual/graphics/polygon.rb +2 -0
- data/manual/graphics/rectangle.rb +2 -0
- data/manual/graphics/rotate.rb +2 -0
- data/manual/graphics/scale.rb +2 -0
- data/manual/graphics/soft_masks.rb +2 -0
- data/manual/graphics/stroke_cap.rb +3 -1
- data/manual/graphics/stroke_dash.rb +2 -0
- data/manual/graphics/stroke_join.rb +3 -1
- data/manual/graphics/translate.rb +2 -0
- data/manual/graphics/transparency.rb +2 -0
- data/manual/how_to_read_this_manual.rb +2 -0
- data/manual/images/absolute_position.rb +2 -0
- data/manual/images/fit.rb +2 -0
- data/manual/images/horizontal.rb +3 -1
- data/manual/images/images.rb +4 -2
- data/manual/images/plain_image.rb +2 -0
- data/manual/images/scale.rb +2 -0
- data/manual/images/vertical.rb +3 -1
- data/manual/images/width_and_height.rb +2 -0
- data/manual/layout/boxes.rb +2 -0
- data/manual/layout/content.rb +2 -0
- data/manual/layout/layout.rb +4 -2
- data/manual/layout/simple_grid.rb +2 -0
- data/manual/outline/add_subsection_to.rb +2 -0
- data/manual/outline/insert_section_after.rb +2 -0
- data/manual/outline/outline.rb +4 -2
- data/manual/outline/sections_and_pages.rb +2 -0
- data/manual/repeatable_content/alternate_page_numbering.rb +2 -0
- data/manual/repeatable_content/page_numbering.rb +2 -0
- data/manual/repeatable_content/repeatable_content.rb +4 -2
- data/manual/repeatable_content/repeater.rb +2 -0
- data/manual/repeatable_content/stamp.rb +2 -0
- data/manual/security/encryption.rb +2 -0
- data/manual/security/permissions.rb +2 -0
- data/manual/security/security.rb +4 -2
- data/manual/table.rb +2 -0
- data/manual/text/alignment.rb +2 -0
- data/manual/text/color.rb +2 -0
- data/manual/text/column_box.rb +4 -2
- data/manual/text/fallback_fonts.rb +4 -2
- data/manual/text/font.rb +2 -0
- data/manual/text/font_size.rb +2 -0
- data/manual/text/font_style.rb +4 -2
- data/manual/text/formatted_callbacks.rb +2 -0
- data/manual/text/formatted_text.rb +3 -1
- data/manual/text/free_flowing_text.rb +2 -0
- data/manual/text/inline.rb +2 -0
- data/manual/text/kerning_and_character_spacing.rb +2 -0
- data/manual/text/leading.rb +2 -0
- data/manual/text/line_wrapping.rb +4 -1
- data/manual/text/paragraph_indentation.rb +2 -0
- data/manual/text/positioned_text.rb +2 -0
- data/manual/text/registering_families.rb +4 -2
- data/manual/text/rendering_and_color.rb +2 -0
- data/manual/text/right_to_left_text.rb +2 -0
- data/manual/text/rotation.rb +3 -1
- data/manual/text/single_usage.rb +2 -0
- data/manual/text/text.rb +4 -3
- data/manual/text/text_box_excess.rb +2 -0
- data/manual/text/text_box_extensions.rb +2 -0
- data/manual/text/text_box_overflow.rb +3 -1
- data/manual/text/utf8.rb +3 -1
- data/manual/text/win_ansi_charset.rb +6 -3
- data/prawn.gemspec +14 -11
- data/spec/extensions/encoding_helpers.rb +4 -2
- data/spec/prawn/document/bounding_box_spec.rb +8 -8
- data/spec/prawn/document/column_box_spec.rb +2 -0
- data/spec/prawn/document/security_spec.rb +12 -9
- data/spec/prawn/document_annotations_spec.rb +2 -0
- data/spec/prawn/document_destinations_spec.rb +2 -0
- data/spec/prawn/document_grid_spec.rb +3 -0
- data/spec/prawn/document_reference_spec.rb +2 -0
- data/spec/prawn/document_span_spec.rb +2 -0
- data/spec/prawn/document_spec.rb +59 -14
- data/spec/prawn/font_metric_cache_spec.rb +2 -0
- data/spec/prawn/font_spec.rb +45 -16
- data/spec/prawn/graphics/blend_mode_spec.rb +4 -2
- data/spec/prawn/graphics/transparency_spec.rb +2 -0
- data/spec/prawn/graphics_spec.rb +40 -20
- data/spec/prawn/graphics_stroke_styles_spec.rb +2 -0
- data/spec/prawn/image_handler_spec.rb +2 -0
- data/spec/prawn/images/jpg_spec.rb +2 -0
- data/spec/prawn/images/png_spec.rb +2 -0
- data/spec/prawn/images_spec.rb +56 -2
- data/spec/prawn/measurements_extensions_spec.rb +2 -0
- data/spec/prawn/outline_spec.rb +6 -2
- data/spec/prawn/repeater_spec.rb +6 -4
- data/spec/prawn/soft_mask_spec.rb +2 -0
- data/spec/prawn/stamp_spec.rb +11 -7
- data/spec/prawn/text/box_spec.rb +26 -27
- data/spec/prawn/text/formatted/arranger_spec.rb +30 -28
- data/spec/prawn/text/formatted/box_spec.rb +78 -57
- data/spec/prawn/text/formatted/fragment_spec.rb +10 -8
- data/spec/prawn/text/formatted/line_wrap_spec.rb +8 -5
- data/spec/prawn/text/formatted/parser_spec.rb +32 -2
- data/spec/prawn/text_draw_text_spec.rb +5 -3
- data/spec/prawn/text_rendering_mode_spec.rb +7 -1
- data/spec/prawn/text_spacing_spec.rb +6 -4
- data/spec/prawn/text_spec.rb +9 -7
- data/spec/prawn/text_with_inline_formatting_spec.rb +3 -1
- data/spec/prawn/transformation_stack_spec.rb +2 -0
- data/spec/prawn/view_spec.rb +18 -0
- data/spec/{manual_spec.rb → prawn_manual_spec.rb} +6 -4
- data/spec/spec_helper.rb +9 -10
- metadata +86 -73
- metadata.gz.sig +4 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 1dd091ffaaed7c69fe8a0353317736d1f145e91f3f133a6d04ed0cffd7b5eb37
         | 
| 4 | 
            +
              data.tar.gz: 98d1b0c973c9bf1947681ea971240fe9c351a9bcc1a74c91e7f8f677510eb11c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9b75677d2586bf8a812549075cc9532bc02f78dc18b0e0db99711ad1087586f4fef6ae2f244e96a73366172410357d19e9371ac7b7eacf4a3bcbf85292ffb028
         | 
| 7 | 
            +
              data.tar.gz: 138ac861e5016c49836a882c8beda2d2ed250e63959307ffe720624d322fd92b21ca71945e9cf58d0439851f8ebec515d13fb5f1d1660a3c9f4c996c5d04e701
         | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | Binary file | 
    
        data.tar.gz.sig
    CHANGED
    
    | Binary file | 
    
        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
    
    
    
        data/Rakefile
    CHANGED
    
    | @@ -1,5 +1,4 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            Bundler.setup
         | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 3 2 |  | 
| 4 3 | 
             
            require 'rake'
         | 
| 5 4 | 
             
            require 'rspec/core/rake_task'
         | 
| @@ -7,7 +6,7 @@ require 'yard' | |
| 7 6 | 
             
            require 'rubygems/package_task'
         | 
| 8 7 | 
             
            require 'rubocop/rake_task'
         | 
| 9 8 |  | 
| 10 | 
            -
            task default: [ | 
| 9 | 
            +
            task default: %i[spec rubocop]
         | 
| 11 10 |  | 
| 12 11 | 
             
            desc 'Run all rspec files'
         | 
| 13 12 | 
             
            RSpec::Core::RakeTask.new('spec') do |c|
         | 
| @@ -45,3 +44,11 @@ task :console do | |
| 45 44 | 
             
            end
         | 
| 46 45 |  | 
| 47 46 | 
             
            RuboCop::RakeTask.new
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            task :checksum do
         | 
| 49 | 
            +
              require 'digest/sha2'
         | 
| 50 | 
            +
              built_gem_path = "prawn-#{Prawn::VERSION}.gem"
         | 
| 51 | 
            +
              checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
         | 
| 52 | 
            +
              checksum_path = "checksums/#{built_gem_path}.sha512"
         | 
| 53 | 
            +
              File.write(checksum_path, checksum)
         | 
| 54 | 
            +
            end
         | 
    
        data/lib/prawn.rb
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            # Welcome to Prawn, the best PDF Generation library ever.
         | 
| 2 4 | 
             
            # This documentation covers user level functionality.
         | 
| 3 5 | 
             
            #
         | 
| @@ -28,11 +30,16 @@ module Prawn | |
| 28 30 | 
             
              #   Detected unknown option(s): [:tomato]
         | 
| 29 31 | 
             
              #   Accepted options are: [:page_size, :page_layout, :left_margin, ...]
         | 
| 30 32 | 
             
              #
         | 
| 31 | 
            -
               | 
| 33 | 
            +
              # @private
         | 
| 34 | 
            +
              attr_accessor :debug
         | 
| 32 35 | 
             
              module_function :debug, :debug=
         | 
| 33 36 |  | 
| 34 | 
            -
               | 
| 37 | 
            +
              module_function
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              # @private
         | 
| 40 | 
            +
              def verify_options(accepted, actual)
         | 
| 35 41 | 
             
                return unless debug || $DEBUG
         | 
| 42 | 
            +
             | 
| 36 43 | 
             
                unless (act = Set[*actual.keys]).subset?(acc = Set[*accepted])
         | 
| 37 44 | 
             
                  raise Prawn::Errors::UnknownOption,
         | 
| 38 45 | 
             
                    "\nDetected unknown option(s): #{(act - acc).to_a.inspect}\n" \
         | 
| @@ -40,7 +47,6 @@ module Prawn | |
| 40 47 | 
             
                end
         | 
| 41 48 | 
             
                yield if block_given?
         | 
| 42 49 | 
             
              end
         | 
| 43 | 
            -
              module_function :verify_options
         | 
| 44 50 | 
             
            end
         | 
| 45 51 |  | 
| 46 52 | 
             
            require_relative 'prawn/version'
         | 
    
        data/lib/prawn/document.rb
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            # document.rb : Implements PDF document generation for Prawn
         | 
| 2 4 | 
             
            #
         | 
| 3 5 | 
             
            # Copyright April 2008, Gregory Brown.  All Rights Reserved.
         | 
| @@ -62,11 +64,11 @@ module Prawn | |
| 62 64 | 
             
                # NOTE: We probably need to rethink the options validation system, but this
         | 
| 63 65 | 
             
                # constant temporarily allows for extensions to modify the list.
         | 
| 64 66 |  | 
| 65 | 
            -
                VALID_OPTIONS = [
         | 
| 66 | 
            -
                   | 
| 67 | 
            -
                   | 
| 68 | 
            -
                   | 
| 69 | 
            -
                   | 
| 67 | 
            +
                VALID_OPTIONS = %i[
         | 
| 68 | 
            +
                  page_size page_layout margin left_margin
         | 
| 69 | 
            +
                  right_margin top_margin bottom_margin skip_page_creation
         | 
| 70 | 
            +
                  compress background info
         | 
| 71 | 
            +
                  text_formatter print_scaling
         | 
| 70 72 | 
             
                ].freeze
         | 
| 71 73 |  | 
| 72 74 | 
             
                # Any module added to this array will be included into instances of
         | 
| @@ -269,7 +271,7 @@ module Prawn | |
| 269 271 |  | 
| 270 272 | 
             
                    # erase the color space so that it gets reset on new page for fussy
         | 
| 271 273 | 
             
                    # pdf-readers
         | 
| 272 | 
            -
                    new_graphic_state | 
| 274 | 
            +
                    new_graphic_state&.color_space = {}
         | 
| 273 275 |  | 
| 274 276 | 
             
                    page_options[:graphic_state] = new_graphic_state
         | 
| 275 277 | 
             
                  end
         | 
| @@ -304,6 +306,26 @@ module Prawn | |
| 304 306 | 
             
                  end
         | 
| 305 307 | 
             
                end
         | 
| 306 308 |  | 
| 309 | 
            +
                # Remove page of the document by index
         | 
| 310 | 
            +
                #
         | 
| 311 | 
            +
                #   pdf = Prawn::Document.new
         | 
| 312 | 
            +
                #   pdf.page_count #=> 1
         | 
| 313 | 
            +
                #   3.times { pdf.start_new_page }
         | 
| 314 | 
            +
                #   pdf.page_count #=> 4
         | 
| 315 | 
            +
                #   pdf.delete_page(-1)
         | 
| 316 | 
            +
                #   pdf.page_count #=> 3
         | 
| 317 | 
            +
                #
         | 
| 318 | 
            +
                def delete_page(index)
         | 
| 319 | 
            +
                  return false if index.abs > (state.pages.count - 1)
         | 
| 320 | 
            +
             | 
| 321 | 
            +
                  state.pages.delete_at(index)
         | 
| 322 | 
            +
             | 
| 323 | 
            +
                  state.store.pages.data[:Kids].delete_at(index)
         | 
| 324 | 
            +
                  state.store.pages.data[:Count] -= 1
         | 
| 325 | 
            +
                  @page_number -= 1
         | 
| 326 | 
            +
                  true
         | 
| 327 | 
            +
                end
         | 
| 328 | 
            +
             | 
| 307 329 | 
             
                # Returns the number of pages in the document
         | 
| 308 330 | 
             
                #
         | 
| 309 331 | 
             
                #   pdf = Prawn::Document.new
         | 
| @@ -320,9 +342,9 @@ module Prawn | |
| 320 342 | 
             
                #
         | 
| 321 343 | 
             
                # See Prawn::Document#number_pages for a sample usage of this capability.
         | 
| 322 344 | 
             
                #
         | 
| 323 | 
            -
                def go_to_page( | 
| 324 | 
            -
                  @page_number =  | 
| 325 | 
            -
                  state.page = state.pages[ | 
| 345 | 
            +
                def go_to_page(page_number)
         | 
| 346 | 
            +
                  @page_number = page_number
         | 
| 347 | 
            +
                  state.page = state.pages[page_number - 1]
         | 
| 326 348 | 
             
                  generate_margin_box
         | 
| 327 349 | 
             
                  @y = @bounding_box.absolute_top
         | 
| 328 350 | 
             
                end
         | 
| @@ -369,13 +391,13 @@ module Prawn | |
| 369 391 | 
             
                # Renders the PDF document to string.
         | 
| 370 392 | 
             
                # Pass an open file descriptor to render to file.
         | 
| 371 393 | 
             
                #
         | 
| 372 | 
            -
                def render(* | 
| 394 | 
            +
                def render(*arguments, &block)
         | 
| 373 395 | 
             
                  (1..page_count).each do |i|
         | 
| 374 396 | 
             
                    go_to_page i
         | 
| 375 397 | 
             
                    repeaters.each { |r| r.run(i) }
         | 
| 376 398 | 
             
                  end
         | 
| 377 399 |  | 
| 378 | 
            -
                  renderer.render(* | 
| 400 | 
            +
                  renderer.render(*arguments, &block)
         | 
| 379 401 | 
             
                end
         | 
| 380 402 |  | 
| 381 403 | 
             
                # Renders the PDF document to file.
         | 
| @@ -437,15 +459,15 @@ module Prawn | |
| 437 459 | 
             
                # Moves up the document by n points relative to the current position inside
         | 
| 438 460 | 
             
                # the current bounding box.
         | 
| 439 461 | 
             
                #
         | 
| 440 | 
            -
                def move_up( | 
| 441 | 
            -
                  self.y +=  | 
| 462 | 
            +
                def move_up(amount)
         | 
| 463 | 
            +
                  self.y += amount
         | 
| 442 464 | 
             
                end
         | 
| 443 465 |  | 
| 444 466 | 
             
                # Moves down the document by n points relative to the current position
         | 
| 445 467 | 
             
                # inside the current bounding box.
         | 
| 446 468 | 
             
                #
         | 
| 447 | 
            -
                def move_down( | 
| 448 | 
            -
                  self.y -=  | 
| 469 | 
            +
                def move_down(amount)
         | 
| 470 | 
            +
                  self.y -= amount
         | 
| 449 471 | 
             
                end
         | 
| 450 472 |  | 
| 451 473 | 
             
                # Moves down the document and then executes a block.
         | 
| @@ -597,7 +619,7 @@ module Prawn | |
| 597 619 | 
             
                # the current page or column.
         | 
| 598 620 | 
             
                #
         | 
| 599 621 | 
             
                # @private
         | 
| 600 | 
            -
                def group(* | 
| 622 | 
            +
                def group(*_arguments)
         | 
| 601 623 | 
             
                  raise NotImplementedError,
         | 
| 602 624 | 
             
                    'Document#group has been disabled because its implementation ' \
         | 
| 603 625 | 
             
                    'lead to corrupted documents whenever a page boundary was ' \
         | 
| @@ -706,11 +728,11 @@ module Prawn | |
| 706 728 |  | 
| 707 729 | 
             
                  # we must update bounding box if not flowing from the previous page
         | 
| 708 730 | 
             
                  #
         | 
| 709 | 
            -
                  @bounding_box = @margin_box unless @bounding_box | 
| 731 | 
            +
                  @bounding_box = @margin_box unless @bounding_box&.parent
         | 
| 710 732 | 
             
                end
         | 
| 711 733 |  | 
| 712 734 | 
             
                def apply_margin_options(options)
         | 
| 713 | 
            -
                  sides = [ | 
| 735 | 
            +
                  sides = %i[top right bottom left]
         | 
| 714 736 | 
             
                  margin = Array(options[:margin])
         | 
| 715 737 |  | 
| 716 738 | 
             
                  # Treat :margin as CSS shorthand with 1-4 values.
         | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            # bounding_box.rb : Implements a mechanism for shifting the coordinate space
         | 
| 2 4 | 
             
            #
         | 
| 3 5 | 
             
            # Copyright May 2008, Gregory Brown. All Rights Reserved.
         | 
| @@ -153,10 +155,10 @@ module Prawn | |
| 153 155 | 
             
                # Of course, if you use canvas, you will be responsible for ensuring that
         | 
| 154 156 | 
             
                # you remain within the printable area of your document.
         | 
| 155 157 | 
             
                #
         | 
| 156 | 
            -
                def bounding_box( | 
| 158 | 
            +
                def bounding_box(point, *args, &block)
         | 
| 157 159 | 
             
                  init_bounding_box(block) do |parent_box|
         | 
| 158 | 
            -
                     | 
| 159 | 
            -
                    @bounding_box = BoundingBox.new(self, parent_box,  | 
| 160 | 
            +
                    point = map_to_absolute(point)
         | 
| 161 | 
            +
                    @bounding_box = BoundingBox.new(self, parent_box, point, *args)
         | 
| 160 162 | 
             
                  end
         | 
| 161 163 | 
             
                end
         | 
| 162 164 |  | 
| @@ -219,7 +221,8 @@ module Prawn | |
| 219 221 | 
             
                # is used for.
         | 
| 220 222 | 
             
                #
         | 
| 221 223 | 
             
                class BoundingBox
         | 
| 222 | 
            -
                   | 
| 224 | 
            +
                  # @private
         | 
| 225 | 
            +
                  def initialize(document, parent, point, options = {})
         | 
| 223 226 | 
             
                    unless options[:width]
         | 
| 224 227 | 
             
                      raise ArgumentError, 'BoundingBox needs the :width option to be set'
         | 
| 225 228 | 
             
                    end
         | 
| @@ -457,6 +460,7 @@ module Prawn | |
| 457 460 | 
             
                  #
         | 
| 458 461 | 
             
                  def height
         | 
| 459 462 | 
             
                    return @height if @height
         | 
| 463 | 
            +
             | 
| 460 464 | 
             
                    @stretched_height = [
         | 
| 461 465 | 
             
                      (absolute_top - @document.y),
         | 
| 462 466 | 
             
                      @stretched_height.to_f
         | 
| @@ -501,6 +505,7 @@ module Prawn | |
| 501 505 | 
             
                  def reference_bounds
         | 
| 502 506 | 
             
                    if stretchy?
         | 
| 503 507 | 
             
                      raise "Can't find reference bounds: my parent is unset" unless @parent
         | 
| 508 | 
            +
             | 
| 504 509 | 
             
                      @parent.reference_bounds
         | 
| 505 510 | 
             
                    else
         | 
| 506 511 | 
             
                      self
         | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            # internals.rb : Implements document internals for Prawn
         | 
| 2 4 | 
             
            #
         | 
| 3 5 | 
             
            # Copyright August 2008, Gregory Brown. All Rights Reserved.
         | 
| @@ -21,9 +23,9 @@ module Prawn | |
| 21 23 | 
             
                  # but they are used in documentation and possibly in extensions.
         | 
| 22 24 | 
             
                  # Perhaps they will become part of the extension API?
         | 
| 23 25 | 
             
                  # Anyway, for now it's not clear what we should do w. them.
         | 
| 24 | 
            -
                  delegate [
         | 
| 25 | 
            -
                     | 
| 26 | 
            -
                     | 
| 26 | 
            +
                  delegate %i[
         | 
| 27 | 
            +
                    graphic_state
         | 
| 28 | 
            +
                    on_page_create
         | 
| 27 29 | 
             
                  ] => :renderer
         | 
| 28 30 |  | 
| 29 31 | 
             
                  def save_graphics_state(state = nil, &block)
         | 
| @@ -45,7 +47,7 @@ module Prawn | |
| 45 47 | 
             
                  delegate [:compression_enabled?] => :renderer
         | 
| 46 48 |  | 
| 47 49 | 
             
                  # FIXME: More circular references in PDF::Core::Page.
         | 
| 48 | 
            -
                  delegate [ | 
| 50 | 
            +
                  delegate %i[ref ref! deref] => :renderer
         | 
| 49 51 |  | 
| 50 52 | 
             
                  # FIXME: Another circular reference, because we mix in a module from
         | 
| 51 53 | 
             
                  # PDF::Core to provide destinations, which in theory should not
         | 
    
        data/lib/prawn/document/span.rb
    CHANGED
    
    
    
        data/lib/prawn/encoding.rb
    CHANGED
    
    | @@ -1,9 +1,12 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            # Copyright September 2008, Gregory Brown, James Healy  All Rights Reserved.
         | 
| 2 4 | 
             
            #
         | 
| 3 5 | 
             
            # This is free software. Please see the LICENSE and COPYING files for details.
         | 
| 4 6 | 
             
            #
         | 
| 5 7 | 
             
            module Prawn
         | 
| 6 | 
            -
               | 
| 8 | 
            +
              # @private
         | 
| 9 | 
            +
              module Encoding
         | 
| 7 10 | 
             
                # Map between unicode and WinAnsiEnoding
         | 
| 8 11 | 
             
                #
         | 
| 9 12 | 
             
                class WinAnsi #:nodoc:
         | 
    
        data/lib/prawn/errors.rb
    CHANGED
    
    
    
        data/lib/prawn/font.rb
    CHANGED
    
    | @@ -1,13 +1,11 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            # font.rb : The Prawn font class
         | 
| 2 4 | 
             
            #
         | 
| 3 5 | 
             
            # Copyright May 2008, Gregory Brown / James Healy. All Rights Reserved.
         | 
| 4 6 | 
             
            #
         | 
| 5 7 | 
             
            # This is free software. Please see the LICENSE and COPYING files for details.
         | 
| 6 8 | 
             
            #
         | 
| 7 | 
            -
            require_relative 'font/afm'
         | 
| 8 | 
            -
            require_relative 'font/ttf'
         | 
| 9 | 
            -
            require_relative 'font/dfont'
         | 
| 10 | 
            -
            require_relative 'font/ttc'
         | 
| 11 9 | 
             
            require_relative 'font_metric_cache'
         | 
| 12 10 |  | 
| 13 11 | 
             
            module Prawn
         | 
| @@ -35,7 +33,7 @@ module Prawn | |
| 35 33 | 
             
                #
         | 
| 36 34 | 
             
                # The :name parameter must be a string. It can be one of the 14 built-in
         | 
| 37 35 | 
             
                # fonts supported by PDF, or the location of a TTF file. The
         | 
| 38 | 
            -
                #  | 
| 36 | 
            +
                # Fonts::AFM::BUILT_INS array specifies the valid built in font values.
         | 
| 39 37 | 
             
                #
         | 
| 40 38 | 
             
                # If a ttf font is specified, the glyphs necessary to render your document
         | 
| 41 39 | 
             
                # will be embedded in the rendered PDF. This should be your preferred option
         | 
| @@ -96,6 +94,7 @@ module Prawn | |
| 96 94 | 
             
                #
         | 
| 97 95 | 
             
                def font_size(points = nil)
         | 
| 98 96 | 
             
                  return @font_size unless points
         | 
| 97 | 
            +
             | 
| 99 98 | 
             
                  size_before_yield = @font_size
         | 
| 100 99 | 
             
                  @font_size = points
         | 
| 101 100 | 
             
                  block_given? ? yield : return
         | 
| @@ -280,6 +279,18 @@ module Prawn | |
| 280 279 | 
             
              # Provides font information and helper functions.
         | 
| 281 280 | 
             
              #
         | 
| 282 281 | 
             
              class Font
         | 
| 282 | 
            +
                require_relative 'fonts/afm'
         | 
| 283 | 
            +
                require_relative 'fonts/ttf'
         | 
| 284 | 
            +
                require_relative 'fonts/dfont'
         | 
| 285 | 
            +
                require_relative 'fonts/otf'
         | 
| 286 | 
            +
                require_relative 'fonts/ttc'
         | 
| 287 | 
            +
             | 
| 288 | 
            +
                # @deprecated
         | 
| 289 | 
            +
                AFM = Fonts::AFM
         | 
| 290 | 
            +
                TTF = Fonts::TTF
         | 
| 291 | 
            +
                DFont = Fonts::DFont
         | 
| 292 | 
            +
                TTC = Fonts::TTC
         | 
| 293 | 
            +
             | 
| 283 294 | 
             
                # The current font name
         | 
| 284 295 | 
             
                attr_reader :name
         | 
| 285 296 |  | 
| @@ -290,14 +301,15 @@ module Prawn | |
| 290 301 | 
             
                attr_reader :options
         | 
| 291 302 |  | 
| 292 303 | 
             
                # Shortcut interface for constructing a font object.  Filenames of the form
         | 
| 293 | 
            -
                # *.ttf will call  | 
| 294 | 
            -
                #  | 
| 295 | 
            -
                #  | 
| 304 | 
            +
                # *.ttf will call Fonts::TTF.new, *.dfont Fonts::DFont.new, *.ttc goes to
         | 
| 305 | 
            +
                # Fonts::TTC.new, and anything else will be passed through to
         | 
| 306 | 
            +
                # Fonts::AFM.new()
         | 
| 296 307 | 
             
                def self.load(document, src, options = {})
         | 
| 297 308 | 
             
                  case font_format(src, options)
         | 
| 298 | 
            -
                  when 'ttf' | 
| 309 | 
            +
                  when 'ttf' then TTF.new(document, src, options)
         | 
| 310 | 
            +
                  when 'otf' then Fonts::OTF.new(document, src, options)
         | 
| 299 311 | 
             
                  when 'dfont' then DFont.new(document, src, options)
         | 
| 300 | 
            -
                  when 'ttc' | 
| 312 | 
            +
                  when 'ttc' then TTC.new(document, src, options)
         | 
| 301 313 | 
             
                  else AFM.new(document, src, options)
         | 
| 302 314 | 
             
                  end
         | 
| 303 315 | 
             
                end
         | 
| @@ -306,10 +318,11 @@ module Prawn | |
| 306 318 | 
             
                  return options.fetch(:format, 'ttf') if src.respond_to? :read
         | 
| 307 319 |  | 
| 308 320 | 
             
                  case src.to_s
         | 
| 309 | 
            -
                  when /\.ttf$/i   then  | 
| 310 | 
            -
                  when /\. | 
| 311 | 
            -
                  when /\. | 
| 312 | 
            -
                   | 
| 321 | 
            +
                  when /\.ttf$/i   then 'ttf'
         | 
| 322 | 
            +
                  when /\.otf$/i   then 'otf'
         | 
| 323 | 
            +
                  when /\.dfont$/i then 'dfont'
         | 
| 324 | 
            +
                  when /\.ttc$/i   then 'ttc'
         | 
| 325 | 
            +
                  else 'afm'
         | 
| 313 326 | 
             
                  end
         | 
| 314 327 | 
             
                end
         | 
| 315 328 |  | 
| @@ -355,8 +368,11 @@ module Prawn | |
| 355 368 | 
             
                # Destructive version of normalize_encoding; normalizes the encoding of a
         | 
| 356 369 | 
             
                # string in place.
         | 
| 357 370 | 
             
                #
         | 
| 371 | 
            +
                # @deprecated
         | 
| 358 372 | 
             
                def normalize_encoding!(str)
         | 
| 359 | 
            -
                   | 
| 373 | 
            +
                  warn 'Font#normalize_encoding! is deprecated. ' \
         | 
| 374 | 
            +
                    'Please use non-mutating version Font#normalize_encoding instead.'
         | 
| 375 | 
            +
                  str.dup.replace(normalize_encoding(str))
         | 
| 360 376 | 
             
                end
         | 
| 361 377 |  | 
| 362 378 | 
             
                # Gets height of current font in PDF points at the given font size
         | 
| @@ -384,7 +400,7 @@ module Prawn | |
| 384 400 | 
             
                end
         | 
| 385 401 |  | 
| 386 402 | 
             
                def identifier_for(subset) #:nodoc:
         | 
| 387 | 
            -
                  "#{@identifier}.#{subset}"
         | 
| 403 | 
            +
                  "#{@identifier}.#{subset}".to_sym
         | 
| 388 404 | 
             
                end
         | 
| 389 405 |  | 
| 390 406 | 
             
                def inspect #:nodoc:
         | 
| @@ -417,13 +433,14 @@ module Prawn | |
| 417 433 | 
             
                  loop do
         | 
| 418 434 | 
             
                    key = :"F#{font_count}"
         | 
| 419 435 | 
             
                    break if key_is_unique?(key)
         | 
| 436 | 
            +
             | 
| 420 437 | 
             
                    font_count += 1
         | 
| 421 438 | 
             
                  end
         | 
| 422 439 | 
             
                  key
         | 
| 423 440 | 
             
                end
         | 
| 424 441 |  | 
| 425 442 | 
             
                def key_is_unique?(test_key)
         | 
| 426 | 
            -
                   | 
| 443 | 
            +
                  @document.state.page.fonts.keys.none? do |key|
         | 
| 427 444 | 
             
                    key.to_s.start_with?("#{test_key}.")
         | 
| 428 445 | 
             
                  end
         | 
| 429 446 | 
             
                end
         |