hexapdf 0.6.0 → 0.7.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
- data/CHANGELOG.md +33 -0
- data/CONTRIBUTERS +1 -1
- data/LICENSE +1 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/hexapdf +1 -1
- data/examples/text_layouter_styling.rb +1 -2
- data/lib/hexapdf.rb +2 -2
- data/lib/hexapdf/cli.rb +3 -3
- data/lib/hexapdf/cli/batch.rb +5 -5
- data/lib/hexapdf/cli/command.rb +15 -17
- data/lib/hexapdf/cli/files.rb +3 -3
- data/lib/hexapdf/cli/images.rb +3 -4
- data/lib/hexapdf/cli/info.rb +5 -5
- data/lib/hexapdf/cli/inspect.rb +6 -6
- data/lib/hexapdf/cli/merge.rb +6 -6
- data/lib/hexapdf/cli/modify.rb +4 -4
- data/lib/hexapdf/cli/optimize.rb +3 -3
- data/lib/hexapdf/configuration.rb +4 -5
- data/lib/hexapdf/content.rb +2 -2
- data/lib/hexapdf/content/canvas.rb +35 -36
- data/lib/hexapdf/content/color_space.rb +9 -14
- data/lib/hexapdf/content/graphic_object.rb +2 -2
- data/lib/hexapdf/content/graphic_object/arc.rb +3 -3
- data/lib/hexapdf/content/graphic_object/endpoint_arc.rb +2 -2
- data/lib/hexapdf/content/graphic_object/solid_arc.rb +4 -8
- data/lib/hexapdf/content/graphics_state.rb +4 -13
- data/lib/hexapdf/content/operator.rb +33 -35
- data/lib/hexapdf/content/parser.rb +28 -18
- data/lib/hexapdf/content/processor.rb +4 -5
- data/lib/hexapdf/content/transformation_matrix.rb +2 -2
- data/lib/hexapdf/data_dir.rb +2 -2
- data/lib/hexapdf/dictionary.rb +8 -9
- data/lib/hexapdf/dictionary_fields.rb +7 -10
- data/lib/hexapdf/document.rb +18 -18
- data/lib/hexapdf/document/files.rb +12 -10
- data/lib/hexapdf/document/fonts.rb +2 -2
- data/lib/hexapdf/document/images.rb +3 -3
- data/lib/hexapdf/document/pages.rb +4 -4
- data/lib/hexapdf/encryption.rb +2 -2
- data/lib/hexapdf/encryption/aes.rb +2 -2
- data/lib/hexapdf/encryption/arc4.rb +4 -4
- data/lib/hexapdf/encryption/fast_aes.rb +2 -2
- data/lib/hexapdf/encryption/fast_arc4.rb +4 -4
- data/lib/hexapdf/encryption/identity.rb +5 -4
- data/lib/hexapdf/encryption/ruby_aes.rb +147 -139
- data/lib/hexapdf/encryption/ruby_arc4.rb +4 -4
- data/lib/hexapdf/encryption/security_handler.rb +11 -12
- data/lib/hexapdf/encryption/standard_security_handler.rb +6 -9
- data/lib/hexapdf/error.rb +7 -9
- data/lib/hexapdf/filter.rb +2 -3
- data/lib/hexapdf/filter/ascii85_decode.rb +3 -3
- data/lib/hexapdf/filter/ascii_hex_decode.rb +2 -2
- data/lib/hexapdf/filter/dct_decode.rb +2 -2
- data/lib/hexapdf/filter/encryption.rb +2 -2
- data/lib/hexapdf/filter/flate_decode.rb +16 -33
- data/lib/hexapdf/filter/jpx_decode.rb +2 -2
- data/lib/hexapdf/filter/lzw_decode.rb +4 -4
- data/lib/hexapdf/filter/predictor.rb +2 -6
- data/lib/hexapdf/filter/run_length_decode.rb +2 -2
- data/lib/hexapdf/font/cmap.rb +2 -3
- data/lib/hexapdf/font/cmap/parser.rb +11 -11
- data/lib/hexapdf/font/cmap/writer.rb +25 -25
- data/lib/hexapdf/font/encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/base.rb +2 -2
- data/lib/hexapdf/font/encoding/difference_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/glyph_list.rb +6 -6
- data/lib/hexapdf/font/encoding/mac_expert_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/mac_roman_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/standard_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/symbol_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/win_ansi_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/zapf_dingbats_encoding.rb +2 -2
- data/lib/hexapdf/font/invalid_glyph.rb +7 -7
- data/lib/hexapdf/font/true_type.rb +2 -2
- data/lib/hexapdf/font/true_type/builder.rb +13 -7
- data/lib/hexapdf/font/true_type/font.rb +2 -3
- data/lib/hexapdf/font/true_type/optimizer.rb +2 -2
- data/lib/hexapdf/font/true_type/subsetter.rb +4 -4
- data/lib/hexapdf/font/true_type/table.rb +3 -5
- data/lib/hexapdf/font/true_type/table/cmap.rb +2 -2
- data/lib/hexapdf/font/true_type/table/cmap_subtable.rb +9 -16
- data/lib/hexapdf/font/true_type/table/directory.rb +4 -4
- data/lib/hexapdf/font/true_type/table/glyf.rb +2 -2
- data/lib/hexapdf/font/true_type/table/head.rb +3 -2
- data/lib/hexapdf/font/true_type/table/hhea.rb +2 -2
- data/lib/hexapdf/font/true_type/table/hmtx.rb +2 -2
- data/lib/hexapdf/font/true_type/table/kern.rb +3 -3
- data/lib/hexapdf/font/true_type/table/loca.rb +3 -3
- data/lib/hexapdf/font/true_type/table/maxp.rb +2 -2
- data/lib/hexapdf/font/true_type/table/name.rb +3 -5
- data/lib/hexapdf/font/true_type/table/os2.rb +4 -3
- data/lib/hexapdf/font/true_type/table/post.rb +3 -7
- data/lib/hexapdf/font/true_type_wrapper.rb +20 -22
- data/lib/hexapdf/font/type1.rb +2 -2
- data/lib/hexapdf/font/type1/afm_parser.rb +7 -7
- data/lib/hexapdf/font/type1/character_metrics.rb +2 -2
- data/lib/hexapdf/font/type1/font.rb +3 -3
- data/lib/hexapdf/font/type1/font_metrics.rb +2 -4
- data/lib/hexapdf/font/type1/pfb_parser.rb +2 -2
- data/lib/hexapdf/font/type1_wrapper.rb +8 -9
- data/lib/hexapdf/font_loader.rb +2 -2
- data/lib/hexapdf/font_loader/from_configuration.rb +2 -2
- data/lib/hexapdf/font_loader/from_file.rb +2 -2
- data/lib/hexapdf/font_loader/standard14.rb +2 -2
- data/lib/hexapdf/image_loader.rb +2 -2
- data/lib/hexapdf/image_loader/jpeg.rb +6 -4
- data/lib/hexapdf/image_loader/pdf.rb +2 -2
- data/lib/hexapdf/image_loader/png.rb +6 -6
- data/lib/hexapdf/importer.rb +6 -4
- data/lib/hexapdf/layout.rb +2 -2
- data/lib/hexapdf/layout/box.rb +4 -4
- data/lib/hexapdf/layout/inline_box.rb +2 -2
- data/lib/hexapdf/layout/line.rb +6 -6
- data/lib/hexapdf/layout/numeric_refinements.rb +2 -2
- data/lib/hexapdf/layout/style.rb +17 -8
- data/lib/hexapdf/layout/text_fragment.rb +86 -48
- data/lib/hexapdf/layout/text_layouter.rb +40 -21
- data/lib/hexapdf/layout/text_shaper.rb +2 -2
- data/lib/hexapdf/name_tree_node.rb +2 -2
- data/lib/hexapdf/number_tree_node.rb +2 -2
- data/lib/hexapdf/object.rb +6 -8
- data/lib/hexapdf/parser.rb +10 -10
- data/lib/hexapdf/rectangle.rb +4 -4
- data/lib/hexapdf/reference.rb +2 -2
- data/lib/hexapdf/revision.rb +4 -4
- data/lib/hexapdf/revisions.rb +5 -5
- data/lib/hexapdf/serializer.rb +27 -24
- data/lib/hexapdf/stream.rb +4 -4
- data/lib/hexapdf/task.rb +2 -2
- data/lib/hexapdf/task/dereference.rb +4 -4
- data/lib/hexapdf/task/optimize.rb +5 -4
- data/lib/hexapdf/tokenizer.rb +12 -14
- data/lib/hexapdf/type.rb +2 -2
- data/lib/hexapdf/type/action.rb +3 -3
- data/lib/hexapdf/type/actions.rb +2 -2
- data/lib/hexapdf/type/actions/go_to.rb +2 -2
- data/lib/hexapdf/type/actions/go_to_r.rb +2 -2
- data/lib/hexapdf/type/actions/launch.rb +2 -2
- data/lib/hexapdf/type/actions/uri.rb +3 -3
- data/lib/hexapdf/type/annotation.rb +3 -3
- data/lib/hexapdf/type/annotations.rb +2 -2
- data/lib/hexapdf/type/annotations/link.rb +2 -2
- data/lib/hexapdf/type/annotations/markup_annotation.rb +2 -2
- data/lib/hexapdf/type/annotations/text.rb +2 -2
- data/lib/hexapdf/type/catalog.rb +4 -4
- data/lib/hexapdf/type/cid_font.rb +4 -5
- data/lib/hexapdf/type/embedded_file.rb +3 -3
- data/lib/hexapdf/type/file_specification.rb +6 -7
- data/lib/hexapdf/type/font.rb +4 -4
- data/lib/hexapdf/type/font_descriptor.rb +3 -4
- data/lib/hexapdf/type/font_simple.rb +12 -16
- data/lib/hexapdf/type/font_true_type.rb +2 -2
- data/lib/hexapdf/type/font_type0.rb +5 -5
- data/lib/hexapdf/type/font_type1.rb +4 -4
- data/lib/hexapdf/type/form.rb +3 -3
- data/lib/hexapdf/type/graphics_state_parameter.rb +3 -3
- data/lib/hexapdf/type/image.rb +13 -14
- data/lib/hexapdf/type/info.rb +2 -2
- data/lib/hexapdf/type/names.rb +2 -2
- data/lib/hexapdf/type/object_stream.rb +5 -5
- data/lib/hexapdf/type/page.rb +9 -10
- data/lib/hexapdf/type/page_tree_node.rb +5 -6
- data/lib/hexapdf/type/resources.rb +11 -11
- data/lib/hexapdf/type/trailer.rb +3 -3
- data/lib/hexapdf/type/viewer_preferences.rb +2 -2
- data/lib/hexapdf/type/xref_stream.rb +8 -4
- data/lib/hexapdf/utils/bit_field.rb +4 -4
- data/lib/hexapdf/utils/bit_stream.rb +4 -4
- data/lib/hexapdf/utils/graphics_helpers.rb +2 -2
- data/lib/hexapdf/utils/lru_cache.rb +2 -2
- data/lib/hexapdf/utils/math_helpers.rb +2 -2
- data/lib/hexapdf/utils/object_hash.rb +3 -3
- data/lib/hexapdf/utils/pdf_doc_encoding.rb +3 -3
- data/lib/hexapdf/utils/sorted_tree_node.rb +12 -11
- data/lib/hexapdf/version.rb +3 -3
- data/lib/hexapdf/writer.rb +8 -8
- data/lib/hexapdf/xref_section.rb +3 -3
- data/test/hexapdf/common_tokenizer_tests.rb +6 -7
- data/test/hexapdf/content/graphic_object/test_endpoint_arc.rb +0 -1
- data/test/hexapdf/content/test_canvas.rb +28 -36
- data/test/hexapdf/content/test_color_space.rb +4 -0
- data/test/hexapdf/content/test_graphics_state.rb +2 -0
- data/test/hexapdf/content/test_operator.rb +6 -7
- data/test/hexapdf/content/test_parser.rb +2 -2
- data/test/hexapdf/content/test_processor.rb +1 -1
- data/test/hexapdf/document/test_files.rb +1 -0
- data/test/hexapdf/document/test_images.rb +1 -1
- data/test/hexapdf/encryption/common.rb +3 -3
- data/test/hexapdf/encryption/test_aes.rb +10 -4
- data/test/hexapdf/encryption/test_identity.rb +1 -1
- data/test/hexapdf/encryption/test_security_handler.rb +13 -17
- data/test/hexapdf/encryption/test_standard_security_handler.rb +12 -12
- data/test/hexapdf/filter/test_ascii85_decode.rb +2 -3
- data/test/hexapdf/filter/test_ascii_hex_decode.rb +6 -1
- data/test/hexapdf/filter/test_flate_decode.rb +2 -2
- data/test/hexapdf/filter/test_lzw_decode.rb +10 -10
- data/test/hexapdf/filter/test_predictor.rb +10 -2
- data/test/hexapdf/filter/test_run_length_decode.rb +1 -1
- data/test/hexapdf/font/cmap/test_parser.rb +40 -40
- data/test/hexapdf/font/cmap/test_writer.rb +29 -29
- data/test/hexapdf/font/test_true_type_wrapper.rb +3 -2
- data/test/hexapdf/font/true_type/common.rb +2 -0
- data/test/hexapdf/font/true_type/table/test_cmap.rb +1 -1
- data/test/hexapdf/font/true_type/table/test_cmap_subtable.rb +5 -4
- data/test/hexapdf/font/true_type/table/test_glyf.rb +2 -2
- data/test/hexapdf/font/true_type/table/test_head.rb +2 -2
- data/test/hexapdf/font/true_type/table/test_name.rb +9 -6
- data/test/hexapdf/font/true_type/test_builder.rb +8 -3
- data/test/hexapdf/font/true_type/test_optimizer.rb +1 -2
- data/test/hexapdf/font/type1/test_afm_parser.rb +2 -2
- data/test/hexapdf/image_loader/test_jpeg.rb +1 -1
- data/test/hexapdf/image_loader/test_pdf.rb +1 -1
- data/test/hexapdf/image_loader/test_png.rb +3 -3
- data/test/hexapdf/layout/test_inline_box.rb +10 -1
- data/test/hexapdf/layout/test_line.rb +4 -4
- data/test/hexapdf/layout/test_style.rb +19 -7
- data/test/hexapdf/layout/test_text_fragment.rb +73 -27
- data/test/hexapdf/layout/test_text_layouter.rb +84 -68
- data/test/hexapdf/layout/test_text_shaper.rb +4 -6
- data/test/hexapdf/task/test_dereference.rb +2 -2
- data/test/hexapdf/task/test_optimize.rb +16 -7
- data/test/hexapdf/test_configuration.rb +1 -1
- data/test/hexapdf/test_data_dir.rb +2 -2
- data/test/hexapdf/test_dictionary.rb +6 -3
- data/test/hexapdf/test_dictionary_fields.rb +15 -14
- data/test/hexapdf/test_document.rb +47 -48
- data/test/hexapdf/test_filter.rb +30 -26
- data/test/hexapdf/test_importer.rb +14 -0
- data/test/hexapdf/test_object.rb +16 -4
- data/test/hexapdf/test_parser.rb +36 -36
- data/test/hexapdf/test_reference.rb +7 -5
- data/test/hexapdf/test_revision.rb +1 -1
- data/test/hexapdf/test_revisions.rb +90 -90
- data/test/hexapdf/test_serializer.rb +3 -2
- data/test/hexapdf/test_stream.rb +2 -4
- data/test/hexapdf/test_tokenizer.rb +2 -2
- data/test/hexapdf/test_writer.rb +80 -80
- data/test/hexapdf/test_xref_section.rb +1 -1
- data/test/hexapdf/type/annotations/test_link.rb +1 -1
- data/test/hexapdf/type/annotations/test_text.rb +3 -3
- data/test/hexapdf/type/test_font_descriptor.rb +1 -1
- data/test/hexapdf/type/test_font_simple.rb +2 -2
- data/test/hexapdf/type/test_font_type0.rb +0 -1
- data/test/hexapdf/type/test_image.rb +0 -3
- data/test/hexapdf/type/test_object_stream.rb +2 -1
- data/test/hexapdf/type/test_page.rb +5 -1
- data/test/hexapdf/type/test_page_tree_node.rb +4 -4
- data/test/hexapdf/type/test_trailer.rb +1 -1
- data/test/hexapdf/type/test_xref_stream.rb +4 -0
- data/test/hexapdf/utils/test_bit_field.rb +2 -0
- data/test/hexapdf/utils/test_bit_stream.rb +1 -1
- data/test/hexapdf/utils/test_lru_cache.rb +1 -1
- data/test/hexapdf/utils/test_sorted_tree_node.rb +10 -4
- data/test/test_helper.rb +3 -6
- metadata +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
data/lib/hexapdf/font/cmap.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -82,7 +82,6 @@ module HexaPDF
|
|
|
82
82
|
Writer.new.create_to_unicode_cmap(mapping)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
|
|
86
85
|
# The registry part of the CMap version.
|
|
87
86
|
attr_accessor :registry
|
|
88
87
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -49,20 +49,20 @@ module HexaPDF
|
|
|
49
49
|
tokenizer = HexaPDF::Content::Tokenizer.new(string)
|
|
50
50
|
cmap = CMap.new
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
until (token = tokenizer.next_token) == HexaPDF::Tokenizer::NO_MORE_TOKENS
|
|
53
53
|
if token.kind_of?(HexaPDF::Tokenizer::Token)
|
|
54
54
|
case token
|
|
55
|
-
when 'beginbfchar'
|
|
56
|
-
when 'beginbfrange'
|
|
57
|
-
when 'begincidchar'
|
|
58
|
-
when 'begincidrange'
|
|
59
|
-
when 'begincodespacerange'
|
|
55
|
+
when 'beginbfchar' then parse_bf_char(tokenizer, cmap)
|
|
56
|
+
when 'beginbfrange' then parse_bf_range(tokenizer, cmap)
|
|
57
|
+
when 'begincidchar' then parse_cid_char(tokenizer, cmap)
|
|
58
|
+
when 'begincidrange' then parse_cid_range(tokenizer, cmap)
|
|
59
|
+
when 'begincodespacerange' then parse_codespace_range(tokenizer, cmap)
|
|
60
60
|
when 'endcmap' then break
|
|
61
61
|
end
|
|
62
62
|
elsif token.kind_of?(Symbol)
|
|
63
63
|
value = tokenizer.next_token
|
|
64
64
|
if value.kind_of?(HexaPDF::Tokenizer::Token)
|
|
65
|
-
parse_cmap(cmap, token) if value == 'usecmap'
|
|
65
|
+
parse_cmap(cmap, token) if value == 'usecmap'
|
|
66
66
|
else
|
|
67
67
|
parse_dict_mapping(cmap, token, value)
|
|
68
68
|
end
|
|
@@ -70,7 +70,7 @@ module HexaPDF
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
cmap
|
|
73
|
-
rescue => e
|
|
73
|
+
rescue StandardError => e
|
|
74
74
|
raise HexaPDF::Error, "Error parsing CMap: #{e.message}", e.backtrace
|
|
75
75
|
end
|
|
76
76
|
|
|
@@ -162,7 +162,7 @@ module HexaPDF
|
|
|
162
162
|
if dest.kind_of?(String)
|
|
163
163
|
codepoint = dest.force_encoding(::Encoding::UTF_16BE).ord
|
|
164
164
|
code1.upto(code2) do |code|
|
|
165
|
-
cmap.add_unicode_mapping(code, '' << codepoint)
|
|
165
|
+
cmap.add_unicode_mapping(code, +'' << codepoint)
|
|
166
166
|
codepoint += 1
|
|
167
167
|
end
|
|
168
168
|
elsif dest.kind_of?(Array)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -57,14 +57,14 @@ module HexaPDF
|
|
|
57
57
|
result = create_sections("bfchar", chars.size / 2) do |index|
|
|
58
58
|
index *= 2
|
|
59
59
|
sprintf("<%04X>", chars[index]) << "<" <<
|
|
60
|
-
(''.force_encoding(::Encoding::UTF_16BE) << chars[index + 1]).unpack('H*').first <<
|
|
60
|
+
((+'').force_encoding(::Encoding::UTF_16BE) << chars[index + 1]).unpack('H*').first <<
|
|
61
61
|
">\n"
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
result << create_sections("bfrange", ranges.size / 3) do |index|
|
|
65
65
|
index *= 3
|
|
66
66
|
sprintf("<%04X><%04X>", ranges[index], ranges[index + 1]) << "<" <<
|
|
67
|
-
(''.force_encoding(::Encoding::UTF_16BE) << ranges[index + 2]).unpack('H*').first <<
|
|
67
|
+
((+'').force_encoding(::Encoding::UTF_16BE) << ranges[index + 2]).unpack('H*').first <<
|
|
68
68
|
">\n"
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -129,12 +129,12 @@ module HexaPDF
|
|
|
129
129
|
def create_sections(type, size)
|
|
130
130
|
return '' if size == 0
|
|
131
131
|
|
|
132
|
-
result = ""
|
|
132
|
+
result = +""
|
|
133
133
|
index = 0
|
|
134
134
|
while size > 0
|
|
135
135
|
count = [MAX_ENTRIES_IN_SECTION, size].min
|
|
136
136
|
result << "#{count} begin#{type}\n"
|
|
137
|
-
index.upto(index + count - 1) {|i| result << yield(i)}
|
|
137
|
+
index.upto(index + count - 1) {|i| result << yield(i) }
|
|
138
138
|
result << "end#{type}\n"
|
|
139
139
|
index += count
|
|
140
140
|
size -= count
|
|
@@ -145,25 +145,25 @@ module HexaPDF
|
|
|
145
145
|
|
|
146
146
|
# Returns the CMap file template for a ToUnicode CMap.
|
|
147
147
|
def to_unicode_template
|
|
148
|
-
|
|
149
|
-
/CIDInit /ProcSet findresource begin
|
|
150
|
-
12 dict begin
|
|
151
|
-
begincmap
|
|
152
|
-
/CIDSystemInfo
|
|
153
|
-
<< /Registry (Adobe)
|
|
154
|
-
/Ordering (UCS)
|
|
155
|
-
/Supplement 0
|
|
156
|
-
>> def
|
|
157
|
-
/CMapName /Adobe-Identity-UCS def
|
|
158
|
-
/CMapType 2 def
|
|
159
|
-
1 begincodespacerange
|
|
160
|
-
<0000> <FFFF>
|
|
161
|
-
endcodespacerange
|
|
162
|
-
%s
|
|
163
|
-
endcmap
|
|
164
|
-
CMapName currentdict /CMap defineresource pop
|
|
165
|
-
end
|
|
166
|
-
end
|
|
148
|
+
<<~TEMPLATE
|
|
149
|
+
/CIDInit /ProcSet findresource begin
|
|
150
|
+
12 dict begin
|
|
151
|
+
begincmap
|
|
152
|
+
/CIDSystemInfo
|
|
153
|
+
<< /Registry (Adobe)
|
|
154
|
+
/Ordering (UCS)
|
|
155
|
+
/Supplement 0
|
|
156
|
+
>> def
|
|
157
|
+
/CMapName /Adobe-Identity-UCS def
|
|
158
|
+
/CMapType 2 def
|
|
159
|
+
1 begincodespacerange
|
|
160
|
+
<0000> <FFFF>
|
|
161
|
+
endcodespacerange
|
|
162
|
+
%s
|
|
163
|
+
endcmap
|
|
164
|
+
CMapName currentdict /CMap defineresource pop
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
167
|
TEMPLATE
|
|
168
168
|
end
|
|
169
169
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -87,7 +87,7 @@ module HexaPDF
|
|
|
87
87
|
else
|
|
88
88
|
name = name.to_s
|
|
89
89
|
if name =~ /\Auni([0-9A-F]{4})\Z/ || name =~ /\Au([0-9A-f]{4,6})\Z/
|
|
90
|
-
'' << $1.hex
|
|
90
|
+
+'' << $1.hex
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|
|
@@ -130,10 +130,10 @@ module HexaPDF
|
|
|
130
130
|
uni2name = {}
|
|
131
131
|
File.open(file, 'rb') do |f|
|
|
132
132
|
while (line = f.gets)
|
|
133
|
-
next if line.start_with?('#'
|
|
134
|
-
index = line.index(';'
|
|
133
|
+
next if line.start_with?('#')
|
|
134
|
+
index = line.index(';')
|
|
135
135
|
name = line[0, index].to_sym
|
|
136
|
-
codes = line[index + 1, 50].split(" "
|
|
136
|
+
codes = line[index + 1, 50].split(" ").map(&:hex).pack('U*')
|
|
137
137
|
name2uni[name] = codes
|
|
138
138
|
uni2name[codes] = name unless uni2name.key?(codes)
|
|
139
139
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -51,16 +51,16 @@ module HexaPDF
|
|
|
51
51
|
def id
|
|
52
52
|
@font.missing_glyph_id
|
|
53
53
|
end
|
|
54
|
-
|
|
54
|
+
alias name id
|
|
55
55
|
|
|
56
56
|
# Returns 0.
|
|
57
57
|
def x_min
|
|
58
58
|
0
|
|
59
59
|
end
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
alias x_max x_min
|
|
61
|
+
alias y_min x_min
|
|
62
|
+
alias y_max x_min
|
|
63
|
+
alias width x_min
|
|
64
64
|
|
|
65
65
|
# Word spacing is never applied for the invalid glyph, so +false+ is returned.
|
|
66
66
|
def apply_word_spacing?
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -51,19 +51,25 @@ module HexaPDF
|
|
|
51
51
|
offset = font_data.length + tables.length * 16
|
|
52
52
|
checksum = Table.calculate_checksum(font_data)
|
|
53
53
|
|
|
54
|
-
#
|
|
55
|
-
tables['head']
|
|
54
|
+
# Prepare head table for checksumming
|
|
55
|
+
head_table = tables['head']
|
|
56
|
+
head_table[8, 4] = "\0\0\0\0"
|
|
57
|
+
|
|
58
|
+
# The directory table needs to be sorted in ascending order by tag
|
|
59
|
+
tables = tables.sort
|
|
56
60
|
|
|
57
61
|
tables.each do |tag, data|
|
|
62
|
+
original_data_length = data.length
|
|
58
63
|
table_checksum = Table.calculate_checksum(data)
|
|
64
|
+
data << "\0" * (4 - original_data_length % 4) if original_data_length % 4 != 0
|
|
59
65
|
# tag, offset, data.length are all 32bit uint, table_checksum for header and body
|
|
60
66
|
checksum += tag.unpack('N').first + 2 * table_checksum + offset + data.length
|
|
61
|
-
font_data << [tag, table_checksum, offset,
|
|
67
|
+
font_data << [tag, table_checksum, offset, original_data_length].pack('a4N3')
|
|
62
68
|
offset += data.length
|
|
63
69
|
end
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
tables.
|
|
71
|
+
head_table[8, 4] = [0xB1B0AFBA - checksum].pack('N')
|
|
72
|
+
tables.each {|_, data| font_data << data }
|
|
67
73
|
|
|
68
74
|
font_data
|
|
69
75
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2018 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -66,7 +66,6 @@ module HexaPDF
|
|
|
66
66
|
'font.true_type.unknown_format' => :ignore,
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
70
69
|
# The IO stream associated with this file.
|
|
71
70
|
attr_reader :io
|
|
72
71
|
|