hexapdf 0.1.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 +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,112 @@
|
|
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/true_type/table'
|
35
|
+
|
36
|
+
module HexaPDF
|
37
|
+
module Font
|
38
|
+
module TrueType
|
39
|
+
class Table
|
40
|
+
|
41
|
+
# The 'maxp' (maximum profile) table contains the maxima for a number of parameters (e.g. to
|
42
|
+
# establish memory requirements).
|
43
|
+
#
|
44
|
+
# See: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6maxp.html
|
45
|
+
class Maxp < Table
|
46
|
+
|
47
|
+
# The version of the table (a Rational).
|
48
|
+
attr_accessor :version
|
49
|
+
|
50
|
+
# The number of glyphs in the font.
|
51
|
+
attr_accessor :num_glyphs
|
52
|
+
|
53
|
+
# The maximum number of points in a non-compound glyph.
|
54
|
+
attr_accessor :max_points
|
55
|
+
|
56
|
+
# The maximum number of contours in a non-computed glyph.
|
57
|
+
attr_accessor :max_contours
|
58
|
+
|
59
|
+
# The maximum number of points in a compound glyph.
|
60
|
+
attr_accessor :max_component_points
|
61
|
+
|
62
|
+
# The maximum number of contours in a compound glyph.
|
63
|
+
attr_accessor :max_component_contours
|
64
|
+
|
65
|
+
# The maximum number of points used in Twilight Zone (Z0).
|
66
|
+
attr_accessor :max_twilight_points
|
67
|
+
|
68
|
+
# The maximum number of storage area locations.
|
69
|
+
attr_accessor :max_storage
|
70
|
+
|
71
|
+
# The maximum number of FDEFs (function definitions).
|
72
|
+
attr_accessor :max_function_defs
|
73
|
+
|
74
|
+
# The maximum number of IDEFs (instruction defintions).
|
75
|
+
attr_accessor :max_instruction_defs
|
76
|
+
|
77
|
+
# The maximum number of elements on the stack, i.e. the stack depth.
|
78
|
+
attr_accessor :max_stack_elements
|
79
|
+
|
80
|
+
# The maximum number of bytes for glyph instructions.
|
81
|
+
attr_accessor :max_size_of_instructions
|
82
|
+
|
83
|
+
# The maximum number of glyphs referenced at the top level.
|
84
|
+
attr_accessor :max_component_elements
|
85
|
+
|
86
|
+
# The levels of recursion (0 if the font has only simple glyphs).
|
87
|
+
attr_accessor :max_component_depth
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def parse_table #:nodoc:
|
92
|
+
@version = read_fixed
|
93
|
+
@num_glyphs, @max_points, @max_contours, @max_component_points, @max_component_contours,
|
94
|
+
_unuse, @max_twilight_points, @max_storage, @max_function_defs, @max_instruction_defs,
|
95
|
+
@max_stack_elements, @max_size_of_instructions, @max_component_elements,
|
96
|
+
@max_component_depth = read_formatted(directory_entry.length - 4, 'n14')
|
97
|
+
end
|
98
|
+
|
99
|
+
def load_default #:nodoc:
|
100
|
+
@version = 1.to_r
|
101
|
+
@num_glyphs = @max_points = @max_contours = @max_component_points =
|
102
|
+
@max_component_contours = @max_twilight_points = @max_storage = @max_function_defs =
|
103
|
+
@max_instruction_defs = @max_stack_elements = @max_size_of_instructions =
|
104
|
+
@max_component_elements = @max_component_depth = 0
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,218 @@
|
|
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/true_type/table'
|
35
|
+
|
36
|
+
module HexaPDF
|
37
|
+
module Font
|
38
|
+
module TrueType
|
39
|
+
class Table
|
40
|
+
|
41
|
+
# The 'name' table contains the human-readable names for features, font names, style names,
|
42
|
+
# copyright notices and so on.
|
43
|
+
#
|
44
|
+
# See: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
|
45
|
+
class Name < Table
|
46
|
+
|
47
|
+
# Table for mapping symbolic names to name_id codes.
|
48
|
+
NAME_MAP = {
|
49
|
+
copyright: 0,
|
50
|
+
font_family: 1,
|
51
|
+
font_subfamily: 2,
|
52
|
+
unique_subfamily: 3,
|
53
|
+
font_name: 4,
|
54
|
+
version: 5,
|
55
|
+
postscript_name: 6,
|
56
|
+
trademark: 7,
|
57
|
+
manufacturer: 8,
|
58
|
+
designer: 9,
|
59
|
+
description: 10,
|
60
|
+
vendor_url: 11,
|
61
|
+
designer_url: 12,
|
62
|
+
license: 13,
|
63
|
+
license_url: 14,
|
64
|
+
preferred_family: 16,
|
65
|
+
preferred_subfamily: 17,
|
66
|
+
compatible_full: 18,
|
67
|
+
sample_text: 19,
|
68
|
+
postscript_cid_name: 20,
|
69
|
+
wws_family: 21,
|
70
|
+
wws_subfamily: 22,
|
71
|
+
}
|
72
|
+
|
73
|
+
# Contains the information for a Name Record.
|
74
|
+
#
|
75
|
+
# The string value is converted to UTF-8 if possible, otherwise it stays in BINARY.
|
76
|
+
class Record < String
|
77
|
+
|
78
|
+
# Indicates Unicode version.
|
79
|
+
PLATFORM_UNICODE = 0
|
80
|
+
|
81
|
+
# QuickDraw Script Manager code for Macintosh.
|
82
|
+
PLATFORM_MACINTOSH = 1
|
83
|
+
|
84
|
+
# Microsoft encoding.
|
85
|
+
PLATFORM_MICROSOFT = 3
|
86
|
+
|
87
|
+
# The platform identifier code.
|
88
|
+
attr_reader :platform_id
|
89
|
+
|
90
|
+
# The platform specific encoding identified.
|
91
|
+
attr_reader :encoding_id
|
92
|
+
|
93
|
+
# The language identified.
|
94
|
+
attr_reader :language_id
|
95
|
+
|
96
|
+
# Create a new name record.
|
97
|
+
def initialize(text, pid, eid, lid)
|
98
|
+
@platform_id = pid
|
99
|
+
@encoding_id = eid
|
100
|
+
@language_id = lid
|
101
|
+
|
102
|
+
if platform?(:unicode) ||
|
103
|
+
(platform?(:microsoft) && encoding_id == 1 || encoding_id == 10)
|
104
|
+
text.encode!(::Encoding::UTF_8, ::Encoding::UTF_16BE)
|
105
|
+
elsif platform?(:macintosh) && encoding_id == 0
|
106
|
+
text.encode!(::Encoding::UTF_8, ::Encoding::MACROMAN)
|
107
|
+
end
|
108
|
+
|
109
|
+
super(text)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Returns +true+ if this record has the given platform identifier which can either be
|
113
|
+
# :unicode, :macintosh or :microsoft.
|
114
|
+
def platform?(identifier)
|
115
|
+
platform_id == case identifier
|
116
|
+
when :unicode then PLATFORM_UNICODE
|
117
|
+
when :macintosh then PLATFORM_MACINTOSH
|
118
|
+
when :microsoft then PLATFORM_MICROSOFT
|
119
|
+
else
|
120
|
+
raise ArgumentError, "Unknown platform identifier: #{identifier}"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Returns +true+ if this record is a "preferred" one.
|
125
|
+
#
|
126
|
+
# The label "preferred" is set on a name if it represents the US English version of the
|
127
|
+
# name in a decodable encoding:
|
128
|
+
# * platform_id :macintosh, encoding_id 0 (Roman) and language_id 0 (English); or
|
129
|
+
# * platform_id :microsoft, encoding_id 1 (Unicode) and language_id 1033 (US English).
|
130
|
+
def preferred?
|
131
|
+
(platform_id == PLATFORM_MACINTOSH && encoding_id == 0 && language_id == 0) ||
|
132
|
+
(platform_id == PLATFORM_MICROSOFT && encoding_id == 1 && language_id == 1033)
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
# Holds records for the same name type (e.g. :font_name, :postscript_name, ...).
|
139
|
+
class Records < Array
|
140
|
+
|
141
|
+
# Returns the preferred record in this collection.
|
142
|
+
#
|
143
|
+
# This is either the first record where Record#preferred? is true or else just the first
|
144
|
+
# record in the collection.
|
145
|
+
def preferred_record
|
146
|
+
find(&:preferred?) || self[0]
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
# The format of the table.
|
153
|
+
attr_accessor :format
|
154
|
+
|
155
|
+
# The name records.
|
156
|
+
attr_accessor :records
|
157
|
+
|
158
|
+
# The mapping of language IDs starting from 0x8000 to language tags conforming to IETF BCP
|
159
|
+
# 47.
|
160
|
+
attr_accessor :language_tags
|
161
|
+
|
162
|
+
# Returns an array with all available entries for the given name identifier (either a
|
163
|
+
# symbol or an ID).
|
164
|
+
#
|
165
|
+
# See: NAME_MAP
|
166
|
+
def [](name_or_id)
|
167
|
+
@records[name_or_id.kind_of?(Symbol) ? NAME_MAP[name_or_id] : name_or_id]
|
168
|
+
end
|
169
|
+
|
170
|
+
# Adds a new record for the given name identifier (either a symbol or an ID).
|
171
|
+
#
|
172
|
+
# The optional platform, encoding and language IDs are preset to represent the text as
|
173
|
+
# English in Mac Roman encoding.
|
174
|
+
def add(name_or_id, text, platform_id: 1, encoding_id: 0, language_id: 0)
|
175
|
+
self[name_or_id] << Record.new(text, platform_id, encoding_id, language_id)
|
176
|
+
end
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
def parse_table #:nodoc:
|
181
|
+
@format, count, string_offset = read_formatted(6, 'n3')
|
182
|
+
string_offset += directory_entry.offset
|
183
|
+
|
184
|
+
@records = Hash.new {|h, k| h[k] = Records.new}
|
185
|
+
@language_tags = {}
|
186
|
+
|
187
|
+
record_rows = count.times.map { read_formatted(12, 'n6') }
|
188
|
+
if @format == 1
|
189
|
+
count = read_formatted(2, 'n').first
|
190
|
+
language_rows = count.times.map { read_formatted(4, 'n2') }
|
191
|
+
end
|
192
|
+
|
193
|
+
record_rows.each do |pid, eid, lid, nid, length, offset|
|
194
|
+
io.pos = string_offset + offset
|
195
|
+
@records[nid] << Record.new(io.read(length), pid, eid, lid)
|
196
|
+
end
|
197
|
+
|
198
|
+
if @format == 1
|
199
|
+
language_rows.each_with_index do |(length, offset), index|
|
200
|
+
io.pos = string_offset + offset
|
201
|
+
@language_tags[0x8000 + index] =
|
202
|
+
io.read(length).encode!(::Encoding::UTF_8, ::Encoding::UTF_16BE)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def load_default #:nodoc:
|
208
|
+
@format = 0
|
209
|
+
@records = Hash.new {|h, k| h[k] = Records.new}
|
210
|
+
@language_tags = {}
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
@@ -0,0 +1,200 @@
|
|
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/true_type/table'
|
35
|
+
require 'hexapdf/utils/bit_field'
|
36
|
+
|
37
|
+
module HexaPDF
|
38
|
+
module Font
|
39
|
+
module TrueType
|
40
|
+
class Table
|
41
|
+
|
42
|
+
# The 'OS/2' table contains information required by Windows.
|
43
|
+
#
|
44
|
+
# Some attributes may be +nil+ when read from a file depending on the version of the table.
|
45
|
+
#
|
46
|
+
# See: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html
|
47
|
+
class OS2 < Table
|
48
|
+
extend HexaPDF::Utils::BitField
|
49
|
+
|
50
|
+
# The version of the table.
|
51
|
+
attr_accessor :version
|
52
|
+
|
53
|
+
# AVerage weighted advance width of lower case letters and space.
|
54
|
+
attr_accessor :x_avg_char_width
|
55
|
+
|
56
|
+
# Visual weight of stroke in glyphs.
|
57
|
+
attr_accessor :weight_class
|
58
|
+
|
59
|
+
# Relative change from the normal aspect ratio (width/height).
|
60
|
+
attr_accessor :width_class
|
61
|
+
|
62
|
+
# Characteristics and properties of this font.
|
63
|
+
attr_accessor :type
|
64
|
+
bit_field(:type, restricted_license_embedding: 1, preview_and_print_embedding: 2,
|
65
|
+
editable_embedding: 3, no_subsetting: 8, bitmap_embedding_only: 9)
|
66
|
+
|
67
|
+
# Recommended horizontal size in pixels for subscripts
|
68
|
+
attr_accessor :subscript_x_size
|
69
|
+
|
70
|
+
# Recommended vertical size in pixels for subscripts
|
71
|
+
attr_accessor :subscript_y_size
|
72
|
+
|
73
|
+
# Recommended horizontal offset for subscripts.
|
74
|
+
attr_accessor :subscript_x_offset
|
75
|
+
|
76
|
+
# Recommended vertical offset from the baseline for subscripts.
|
77
|
+
attr_accessor :subscript_y_offset
|
78
|
+
|
79
|
+
# Recommended horizontal size in pixels for superscripts
|
80
|
+
attr_accessor :superscript_x_size
|
81
|
+
|
82
|
+
# Recommended vertical size in pixels for superscripts
|
83
|
+
attr_accessor :superscript_y_size
|
84
|
+
|
85
|
+
# Recommended horizontal offset for superscripts.
|
86
|
+
attr_accessor :superscript_x_offset
|
87
|
+
|
88
|
+
# Recommended vertical offset from the baseline for superscripts.
|
89
|
+
attr_accessor :superscript_y_offset
|
90
|
+
|
91
|
+
# Width of the strikeout stroke.
|
92
|
+
attr_accessor :strikeout_size
|
93
|
+
|
94
|
+
# Position of the strikeout stroke relative to the baseline.
|
95
|
+
attr_accessor :strikeout_position
|
96
|
+
|
97
|
+
# Classification of the font-family design.
|
98
|
+
attr_accessor :family_class
|
99
|
+
|
100
|
+
# Describes the visual characteristics of the given typeface.
|
101
|
+
attr_accessor :panose
|
102
|
+
|
103
|
+
# Describes the Unicode ranges covered by the font.
|
104
|
+
attr_accessor :unicode_range
|
105
|
+
|
106
|
+
# The four character identifier of the font vendor.
|
107
|
+
attr_accessor :vendor_id
|
108
|
+
|
109
|
+
# Information concerning the nature of the font patterns.
|
110
|
+
attr_accessor :selection
|
111
|
+
bit_field(:selection, italic: 0, underscore: 1, negative: 2, outlined: 3, strikeout: 4,
|
112
|
+
bold: 5, regular: 6, use_typo_metrics: 7, wws: 8, oblique: 9)
|
113
|
+
|
114
|
+
# The minimum Unicode index in this font.
|
115
|
+
attr_accessor :first_char_index
|
116
|
+
|
117
|
+
# The maximum Unicode index in this font.
|
118
|
+
attr_accessor :last_char_index
|
119
|
+
|
120
|
+
# The typographic ascender. May not be the same as the ascender in the 'hhea' table.
|
121
|
+
attr_accessor :typo_ascender
|
122
|
+
|
123
|
+
# The typographic descender. May not be the same as the ascender in the 'hhea' table.
|
124
|
+
attr_accessor :typo_descender
|
125
|
+
|
126
|
+
# The typographic line gap. May not be the same as the ascender in the 'hhea' table.
|
127
|
+
attr_accessor :typo_line_gap
|
128
|
+
|
129
|
+
# The ascender metric for Windows.
|
130
|
+
attr_accessor :win_ascent
|
131
|
+
|
132
|
+
# The descender metric for Windows.
|
133
|
+
attr_accessor :win_descent
|
134
|
+
|
135
|
+
# The code page character range.
|
136
|
+
attr_accessor :code_page_range
|
137
|
+
|
138
|
+
# The distance between the baseline and the approximate height of non-ascending lowercase
|
139
|
+
# letters.
|
140
|
+
attr_accessor :x_height
|
141
|
+
|
142
|
+
# The distance between the baseline and the approximate height of uppercase letters.
|
143
|
+
attr_accessor :cap_height
|
144
|
+
|
145
|
+
# The default character displayed by Windows to represent an unsupported character.
|
146
|
+
attr_accessor :default_char
|
147
|
+
|
148
|
+
# The break character used by Windows.
|
149
|
+
attr_accessor :break_char
|
150
|
+
|
151
|
+
# The maximum length of an OpenType context for any feature in this font.
|
152
|
+
attr_accessor :max_context
|
153
|
+
|
154
|
+
# The lowest size at which the font starts to be used.
|
155
|
+
attr_accessor :lower_point_size
|
156
|
+
|
157
|
+
# The highest size at which the font starts to be used.
|
158
|
+
attr_accessor :upper_point_size
|
159
|
+
|
160
|
+
private
|
161
|
+
|
162
|
+
def parse_table #:nodoc:
|
163
|
+
@version, @x_avg_char_width, @weight_class, @width_class, @type, @subscript_x_size,
|
164
|
+
@subscript_y_size, @subscript_x_offset, @subscript_y_offset, @superscript_x_size,
|
165
|
+
@superscript_y_size, @superscript_x_offset, @superscript_y_offset, @strikeout_size,
|
166
|
+
@strikeout_position, @family_class, @panose =
|
167
|
+
read_formatted(42, 'ns>n2s>12a10')
|
168
|
+
|
169
|
+
@weight_class *= 100 if @weight_class < 100 # Normalize to standard weights
|
170
|
+
|
171
|
+
@unicode_range, temp = read_formatted(16, 'Q>2')
|
172
|
+
@unicode_range = @unicode_range << 64 & temp
|
173
|
+
|
174
|
+
@vendor_id, @selection,
|
175
|
+
@first_char_index, @last_char_index, @typo_ascender, @typo_descender, @typo_line_gap,
|
176
|
+
@win_ascent, @win_descent, @code_page_range, @x_height, @cap_height, @default_char,
|
177
|
+
@break_char, @max_context, @lower_point_size, @upper_point_size =
|
178
|
+
read_formatted(directory_entry.length - 58, 'a4n3s>3n2Q>s>2n5')
|
179
|
+
end
|
180
|
+
|
181
|
+
def load_default #:nodoc:
|
182
|
+
@version = 5
|
183
|
+
@panose = ''.b
|
184
|
+
@vendor_id = ' '.b
|
185
|
+
@x_avg_char_width = @weight_class = @width_class = @type = @subscript_x_size =
|
186
|
+
@subscript_y_size = @subscript_x_offset = @subscript_y_offset = @superscript_x_size =
|
187
|
+
@superscript_y_size = @superscript_x_offset = @superscript_y_offset =
|
188
|
+
@strikeout_size = @strikeout_position = @family_class = @unicode_range = @selection =
|
189
|
+
@first_char_index = @last_char_index = @typo_ascender = @typo_descender =
|
190
|
+
@typo_line_gap = @win_ascent = @win_descent = @code_page_range = @x_height =
|
191
|
+
@cap_height = @default_char = @break_char = @max_context = @lower_point_size =
|
192
|
+
@upper_point_size = 0
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|