hexapdf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTERS +3 -0
- data/LICENSE +26 -0
- data/README.md +88 -0
- data/Rakefile +121 -0
- data/VERSION +1 -0
- data/agpl-3.0.txt +661 -0
- data/bin/hexapdf +6 -0
- data/data/hexapdf/afm/Courier-Bold.afm +342 -0
- data/data/hexapdf/afm/Courier-BoldOblique.afm +342 -0
- data/data/hexapdf/afm/Courier-Oblique.afm +342 -0
- data/data/hexapdf/afm/Courier.afm +342 -0
- data/data/hexapdf/afm/Helvetica-Bold.afm +2827 -0
- data/data/hexapdf/afm/Helvetica-BoldOblique.afm +2827 -0
- data/data/hexapdf/afm/Helvetica-Oblique.afm +3051 -0
- data/data/hexapdf/afm/Helvetica.afm +3051 -0
- data/data/hexapdf/afm/MustRead.html +1 -0
- data/data/hexapdf/afm/Symbol.afm +213 -0
- data/data/hexapdf/afm/Times-Bold.afm +2588 -0
- data/data/hexapdf/afm/Times-BoldItalic.afm +2384 -0
- data/data/hexapdf/afm/Times-Italic.afm +2667 -0
- data/data/hexapdf/afm/Times-Roman.afm +2419 -0
- data/data/hexapdf/afm/ZapfDingbats.afm +225 -0
- data/data/hexapdf/encoding/glyphlist.txt +4305 -0
- data/data/hexapdf/encoding/zapfdingbats.txt +225 -0
- data/examples/arc.rb +50 -0
- data/examples/graphics.rb +274 -0
- data/examples/hello_world.rb +16 -0
- data/examples/machupicchu.jpg +0 -0
- data/examples/merging.rb +24 -0
- data/examples/optimizing.rb +20 -0
- data/examples/show_char_bboxes.rb +55 -0
- data/examples/standard_pdf_fonts.rb +72 -0
- data/examples/truetype.rb +45 -0
- data/lib/hexapdf/cli/extract.rb +128 -0
- data/lib/hexapdf/cli/info.rb +121 -0
- data/lib/hexapdf/cli/inspect.rb +157 -0
- data/lib/hexapdf/cli/modify.rb +218 -0
- data/lib/hexapdf/cli.rb +121 -0
- data/lib/hexapdf/configuration.rb +392 -0
- data/lib/hexapdf/content/canvas.rb +1974 -0
- data/lib/hexapdf/content/color_space.rb +364 -0
- data/lib/hexapdf/content/graphic_object/arc.rb +267 -0
- data/lib/hexapdf/content/graphic_object/endpoint_arc.rb +208 -0
- data/lib/hexapdf/content/graphic_object/solid_arc.rb +173 -0
- data/lib/hexapdf/content/graphic_object.rb +81 -0
- data/lib/hexapdf/content/graphics_state.rb +579 -0
- data/lib/hexapdf/content/operator.rb +1072 -0
- data/lib/hexapdf/content/parser.rb +204 -0
- data/lib/hexapdf/content/processor.rb +451 -0
- data/lib/hexapdf/content/transformation_matrix.rb +172 -0
- data/lib/hexapdf/content.rb +47 -0
- data/lib/hexapdf/data_dir.rb +51 -0
- data/lib/hexapdf/dictionary.rb +303 -0
- data/lib/hexapdf/dictionary_fields.rb +382 -0
- data/lib/hexapdf/document.rb +589 -0
- data/lib/hexapdf/document_utils.rb +209 -0
- data/lib/hexapdf/encryption/aes.rb +206 -0
- data/lib/hexapdf/encryption/arc4.rb +93 -0
- data/lib/hexapdf/encryption/fast_aes.rb +79 -0
- data/lib/hexapdf/encryption/fast_arc4.rb +67 -0
- data/lib/hexapdf/encryption/identity.rb +63 -0
- data/lib/hexapdf/encryption/ruby_aes.rb +447 -0
- data/lib/hexapdf/encryption/ruby_arc4.rb +96 -0
- data/lib/hexapdf/encryption/security_handler.rb +494 -0
- data/lib/hexapdf/encryption/standard_security_handler.rb +616 -0
- data/lib/hexapdf/encryption.rb +94 -0
- data/lib/hexapdf/error.rb +73 -0
- data/lib/hexapdf/filter/ascii85_decode.rb +160 -0
- data/lib/hexapdf/filter/ascii_hex_decode.rb +87 -0
- data/lib/hexapdf/filter/dct_decode.rb +57 -0
- data/lib/hexapdf/filter/encryption.rb +59 -0
- data/lib/hexapdf/filter/flate_decode.rb +93 -0
- data/lib/hexapdf/filter/jpx_decode.rb +56 -0
- data/lib/hexapdf/filter/lzw_decode.rb +191 -0
- data/lib/hexapdf/filter/predictor.rb +266 -0
- data/lib/hexapdf/filter/run_length_decode.rb +108 -0
- data/lib/hexapdf/filter.rb +176 -0
- data/lib/hexapdf/font/cmap/parser.rb +146 -0
- data/lib/hexapdf/font/cmap/writer.rb +176 -0
- data/lib/hexapdf/font/cmap.rb +90 -0
- data/lib/hexapdf/font/encoding/base.rb +77 -0
- data/lib/hexapdf/font/encoding/difference_encoding.rb +64 -0
- data/lib/hexapdf/font/encoding/glyph_list.rb +150 -0
- data/lib/hexapdf/font/encoding/mac_expert_encoding.rb +221 -0
- data/lib/hexapdf/font/encoding/mac_roman_encoding.rb +265 -0
- data/lib/hexapdf/font/encoding/standard_encoding.rb +205 -0
- data/lib/hexapdf/font/encoding/symbol_encoding.rb +244 -0
- data/lib/hexapdf/font/encoding/win_ansi_encoding.rb +280 -0
- data/lib/hexapdf/font/encoding/zapf_dingbats_encoding.rb +250 -0
- data/lib/hexapdf/font/encoding.rb +68 -0
- data/lib/hexapdf/font/true_type/font.rb +179 -0
- data/lib/hexapdf/font/true_type/table/cmap.rb +103 -0
- data/lib/hexapdf/font/true_type/table/cmap_subtable.rb +384 -0
- data/lib/hexapdf/font/true_type/table/directory.rb +92 -0
- data/lib/hexapdf/font/true_type/table/glyf.rb +166 -0
- data/lib/hexapdf/font/true_type/table/head.rb +143 -0
- data/lib/hexapdf/font/true_type/table/hhea.rb +109 -0
- data/lib/hexapdf/font/true_type/table/hmtx.rb +79 -0
- data/lib/hexapdf/font/true_type/table/loca.rb +79 -0
- data/lib/hexapdf/font/true_type/table/maxp.rb +112 -0
- data/lib/hexapdf/font/true_type/table/name.rb +218 -0
- data/lib/hexapdf/font/true_type/table/os2.rb +200 -0
- data/lib/hexapdf/font/true_type/table/post.rb +230 -0
- data/lib/hexapdf/font/true_type/table.rb +155 -0
- data/lib/hexapdf/font/true_type.rb +48 -0
- data/lib/hexapdf/font/true_type_wrapper.rb +240 -0
- data/lib/hexapdf/font/type1/afm_parser.rb +230 -0
- data/lib/hexapdf/font/type1/character_metrics.rb +67 -0
- data/lib/hexapdf/font/type1/font.rb +123 -0
- data/lib/hexapdf/font/type1/font_metrics.rb +117 -0
- data/lib/hexapdf/font/type1/pfb_parser.rb +71 -0
- data/lib/hexapdf/font/type1.rb +52 -0
- data/lib/hexapdf/font/type1_wrapper.rb +193 -0
- data/lib/hexapdf/font_loader/from_configuration.rb +70 -0
- data/lib/hexapdf/font_loader/standard14.rb +98 -0
- data/lib/hexapdf/font_loader.rb +85 -0
- data/lib/hexapdf/font_utils.rb +89 -0
- data/lib/hexapdf/image_loader/jpeg.rb +166 -0
- data/lib/hexapdf/image_loader/pdf.rb +89 -0
- data/lib/hexapdf/image_loader/png.rb +410 -0
- data/lib/hexapdf/image_loader.rb +68 -0
- data/lib/hexapdf/importer.rb +139 -0
- data/lib/hexapdf/name_tree_node.rb +78 -0
- data/lib/hexapdf/number_tree_node.rb +67 -0
- data/lib/hexapdf/object.rb +363 -0
- data/lib/hexapdf/parser.rb +349 -0
- data/lib/hexapdf/rectangle.rb +99 -0
- data/lib/hexapdf/reference.rb +98 -0
- data/lib/hexapdf/revision.rb +206 -0
- data/lib/hexapdf/revisions.rb +194 -0
- data/lib/hexapdf/serializer.rb +326 -0
- data/lib/hexapdf/stream.rb +279 -0
- data/lib/hexapdf/task/dereference.rb +109 -0
- data/lib/hexapdf/task/optimize.rb +230 -0
- data/lib/hexapdf/task.rb +68 -0
- data/lib/hexapdf/tokenizer.rb +406 -0
- data/lib/hexapdf/type/catalog.rb +107 -0
- data/lib/hexapdf/type/embedded_file.rb +87 -0
- data/lib/hexapdf/type/file_specification.rb +232 -0
- data/lib/hexapdf/type/font.rb +81 -0
- data/lib/hexapdf/type/font_descriptor.rb +109 -0
- data/lib/hexapdf/type/font_simple.rb +190 -0
- data/lib/hexapdf/type/font_true_type.rb +47 -0
- data/lib/hexapdf/type/font_type1.rb +162 -0
- data/lib/hexapdf/type/form.rb +103 -0
- data/lib/hexapdf/type/graphics_state_parameter.rb +79 -0
- data/lib/hexapdf/type/image.rb +73 -0
- data/lib/hexapdf/type/info.rb +70 -0
- data/lib/hexapdf/type/names.rb +69 -0
- data/lib/hexapdf/type/object_stream.rb +224 -0
- data/lib/hexapdf/type/page.rb +355 -0
- data/lib/hexapdf/type/page_tree_node.rb +269 -0
- data/lib/hexapdf/type/resources.rb +212 -0
- data/lib/hexapdf/type/trailer.rb +128 -0
- data/lib/hexapdf/type/viewer_preferences.rb +73 -0
- data/lib/hexapdf/type/xref_stream.rb +204 -0
- data/lib/hexapdf/type.rb +67 -0
- data/lib/hexapdf/utils/bit_field.rb +87 -0
- data/lib/hexapdf/utils/bit_stream.rb +148 -0
- data/lib/hexapdf/utils/lru_cache.rb +65 -0
- data/lib/hexapdf/utils/math_helpers.rb +55 -0
- data/lib/hexapdf/utils/object_hash.rb +130 -0
- data/lib/hexapdf/utils/pdf_doc_encoding.rb +93 -0
- data/lib/hexapdf/utils/sorted_tree_node.rb +339 -0
- data/lib/hexapdf/version.rb +39 -0
- data/lib/hexapdf/writer.rb +199 -0
- data/lib/hexapdf/xref_section.rb +152 -0
- data/lib/hexapdf.rb +34 -0
- data/man/man1/hexapdf.1 +249 -0
- data/test/data/aes-test-vectors/CBCGFSbox-128-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-128-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-192-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-192-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-256-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-256-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-128-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-128-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-192-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-192-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-256-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-256-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-128-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-128-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-192-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-192-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-256-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-256-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-128-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-128-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-192-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-192-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-256-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-256-encrypt.data.gz +0 -0
- data/test/data/fonts/Ubuntu-Title.ttf +0 -0
- data/test/data/images/cmyk.jpg +0 -0
- data/test/data/images/fillbytes.jpg +0 -0
- data/test/data/images/gray.jpg +0 -0
- data/test/data/images/greyscale-1bit.png +0 -0
- data/test/data/images/greyscale-2bit.png +0 -0
- data/test/data/images/greyscale-4bit.png +0 -0
- data/test/data/images/greyscale-8bit.png +0 -0
- data/test/data/images/greyscale-alpha-8bit.png +0 -0
- data/test/data/images/greyscale-trns-8bit.png +0 -0
- data/test/data/images/greyscale-with-gamma1.0.png +0 -0
- data/test/data/images/greyscale-with-gamma1.5.png +0 -0
- data/test/data/images/indexed-1bit.png +0 -0
- data/test/data/images/indexed-2bit.png +0 -0
- data/test/data/images/indexed-4bit.png +0 -0
- data/test/data/images/indexed-8bit.png +0 -0
- data/test/data/images/indexed-alpha-4bit.png +0 -0
- data/test/data/images/indexed-alpha-8bit.png +0 -0
- data/test/data/images/rgb.jpg +0 -0
- data/test/data/images/truecolour-8bit.png +0 -0
- data/test/data/images/truecolour-alpha-8bit.png +0 -0
- data/test/data/images/truecolour-gama-chrm-8bit.png +0 -0
- data/test/data/images/truecolour-srgb-8bit.png +0 -0
- data/test/data/minimal.pdf +44 -0
- data/test/data/standard-security-handler/README +9 -0
- data/test/data/standard-security-handler/bothpwd-aes-128bit-V4.pdf +44 -0
- data/test/data/standard-security-handler/bothpwd-aes-256bit-V5.pdf +0 -0
- data/test/data/standard-security-handler/bothpwd-arc4-128bit-V2.pdf +43 -0
- data/test/data/standard-security-handler/bothpwd-arc4-128bit-V4.pdf +43 -0
- data/test/data/standard-security-handler/bothpwd-arc4-40bit-V1.pdf +0 -0
- data/test/data/standard-security-handler/nopwd-aes-128bit-V4.pdf +43 -0
- data/test/data/standard-security-handler/nopwd-aes-256bit-V5.pdf +0 -0
- data/test/data/standard-security-handler/nopwd-arc4-128bit-V2.pdf +43 -0
- data/test/data/standard-security-handler/nopwd-arc4-128bit-V4.pdf +43 -0
- data/test/data/standard-security-handler/nopwd-arc4-40bit-V1.pdf +43 -0
- data/test/data/standard-security-handler/ownerpwd-aes-128bit-V4.pdf +0 -0
- data/test/data/standard-security-handler/ownerpwd-aes-256bit-V5.pdf +43 -0
- data/test/data/standard-security-handler/ownerpwd-arc4-128bit-V2.pdf +43 -0
- data/test/data/standard-security-handler/ownerpwd-arc4-128bit-V4.pdf +43 -0
- data/test/data/standard-security-handler/ownerpwd-arc4-40bit-V1.pdf +43 -0
- data/test/data/standard-security-handler/userpwd-aes-128bit-V4.pdf +43 -0
- data/test/data/standard-security-handler/userpwd-aes-256bit-V5.pdf +43 -0
- data/test/data/standard-security-handler/userpwd-arc4-128bit-V2.pdf +0 -0
- data/test/data/standard-security-handler/userpwd-arc4-128bit-V4.pdf +0 -0
- data/test/data/standard-security-handler/userpwd-arc4-40bit-V1.pdf +43 -0
- data/test/hexapdf/common_tokenizer_tests.rb +204 -0
- data/test/hexapdf/content/common.rb +31 -0
- data/test/hexapdf/content/graphic_object/test_arc.rb +93 -0
- data/test/hexapdf/content/graphic_object/test_endpoint_arc.rb +91 -0
- data/test/hexapdf/content/graphic_object/test_solid_arc.rb +86 -0
- data/test/hexapdf/content/test_canvas.rb +1113 -0
- data/test/hexapdf/content/test_color_space.rb +97 -0
- data/test/hexapdf/content/test_graphics_state.rb +138 -0
- data/test/hexapdf/content/test_operator.rb +619 -0
- data/test/hexapdf/content/test_parser.rb +66 -0
- data/test/hexapdf/content/test_processor.rb +156 -0
- data/test/hexapdf/content/test_transformation_matrix.rb +64 -0
- data/test/hexapdf/encryption/common.rb +87 -0
- data/test/hexapdf/encryption/test_aes.rb +121 -0
- data/test/hexapdf/encryption/test_arc4.rb +39 -0
- data/test/hexapdf/encryption/test_fast_aes.rb +17 -0
- data/test/hexapdf/encryption/test_fast_arc4.rb +12 -0
- data/test/hexapdf/encryption/test_identity.rb +21 -0
- data/test/hexapdf/encryption/test_ruby_aes.rb +23 -0
- data/test/hexapdf/encryption/test_ruby_arc4.rb +20 -0
- data/test/hexapdf/encryption/test_security_handler.rb +356 -0
- data/test/hexapdf/encryption/test_standard_security_handler.rb +274 -0
- data/test/hexapdf/filter/common.rb +53 -0
- data/test/hexapdf/filter/test_ascii85_decode.rb +60 -0
- data/test/hexapdf/filter/test_ascii_hex_decode.rb +33 -0
- data/test/hexapdf/filter/test_encryption.rb +24 -0
- data/test/hexapdf/filter/test_flate_decode.rb +35 -0
- data/test/hexapdf/filter/test_lzw_decode.rb +52 -0
- data/test/hexapdf/filter/test_predictor.rb +183 -0
- data/test/hexapdf/filter/test_run_length_decode.rb +32 -0
- data/test/hexapdf/font/cmap/test_parser.rb +67 -0
- data/test/hexapdf/font/cmap/test_writer.rb +58 -0
- data/test/hexapdf/font/encoding/test_base.rb +35 -0
- data/test/hexapdf/font/encoding/test_difference_encoding.rb +21 -0
- data/test/hexapdf/font/encoding/test_glyph_list.rb +59 -0
- data/test/hexapdf/font/encoding/test_zapf_dingbats_encoding.rb +16 -0
- data/test/hexapdf/font/test_encoding.rb +27 -0
- data/test/hexapdf/font/test_true_type_wrapper.rb +110 -0
- data/test/hexapdf/font/test_type1_wrapper.rb +66 -0
- data/test/hexapdf/font/true_type/common.rb +19 -0
- data/test/hexapdf/font/true_type/table/test_cmap.rb +59 -0
- data/test/hexapdf/font/true_type/table/test_cmap_subtable.rb +133 -0
- data/test/hexapdf/font/true_type/table/test_directory.rb +35 -0
- data/test/hexapdf/font/true_type/table/test_glyf.rb +58 -0
- data/test/hexapdf/font/true_type/table/test_head.rb +76 -0
- data/test/hexapdf/font/true_type/table/test_hhea.rb +40 -0
- data/test/hexapdf/font/true_type/table/test_hmtx.rb +38 -0
- data/test/hexapdf/font/true_type/table/test_loca.rb +43 -0
- data/test/hexapdf/font/true_type/table/test_maxp.rb +62 -0
- data/test/hexapdf/font/true_type/table/test_name.rb +95 -0
- data/test/hexapdf/font/true_type/table/test_os2.rb +65 -0
- data/test/hexapdf/font/true_type/table/test_post.rb +89 -0
- data/test/hexapdf/font/true_type/test_font.rb +120 -0
- data/test/hexapdf/font/true_type/test_table.rb +41 -0
- data/test/hexapdf/font/type1/test_afm_parser.rb +51 -0
- data/test/hexapdf/font/type1/test_font.rb +68 -0
- data/test/hexapdf/font/type1/test_pfb_parser.rb +37 -0
- data/test/hexapdf/font_loader/test_from_configuration.rb +28 -0
- data/test/hexapdf/font_loader/test_standard14.rb +22 -0
- data/test/hexapdf/image_loader/test_jpeg.rb +83 -0
- data/test/hexapdf/image_loader/test_pdf.rb +47 -0
- data/test/hexapdf/image_loader/test_png.rb +258 -0
- data/test/hexapdf/task/test_dereference.rb +46 -0
- data/test/hexapdf/task/test_optimize.rb +137 -0
- data/test/hexapdf/test_configuration.rb +82 -0
- data/test/hexapdf/test_data_dir.rb +32 -0
- data/test/hexapdf/test_dictionary.rb +284 -0
- data/test/hexapdf/test_dictionary_fields.rb +185 -0
- data/test/hexapdf/test_document.rb +574 -0
- data/test/hexapdf/test_document_utils.rb +144 -0
- data/test/hexapdf/test_filter.rb +96 -0
- data/test/hexapdf/test_font_utils.rb +47 -0
- data/test/hexapdf/test_importer.rb +78 -0
- data/test/hexapdf/test_object.rb +177 -0
- data/test/hexapdf/test_parser.rb +394 -0
- data/test/hexapdf/test_rectangle.rb +36 -0
- data/test/hexapdf/test_reference.rb +41 -0
- data/test/hexapdf/test_revision.rb +139 -0
- data/test/hexapdf/test_revisions.rb +93 -0
- data/test/hexapdf/test_serializer.rb +169 -0
- data/test/hexapdf/test_stream.rb +262 -0
- data/test/hexapdf/test_tokenizer.rb +30 -0
- data/test/hexapdf/test_writer.rb +120 -0
- data/test/hexapdf/test_xref_section.rb +35 -0
- data/test/hexapdf/type/test_catalog.rb +30 -0
- data/test/hexapdf/type/test_embedded_file.rb +16 -0
- data/test/hexapdf/type/test_file_specification.rb +148 -0
- data/test/hexapdf/type/test_font.rb +35 -0
- data/test/hexapdf/type/test_font_descriptor.rb +51 -0
- data/test/hexapdf/type/test_font_simple.rb +190 -0
- data/test/hexapdf/type/test_font_type1.rb +128 -0
- data/test/hexapdf/type/test_form.rb +60 -0
- data/test/hexapdf/type/test_info.rb +14 -0
- data/test/hexapdf/type/test_names.rb +9 -0
- data/test/hexapdf/type/test_object_stream.rb +84 -0
- data/test/hexapdf/type/test_page.rb +260 -0
- data/test/hexapdf/type/test_page_tree_node.rb +255 -0
- data/test/hexapdf/type/test_resources.rb +167 -0
- data/test/hexapdf/type/test_trailer.rb +109 -0
- data/test/hexapdf/type/test_xref_stream.rb +131 -0
- data/test/hexapdf/utils/test_bit_field.rb +47 -0
- data/test/hexapdf/utils/test_lru_cache.rb +22 -0
- data/test/hexapdf/utils/test_object_hash.rb +115 -0
- data/test/hexapdf/utils/test_pdf_doc_encoding.rb +18 -0
- data/test/hexapdf/utils/test_sorted_tree_node.rb +232 -0
- data/test/test_helper.rb +56 -0
- metadata +427 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# This file is part of HexaPDF.
|
5
|
+
#
|
6
|
+
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
7
|
+
# Copyright (C) 2016 Thomas Leitner
|
8
|
+
#
|
9
|
+
# HexaPDF is free software: you can redistribute it and/or modify it
|
10
|
+
# under the terms of the GNU Affero General Public License version 3 as
|
11
|
+
# published by the Free Software Foundation with the addition of the
|
12
|
+
# following permission added to Section 15 as permitted in Section 7(a):
|
13
|
+
# FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
14
|
+
# THOMAS LEITNER, THOMAS LEITNER DISCLAIMS THE WARRANTY OF NON
|
15
|
+
# INFRINGEMENT OF THIRD PARTY RIGHTS.
|
16
|
+
#
|
17
|
+
# HexaPDF is distributed in the hope that it will be useful, but WITHOUT
|
18
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
20
|
+
# License for more details.
|
21
|
+
#
|
22
|
+
# You should have received a copy of the GNU Affero General Public License
|
23
|
+
# along with HexaPDF. If not, see <http://www.gnu.org/licenses/>.
|
24
|
+
#
|
25
|
+
# The interactive user interfaces in modified source and object code
|
26
|
+
# versions of HexaPDF must display Appropriate Legal Notices, as required
|
27
|
+
# under Section 5 of the GNU Affero General Public License version 3.
|
28
|
+
#
|
29
|
+
# In accordance with Section 7(b) of the GNU Affero General Public
|
30
|
+
# License, a covered work must retain the producer line in every PDF that
|
31
|
+
# is created or manipulated using HexaPDF.
|
32
|
+
#++
|
33
|
+
|
34
|
+
require 'hexapdf/font/encoding/base'
|
35
|
+
|
36
|
+
module HexaPDF
|
37
|
+
module Font
|
38
|
+
module Encoding
|
39
|
+
|
40
|
+
# The difference encoding uses a base encoding that can be overlayed with additional mappings.
|
41
|
+
#
|
42
|
+
# See: PDF1.7 s9.6.6.1
|
43
|
+
class DifferenceEncoding < Base
|
44
|
+
|
45
|
+
# The base encoding.
|
46
|
+
attr_reader :base_encoding
|
47
|
+
|
48
|
+
# Initializes the Differences object with the given base encoding object.
|
49
|
+
def initialize(base_encoding)
|
50
|
+
super()
|
51
|
+
@base_encoding = base_encoding
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns the name for the given code, either from this object, if it contains the code, or
|
55
|
+
# from the base encoding.
|
56
|
+
def name(code)
|
57
|
+
code_to_name[code] || base_encoding.name(code)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# This file is part of HexaPDF.
|
5
|
+
#
|
6
|
+
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
7
|
+
# Copyright (C) 2016 Thomas Leitner
|
8
|
+
#
|
9
|
+
# HexaPDF is free software: you can redistribute it and/or modify it
|
10
|
+
# under the terms of the GNU Affero General Public License version 3 as
|
11
|
+
# published by the Free Software Foundation with the addition of the
|
12
|
+
# following permission added to Section 15 as permitted in Section 7(a):
|
13
|
+
# FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
14
|
+
# THOMAS LEITNER, THOMAS LEITNER DISCLAIMS THE WARRANTY OF NON
|
15
|
+
# INFRINGEMENT OF THIRD PARTY RIGHTS.
|
16
|
+
#
|
17
|
+
# HexaPDF is distributed in the hope that it will be useful, but WITHOUT
|
18
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
20
|
+
# License for more details.
|
21
|
+
#
|
22
|
+
# You should have received a copy of the GNU Affero General Public License
|
23
|
+
# along with HexaPDF. If not, see <http://www.gnu.org/licenses/>.
|
24
|
+
#
|
25
|
+
# The interactive user interfaces in modified source and object code
|
26
|
+
# versions of HexaPDF must display Appropriate Legal Notices, as required
|
27
|
+
# under Section 5 of the GNU Affero General Public License version 3.
|
28
|
+
#
|
29
|
+
# In accordance with Section 7(b) of the GNU Affero General Public
|
30
|
+
# License, a covered work must retain the producer line in every PDF that
|
31
|
+
# is created or manipulated using HexaPDF.
|
32
|
+
#++
|
33
|
+
|
34
|
+
require 'hexapdf/data_dir'
|
35
|
+
|
36
|
+
module HexaPDF
|
37
|
+
module Font
|
38
|
+
module Encoding
|
39
|
+
|
40
|
+
# Provides access to and mapping functionality for the Adobe Glyph List.
|
41
|
+
#
|
42
|
+
# The Adobe Glyph List is used for mapping glyph names to Unicode values. The mapping itself
|
43
|
+
# is not a one-to-one mapping because some glyphs are mapped to the same Unicode sequence,
|
44
|
+
# e.g. the glyph name for 'A' and the glyph name for 'small capital A'.
|
45
|
+
#
|
46
|
+
# Since a reverse mapping is needed for converting UTF-8 strings to glyph names when encoding
|
47
|
+
# text, this (not unique) reverse mapping is also available. However, only the first occurence
|
48
|
+
# of a particular Unicode string is reverse-mapped.
|
49
|
+
#
|
50
|
+
# See:
|
51
|
+
# * https://github.com/adobe-type-tools/agl-aglfn
|
52
|
+
# * https://github.com/adobe-type-tools/agl-specification
|
53
|
+
class GlyphList
|
54
|
+
|
55
|
+
# Creates and returns the single GlyphList instance.
|
56
|
+
def self.new
|
57
|
+
@instance ||= super
|
58
|
+
end
|
59
|
+
|
60
|
+
# See #name_to_unicode
|
61
|
+
def self.name_to_unicode(name, zapf_dingbats: false)
|
62
|
+
new.name_to_unicode(name, zapf_dingbats: zapf_dingbats)
|
63
|
+
end
|
64
|
+
|
65
|
+
# See #unicode_to_name
|
66
|
+
def self.unicode_to_name(unicode, zapf_dingbats: false)
|
67
|
+
new.unicode_to_name(unicode, zapf_dingbats: zapf_dingbats)
|
68
|
+
end
|
69
|
+
|
70
|
+
def initialize #:nodoc:
|
71
|
+
load
|
72
|
+
end
|
73
|
+
|
74
|
+
# Maps the given name to a string by following the Adobe Glyph Specification. An empty
|
75
|
+
# string is returned if the name has no correct mapping.
|
76
|
+
#
|
77
|
+
# If this method is invoked when dealing with the ZapfDingbats font, the +zapf_dingbats+
|
78
|
+
# option needs to be set to +true+.
|
79
|
+
#
|
80
|
+
# Assumes that the name is a Symbol and that it includes just one component (no
|
81
|
+
# underscores)!
|
82
|
+
def name_to_unicode(name, zapf_dingbats: false)
|
83
|
+
if zapf_dingbats && @zapf_name_to_uni.key?(name)
|
84
|
+
@zapf_name_to_uni[name]
|
85
|
+
elsif @standard_name_to_uni.key?(name)
|
86
|
+
@standard_name_to_uni[name]
|
87
|
+
else
|
88
|
+
name = name.to_s
|
89
|
+
if name =~ /\Auni([0-9A-F]{4})\Z/ || name =~ /\Au([0-9A-f]{4,6})\Z/
|
90
|
+
'' << $1.hex
|
91
|
+
else
|
92
|
+
''
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Maps the given Unicode codepoint/string to a name in the Adobe Glyph List, or to .notdef
|
98
|
+
# if there is no mapping.
|
99
|
+
#
|
100
|
+
# If this method is invoked when dealing with the ZapfDingbats font, the +zapf_dingbats+
|
101
|
+
# option needs to be set to +true+.
|
102
|
+
def unicode_to_name(unicode, zapf_dingbats: false)
|
103
|
+
if zapf_dingbats
|
104
|
+
@zapf_uni_to_name.fetch(unicode, :'.notdef')
|
105
|
+
else
|
106
|
+
@standard_uni_to_name.fetch(unicode, :'.notdef')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
# Loads the needed Adobe Glyph List files.
|
113
|
+
def load
|
114
|
+
@standard_name_to_uni, @standard_uni_to_name =
|
115
|
+
load_file(File.join(HexaPDF.data_dir, 'encoding', 'glyphlist.txt'))
|
116
|
+
@zapf_name_to_uni, @zapf_uni_to_name =
|
117
|
+
load_file(File.join(HexaPDF.data_dir, 'encoding', 'zapfdingbats.txt'))
|
118
|
+
end
|
119
|
+
|
120
|
+
# Loads an Adobe Glyph List from the specified file and returns the name-to-unicode and
|
121
|
+
# unicode-to-name mappings.
|
122
|
+
#
|
123
|
+
# Regarding the mappings:
|
124
|
+
#
|
125
|
+
# * The name-to-unicode mapping maps a name (Symbol) to an UTF-8 string consisting of one or
|
126
|
+
# more characters.
|
127
|
+
#
|
128
|
+
# * The unicode-to-name mapping is *not* unique! It only uses the first occurence of a
|
129
|
+
# Unicode sequence.
|
130
|
+
def load_file(file)
|
131
|
+
name2uni = {}
|
132
|
+
uni2name = {}
|
133
|
+
File.open(file, 'rb') do |f|
|
134
|
+
while (line = f.gets)
|
135
|
+
next if line.start_with?('#'.freeze)
|
136
|
+
index = line.index(';'.freeze)
|
137
|
+
name = line[0, index].to_sym
|
138
|
+
codes = line[index + 1, 50].split(" ".freeze).map(&:hex).pack('U*'.freeze)
|
139
|
+
name2uni[name] = codes
|
140
|
+
uni2name[codes] = name unless uni2name.key?(codes)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
[name2uni.freeze, uni2name.freeze]
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# This file is part of HexaPDF.
|
5
|
+
#
|
6
|
+
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
7
|
+
# Copyright (C) 2016 Thomas Leitner
|
8
|
+
#
|
9
|
+
# HexaPDF is free software: you can redistribute it and/or modify it
|
10
|
+
# under the terms of the GNU Affero General Public License version 3 as
|
11
|
+
# published by the Free Software Foundation with the addition of the
|
12
|
+
# following permission added to Section 15 as permitted in Section 7(a):
|
13
|
+
# FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
14
|
+
# THOMAS LEITNER, THOMAS LEITNER DISCLAIMS THE WARRANTY OF NON
|
15
|
+
# INFRINGEMENT OF THIRD PARTY RIGHTS.
|
16
|
+
#
|
17
|
+
# HexaPDF is distributed in the hope that it will be useful, but WITHOUT
|
18
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
20
|
+
# License for more details.
|
21
|
+
#
|
22
|
+
# You should have received a copy of the GNU Affero General Public License
|
23
|
+
# along with HexaPDF. If not, see <http://www.gnu.org/licenses/>.
|
24
|
+
#
|
25
|
+
# The interactive user interfaces in modified source and object code
|
26
|
+
# versions of HexaPDF must display Appropriate Legal Notices, as required
|
27
|
+
# under Section 5 of the GNU Affero General Public License version 3.
|
28
|
+
#
|
29
|
+
# In accordance with Section 7(b) of the GNU Affero General Public
|
30
|
+
# License, a covered work must retain the producer line in every PDF that
|
31
|
+
# is created or manipulated using HexaPDF.
|
32
|
+
#++
|
33
|
+
|
34
|
+
require 'hexapdf/font/encoding/base'
|
35
|
+
|
36
|
+
module HexaPDF
|
37
|
+
module Font
|
38
|
+
module Encoding
|
39
|
+
|
40
|
+
# The MacExpertEncoding for Latin texts.
|
41
|
+
#
|
42
|
+
# See: PDF1.7 sD.4
|
43
|
+
class MacExpertEncoding < Base
|
44
|
+
|
45
|
+
def initialize #:nodoc:
|
46
|
+
super
|
47
|
+
@encoding_name = :MacExpertEncoding
|
48
|
+
@code_to_name = {
|
49
|
+
0276 => :AEsmall,
|
50
|
+
0207 => :Aacutesmall,
|
51
|
+
0211 => :Acircumflexsmall,
|
52
|
+
0047 => :Acutesmall,
|
53
|
+
0212 => :Adieresissmall,
|
54
|
+
0210 => :Agravesmall,
|
55
|
+
0214 => :Aringsmall,
|
56
|
+
0141 => :Asmall,
|
57
|
+
0213 => :Atildesmall,
|
58
|
+
0363 => :Brevesmall,
|
59
|
+
0142 => :Bsmall,
|
60
|
+
0256 => :Caronsmall,
|
61
|
+
0215 => :Ccedillasmall,
|
62
|
+
0311 => :Cedillasmall,
|
63
|
+
0136 => :Circumflexsmall,
|
64
|
+
0143 => :Csmall,
|
65
|
+
0254 => :Dieresissmall,
|
66
|
+
0372 => :Dotaccentsmall,
|
67
|
+
0144 => :Dsmall,
|
68
|
+
0216 => :Eacutesmall,
|
69
|
+
0220 => :Ecircumflexsmall,
|
70
|
+
0221 => :Edieresissmall,
|
71
|
+
0217 => :Egravesmall,
|
72
|
+
0145 => :Esmall,
|
73
|
+
0104 => :Ethsmall,
|
74
|
+
0146 => :Fsmall,
|
75
|
+
0140 => :Gravesmall,
|
76
|
+
0147 => :Gsmall,
|
77
|
+
0150 => :Hsmall,
|
78
|
+
0042 => :Hungarumlautsmall,
|
79
|
+
0222 => :Iacutesmall,
|
80
|
+
0224 => :Icircumflexsmall,
|
81
|
+
0225 => :Idieresissmall,
|
82
|
+
0223 => :Igravesmall,
|
83
|
+
0151 => :Ismall,
|
84
|
+
0152 => :Jsmall,
|
85
|
+
0153 => :Ksmall,
|
86
|
+
0302 => :Lslashsmall,
|
87
|
+
0154 => :Lsmall,
|
88
|
+
0364 => :Macronsmall,
|
89
|
+
0155 => :Msmall,
|
90
|
+
0156 => :Nsmall,
|
91
|
+
0226 => :Ntildesmall,
|
92
|
+
0317 => :OEsmall,
|
93
|
+
0227 => :Oacutesmall,
|
94
|
+
0231 => :Ocircumflexsmall,
|
95
|
+
0232 => :Odieresissmall,
|
96
|
+
0362 => :Ogoneksmall,
|
97
|
+
0230 => :Ogravesmall,
|
98
|
+
0277 => :Oslashsmall,
|
99
|
+
0157 => :Osmall,
|
100
|
+
0233 => :Otildesmall,
|
101
|
+
0160 => :Psmall,
|
102
|
+
0161 => :Qsmall,
|
103
|
+
0373 => :Ringsmall,
|
104
|
+
0162 => :Rsmall,
|
105
|
+
0247 => :Scaronsmall,
|
106
|
+
0163 => :Ssmall,
|
107
|
+
0271 => :Thornsmall,
|
108
|
+
0176 => :Tildesmall,
|
109
|
+
0164 => :Tsmall,
|
110
|
+
0234 => :Uacutesmall,
|
111
|
+
0236 => :Ucircumflexsmall,
|
112
|
+
0237 => :Udieresissmall,
|
113
|
+
0235 => :Ugravesmall,
|
114
|
+
0165 => :Usmall,
|
115
|
+
0166 => :Vsmall,
|
116
|
+
0167 => :Wsmall,
|
117
|
+
0170 => :Xsmall,
|
118
|
+
0264 => :Yacutesmall,
|
119
|
+
0330 => :Ydieresissmall,
|
120
|
+
0171 => :Ysmall,
|
121
|
+
0275 => :Zcaronsmall,
|
122
|
+
0172 => :Zsmall,
|
123
|
+
0046 => :ampersandsmall,
|
124
|
+
0201 => :asuperior,
|
125
|
+
0365 => :bsuperior,
|
126
|
+
0251 => :centinferior,
|
127
|
+
0043 => :centoldstyle,
|
128
|
+
0202 => :centsuperior,
|
129
|
+
0072 => :colon,
|
130
|
+
0173 => :colonmonetary,
|
131
|
+
0054 => :comma,
|
132
|
+
0262 => :commainferior,
|
133
|
+
0370 => :commasuperior,
|
134
|
+
0266 => :dollarinferior,
|
135
|
+
0044 => :dollaroldstyle,
|
136
|
+
0045 => :dollarsuperior,
|
137
|
+
0353 => :dsuperior,
|
138
|
+
0245 => :eightinferior,
|
139
|
+
0070 => :eightoldstyle,
|
140
|
+
0241 => :eightsuperior,
|
141
|
+
0344 => :esuperior,
|
142
|
+
0326 => :exclamdownsmall,
|
143
|
+
0041 => :exclamsmall,
|
144
|
+
0126 => :ff,
|
145
|
+
0131 => :ffi,
|
146
|
+
0132 => :ffl,
|
147
|
+
0127 => :fi,
|
148
|
+
0320 => :figuredash,
|
149
|
+
0114 => :fiveeighths,
|
150
|
+
0260 => :fiveinferior,
|
151
|
+
0065 => :fiveoldstyle,
|
152
|
+
0336 => :fivesuperior,
|
153
|
+
0130 => :fl,
|
154
|
+
0242 => :fourinferior,
|
155
|
+
0064 => :fouroldstyle,
|
156
|
+
0335 => :foursuperior,
|
157
|
+
0057 => :fraction,
|
158
|
+
0055 => :hyphen,
|
159
|
+
0137 => :hypheninferior,
|
160
|
+
0321 => :hyphensuperior,
|
161
|
+
0351 => :isuperior,
|
162
|
+
0361 => :lsuperior,
|
163
|
+
0367 => :msuperior,
|
164
|
+
0273 => :nineinferior,
|
165
|
+
0071 => :nineoldstyle,
|
166
|
+
0341 => :ninesuperior,
|
167
|
+
0366 => :nsuperior,
|
168
|
+
0053 => :onedotenleader,
|
169
|
+
0112 => :oneeighth,
|
170
|
+
0174 => :onefitted,
|
171
|
+
0110 => :onehalf,
|
172
|
+
0301 => :oneinferior,
|
173
|
+
0061 => :oneoldstyle,
|
174
|
+
0107 => :onequarter,
|
175
|
+
0332 => :onesuperior,
|
176
|
+
0116 => :onethird,
|
177
|
+
0257 => :osuperior,
|
178
|
+
0133 => :parenleftinferior,
|
179
|
+
0050 => :parenleftsuperior,
|
180
|
+
0135 => :parenrightinferior,
|
181
|
+
0051 => :parenrightsuperior,
|
182
|
+
0056 => :period,
|
183
|
+
0263 => :periodinferior,
|
184
|
+
0371 => :periodsuperior,
|
185
|
+
0300 => :questiondownsmall,
|
186
|
+
0077 => :questionsmall,
|
187
|
+
0345 => :rsuperior,
|
188
|
+
0175 => :rupiah,
|
189
|
+
0073 => :semicolon,
|
190
|
+
0115 => :seveneighths,
|
191
|
+
0246 => :seveninferior,
|
192
|
+
0067 => :sevenoldstyle,
|
193
|
+
0340 => :sevensuperior,
|
194
|
+
0244 => :sixinferior,
|
195
|
+
0066 => :sixoldstyle,
|
196
|
+
0337 => :sixsuperior,
|
197
|
+
0040 => :space,
|
198
|
+
0352 => :ssuperior,
|
199
|
+
0113 => :threeeighths,
|
200
|
+
0243 => :threeinferior,
|
201
|
+
0063 => :threeoldstyle,
|
202
|
+
0111 => :threequarters,
|
203
|
+
0075 => :threequartersemdash,
|
204
|
+
0334 => :threesuperior,
|
205
|
+
0346 => :tsuperior,
|
206
|
+
0052 => :twodotenleader,
|
207
|
+
0252 => :twoinferior,
|
208
|
+
0062 => :twooldstyle,
|
209
|
+
0333 => :twosuperior,
|
210
|
+
0117 => :twothirds,
|
211
|
+
0274 => :zeroinferior,
|
212
|
+
0060 => :zerooldstyle,
|
213
|
+
0342 => :zerosuperior,
|
214
|
+
}
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
@@ -0,0 +1,265 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# This file is part of HexaPDF.
|
5
|
+
#
|
6
|
+
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
7
|
+
# Copyright (C) 2016 Thomas Leitner
|
8
|
+
#
|
9
|
+
# HexaPDF is free software: you can redistribute it and/or modify it
|
10
|
+
# under the terms of the GNU Affero General Public License version 3 as
|
11
|
+
# published by the Free Software Foundation with the addition of the
|
12
|
+
# following permission added to Section 15 as permitted in Section 7(a):
|
13
|
+
# FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
14
|
+
# THOMAS LEITNER, THOMAS LEITNER DISCLAIMS THE WARRANTY OF NON
|
15
|
+
# INFRINGEMENT OF THIRD PARTY RIGHTS.
|
16
|
+
#
|
17
|
+
# HexaPDF is distributed in the hope that it will be useful, but WITHOUT
|
18
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
20
|
+
# License for more details.
|
21
|
+
#
|
22
|
+
# You should have received a copy of the GNU Affero General Public License
|
23
|
+
# along with HexaPDF. If not, see <http://www.gnu.org/licenses/>.
|
24
|
+
#
|
25
|
+
# The interactive user interfaces in modified source and object code
|
26
|
+
# versions of HexaPDF must display Appropriate Legal Notices, as required
|
27
|
+
# under Section 5 of the GNU Affero General Public License version 3.
|
28
|
+
#
|
29
|
+
# In accordance with Section 7(b) of the GNU Affero General Public
|
30
|
+
# License, a covered work must retain the producer line in every PDF that
|
31
|
+
# is created or manipulated using HexaPDF.
|
32
|
+
#++
|
33
|
+
|
34
|
+
require 'hexapdf/font/encoding/base'
|
35
|
+
|
36
|
+
module HexaPDF
|
37
|
+
module Font
|
38
|
+
module Encoding
|
39
|
+
|
40
|
+
# The Mac Roman standard encoding for Latin texts.
|
41
|
+
#
|
42
|
+
# See: PDF1.7 sD.1, sD.2
|
43
|
+
class MacRomanEncoding < Base
|
44
|
+
|
45
|
+
def initialize #:nodoc:
|
46
|
+
super
|
47
|
+
@encoding_name = :MacRomanEncoding
|
48
|
+
@code_to_name = {
|
49
|
+
0101 => :A,
|
50
|
+
0256 => :AE,
|
51
|
+
0347 => :Aacute,
|
52
|
+
0345 => :Acircumflex,
|
53
|
+
0200 => :Adieresis,
|
54
|
+
0313 => :Agrave,
|
55
|
+
0201 => :Aring,
|
56
|
+
0314 => :Atilde,
|
57
|
+
0102 => :B,
|
58
|
+
0103 => :C,
|
59
|
+
0202 => :Ccedilla,
|
60
|
+
0104 => :D,
|
61
|
+
0105 => :E,
|
62
|
+
0203 => :Eacute,
|
63
|
+
0346 => :Ecircumflex,
|
64
|
+
0350 => :Edieresis,
|
65
|
+
0351 => :Egrave,
|
66
|
+
0106 => :F,
|
67
|
+
0107 => :G,
|
68
|
+
0110 => :H,
|
69
|
+
0111 => :I,
|
70
|
+
0352 => :Iacute,
|
71
|
+
0353 => :Icircumflex,
|
72
|
+
0354 => :Idieresis,
|
73
|
+
0355 => :Igrave,
|
74
|
+
0112 => :J,
|
75
|
+
0113 => :K,
|
76
|
+
0114 => :L,
|
77
|
+
0115 => :M,
|
78
|
+
0116 => :N,
|
79
|
+
0204 => :Ntilde,
|
80
|
+
0117 => :O,
|
81
|
+
0316 => :OE,
|
82
|
+
0356 => :Oacute,
|
83
|
+
0357 => :Ocircumflex,
|
84
|
+
0205 => :Odieresis,
|
85
|
+
0361 => :Ograve,
|
86
|
+
0257 => :Oslash,
|
87
|
+
0315 => :Otilde,
|
88
|
+
0120 => :P,
|
89
|
+
0121 => :Q,
|
90
|
+
0122 => :R,
|
91
|
+
0123 => :S,
|
92
|
+
0124 => :T,
|
93
|
+
0125 => :U,
|
94
|
+
0362 => :Uacute,
|
95
|
+
0363 => :Ucircumflex,
|
96
|
+
0206 => :Udieresis,
|
97
|
+
0364 => :Ugrave,
|
98
|
+
0126 => :V,
|
99
|
+
0127 => :W,
|
100
|
+
0130 => :X,
|
101
|
+
0131 => :Y,
|
102
|
+
0331 => :Ydieresis,
|
103
|
+
0132 => :Z,
|
104
|
+
0141 => :a,
|
105
|
+
0207 => :aacute,
|
106
|
+
0211 => :acircumflex,
|
107
|
+
0253 => :acute,
|
108
|
+
0212 => :adieresis,
|
109
|
+
0276 => :ae,
|
110
|
+
0210 => :agrave,
|
111
|
+
0046 => :ampersand,
|
112
|
+
0214 => :aring,
|
113
|
+
0136 => :asciicircum,
|
114
|
+
0176 => :asciitilde,
|
115
|
+
0052 => :asterisk,
|
116
|
+
0100 => :at,
|
117
|
+
0213 => :atilde,
|
118
|
+
0142 => :b,
|
119
|
+
0134 => :backslash,
|
120
|
+
0174 => :bar,
|
121
|
+
0173 => :braceleft,
|
122
|
+
0175 => :braceright,
|
123
|
+
0133 => :bracketleft,
|
124
|
+
0135 => :bracketright,
|
125
|
+
0371 => :breve,
|
126
|
+
0245 => :bullet,
|
127
|
+
0143 => :c,
|
128
|
+
0377 => :caron,
|
129
|
+
0215 => :ccedilla,
|
130
|
+
0374 => :cedilla,
|
131
|
+
0242 => :cent,
|
132
|
+
0366 => :circumflex,
|
133
|
+
0072 => :colon,
|
134
|
+
0054 => :comma,
|
135
|
+
0251 => :copyright,
|
136
|
+
0333 => :currency,
|
137
|
+
0144 => :d,
|
138
|
+
0240 => :dagger,
|
139
|
+
0340 => :daggerdbl,
|
140
|
+
0241 => :degree,
|
141
|
+
0254 => :dieresis,
|
142
|
+
0326 => :divide,
|
143
|
+
0044 => :dollar,
|
144
|
+
0372 => :dotaccent,
|
145
|
+
0365 => :dotlessi,
|
146
|
+
0145 => :e,
|
147
|
+
0216 => :eacute,
|
148
|
+
0220 => :ecircumflex,
|
149
|
+
0221 => :edieresis,
|
150
|
+
0217 => :egrave,
|
151
|
+
0070 => :eight,
|
152
|
+
0311 => :ellipsis,
|
153
|
+
0321 => :emdash,
|
154
|
+
0320 => :endash,
|
155
|
+
0075 => :equal,
|
156
|
+
0041 => :exclam,
|
157
|
+
0301 => :exclamdown,
|
158
|
+
0146 => :f,
|
159
|
+
0336 => :fi,
|
160
|
+
0065 => :five,
|
161
|
+
0337 => :fl,
|
162
|
+
0304 => :florin,
|
163
|
+
0064 => :four,
|
164
|
+
0332 => :fraction,
|
165
|
+
0147 => :g,
|
166
|
+
0247 => :germandbls,
|
167
|
+
0140 => :grave,
|
168
|
+
0076 => :greater,
|
169
|
+
0307 => :guillemotleft,
|
170
|
+
0310 => :guillemotright,
|
171
|
+
0334 => :guilsinglleft,
|
172
|
+
0335 => :guilsinglright,
|
173
|
+
0150 => :h,
|
174
|
+
0375 => :hungarumlaut,
|
175
|
+
0055 => :hyphen,
|
176
|
+
0151 => :i,
|
177
|
+
0222 => :iacute,
|
178
|
+
0224 => :icircumflex,
|
179
|
+
0225 => :idieresis,
|
180
|
+
0223 => :igrave,
|
181
|
+
0152 => :j,
|
182
|
+
0153 => :k,
|
183
|
+
0154 => :l,
|
184
|
+
0074 => :less,
|
185
|
+
0302 => :logicalnot,
|
186
|
+
0155 => :m,
|
187
|
+
0370 => :macron,
|
188
|
+
0265 => :mu,
|
189
|
+
0156 => :n,
|
190
|
+
0071 => :nine,
|
191
|
+
0226 => :ntilde,
|
192
|
+
0043 => :numbersign,
|
193
|
+
0157 => :o,
|
194
|
+
0227 => :oacute,
|
195
|
+
0231 => :ocircumflex,
|
196
|
+
0232 => :odieresis,
|
197
|
+
0317 => :oe,
|
198
|
+
0376 => :ogonek,
|
199
|
+
0230 => :ograve,
|
200
|
+
0061 => :one,
|
201
|
+
0273 => :ordfeminine,
|
202
|
+
0274 => :ordmasculine,
|
203
|
+
0277 => :oslash,
|
204
|
+
0233 => :otilde,
|
205
|
+
0160 => :p,
|
206
|
+
0246 => :paragraph,
|
207
|
+
0050 => :parenleft,
|
208
|
+
0051 => :parenright,
|
209
|
+
0045 => :percent,
|
210
|
+
0056 => :period,
|
211
|
+
0341 => :periodcentered,
|
212
|
+
0344 => :perthousand,
|
213
|
+
0053 => :plus,
|
214
|
+
0261 => :plusminus,
|
215
|
+
0161 => :q,
|
216
|
+
0077 => :question,
|
217
|
+
0300 => :questiondown,
|
218
|
+
0042 => :quotedbl,
|
219
|
+
0343 => :quotedblbase,
|
220
|
+
0322 => :quotedblleft,
|
221
|
+
0323 => :quotedblright,
|
222
|
+
0324 => :quoteleft,
|
223
|
+
0325 => :quoteright,
|
224
|
+
0342 => :quotesinglbase,
|
225
|
+
0047 => :quotesingle,
|
226
|
+
0162 => :r,
|
227
|
+
0250 => :registered,
|
228
|
+
0373 => :ring,
|
229
|
+
0163 => :s,
|
230
|
+
0244 => :section,
|
231
|
+
0073 => :semicolon,
|
232
|
+
0067 => :seven,
|
233
|
+
0066 => :six,
|
234
|
+
0057 => :slash,
|
235
|
+
0040 => :space,
|
236
|
+
0243 => :sterling,
|
237
|
+
0164 => :t,
|
238
|
+
0063 => :three,
|
239
|
+
0367 => :tilde,
|
240
|
+
0252 => :trademark,
|
241
|
+
0062 => :two,
|
242
|
+
0165 => :u,
|
243
|
+
0234 => :uacute,
|
244
|
+
0236 => :ucircumflex,
|
245
|
+
0237 => :udieresis,
|
246
|
+
0235 => :ugrave,
|
247
|
+
0137 => :underscore,
|
248
|
+
0166 => :v,
|
249
|
+
0167 => :w,
|
250
|
+
0170 => :x,
|
251
|
+
0171 => :y,
|
252
|
+
0330 => :ydieresis,
|
253
|
+
0264 => :yen,
|
254
|
+
0172 => :z,
|
255
|
+
0060 => :zero,
|
256
|
+
# additions due to PDF1.7 sD.2 footnote 6
|
257
|
+
0312 => :space,
|
258
|
+
}
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|