module HexaPDF
def self.data_dir
def self.data_dir unless defined?(@data_dir) require 'rbconfig' @data_dir = File.expand_path(File.join(__dir__, '..', '..', 'data', 'hexapdf')) unless File.directory?(@data_dir) @data_dir = File.expand_path(File.join(RbConfig::CONFIG["datadir"], "hexapdf")) end unless File.directory?(@data_dir) raise "HexaPDF data directory not found! This is a bug, please report it!" end end @data_dir end
def self.font_on_invalid_glyph(codepoint, invalid_glyph)
contains a glyph for the +codepoint+ (taking the font variant into account). If no fallback font
It uses the first font in the list provided by the 'font.fallback' configuration option that
Provides the default implementation for the configuration option 'font.on_invalid_glyph'.
def self.font_on_invalid_glyph(codepoint, invalid_glyph) font_wrapper = invalid_glyph.font_wrapper document = font_wrapper.pdf_object.document variant = case when font_wrapper.italic? && font_wrapper.bold? then :bold_italic when font_wrapper.bold? then :bold when font_wrapper.italic? then :italic else :none end document.config['font.fallback'].each do |font_name| font = document.fonts.add(font_name, variant: variant) rescue document.fonts.add(font_name) glyph = font.decode_codepoint(codepoint) unless glyph.kind_of?(HexaPDF::Font::InvalidGlyph) return [glyph] end end [invalid_glyph] end
Modules
Classes
- HexaPDF::Composer
- HexaPDF::Configuration
- HexaPDF::Dictionary
- HexaPDF::Document
- HexaPDF::EncryptionError
- HexaPDF::Error
- HexaPDF::FiberDoubleForString
- HexaPDF::FiberWithLength
- HexaPDF::FilterError
- HexaPDF::Importer
- HexaPDF::InvalidPDFObjectError
- HexaPDF::MalformedPDFError
- HexaPDF::MissingGlyphError
- HexaPDF::NameTreeNode
- HexaPDF::NumberTreeNode
- HexaPDF::Object
- HexaPDF::PDFArray
- HexaPDF::PDFData
- HexaPDF::Parser
- HexaPDF::Rectangle
- HexaPDF::Reference
- HexaPDF::Revision
- HexaPDF::Revisions
- HexaPDF::Serializer
- HexaPDF::Stream
- HexaPDF::StreamData
- HexaPDF::Tokenizer
- HexaPDF::UnsupportedEncryptionError
- HexaPDF::Writer
- HexaPDF::XRefSection
Class Methods
Defined in
- lib/hexapdf/cli.rb
- lib/hexapdf/cli/batch.rb
- lib/hexapdf/cli/command.rb
- lib/hexapdf/cli/files.rb
- lib/hexapdf/cli/fonts.rb
- lib/hexapdf/cli/form.rb
- lib/hexapdf/cli/image2pdf.rb
- lib/hexapdf/cli/images.rb
- lib/hexapdf/cli/info.rb
- lib/hexapdf/cli/inspect.rb
- lib/hexapdf/cli/merge.rb
- lib/hexapdf/cli/modify.rb
- lib/hexapdf/cli/optimize.rb
- lib/hexapdf/cli/split.rb
- lib/hexapdf/cli/usage.rb
- lib/hexapdf/cli/watermark.rb
- lib/hexapdf/composer.rb
- lib/hexapdf/configuration.rb
- lib/hexapdf/content.rb
- lib/hexapdf/content/canvas.rb
- lib/hexapdf/content/canvas_composer.rb
- lib/hexapdf/content/color_space.rb
- lib/hexapdf/content/graphic_object.rb
- lib/hexapdf/content/graphic_object/arc.rb
- lib/hexapdf/content/graphic_object/endpoint_arc.rb
- lib/hexapdf/content/graphic_object/geom2d.rb
- lib/hexapdf/content/graphic_object/solid_arc.rb
- lib/hexapdf/content/graphics_state.rb
- lib/hexapdf/content/operator.rb
- lib/hexapdf/content/parser.rb
- lib/hexapdf/content/processor.rb
- lib/hexapdf/content/transformation_matrix.rb
- lib/hexapdf/data_dir.rb
- lib/hexapdf/dictionary.rb
- lib/hexapdf/dictionary_fields.rb
- lib/hexapdf/digital_signature.rb
- lib/hexapdf/digital_signature/cms_handler.rb
- lib/hexapdf/digital_signature/handler.rb
- lib/hexapdf/digital_signature/pkcs1_handler.rb
- lib/hexapdf/digital_signature/signature.rb
- lib/hexapdf/digital_signature/signatures.rb
- lib/hexapdf/digital_signature/signing.rb
- lib/hexapdf/digital_signature/signing/default_handler.rb
- lib/hexapdf/digital_signature/signing/signed_data_creator.rb
- lib/hexapdf/digital_signature/signing/timestamp_handler.rb
- lib/hexapdf/digital_signature/verification_result.rb
- lib/hexapdf/document.rb
- lib/hexapdf/document/annotations.rb
- lib/hexapdf/document/destinations.rb
- lib/hexapdf/document/files.rb
- lib/hexapdf/document/fonts.rb
- lib/hexapdf/document/images.rb
- lib/hexapdf/document/layout.rb
- lib/hexapdf/document/metadata.rb
- lib/hexapdf/document/pages.rb
- lib/hexapdf/encryption.rb
- lib/hexapdf/encryption/aes.rb
- lib/hexapdf/encryption/arc4.rb
- lib/hexapdf/encryption/fast_aes.rb
- lib/hexapdf/encryption/fast_arc4.rb
- lib/hexapdf/encryption/identity.rb
- lib/hexapdf/encryption/ruby_aes.rb
- lib/hexapdf/encryption/ruby_arc4.rb
- lib/hexapdf/encryption/security_handler.rb
- lib/hexapdf/encryption/standard_security_handler.rb
- lib/hexapdf/error.rb
- lib/hexapdf/filter.rb
- lib/hexapdf/filter/ascii85_decode.rb
- lib/hexapdf/filter/ascii_hex_decode.rb
- lib/hexapdf/filter/crypt.rb
- lib/hexapdf/filter/encryption.rb
- lib/hexapdf/filter/flate_decode.rb
- lib/hexapdf/filter/lzw_decode.rb
- lib/hexapdf/filter/pass_through.rb
- lib/hexapdf/filter/predictor.rb
- lib/hexapdf/filter/run_length_decode.rb
- lib/hexapdf/font/cmap.rb
- lib/hexapdf/font/cmap/parser.rb
- lib/hexapdf/font/cmap/writer.rb
- lib/hexapdf/font/encoding.rb
- lib/hexapdf/font/encoding/base.rb
- lib/hexapdf/font/encoding/difference_encoding.rb
- lib/hexapdf/font/encoding/glyph_list.rb
- lib/hexapdf/font/encoding/mac_expert_encoding.rb
- lib/hexapdf/font/encoding/mac_roman_encoding.rb
- lib/hexapdf/font/encoding/standard_encoding.rb
- lib/hexapdf/font/encoding/symbol_encoding.rb
- lib/hexapdf/font/encoding/win_ansi_encoding.rb
- lib/hexapdf/font/encoding/zapf_dingbats_encoding.rb
- lib/hexapdf/font/invalid_glyph.rb
- lib/hexapdf/font/true_type.rb
- lib/hexapdf/font/true_type/builder.rb
- lib/hexapdf/font/true_type/font.rb
- lib/hexapdf/font/true_type/optimizer.rb
- lib/hexapdf/font/true_type/subsetter.rb
- lib/hexapdf/font/true_type/table.rb
- lib/hexapdf/font/true_type/table/cmap.rb
- lib/hexapdf/font/true_type/table/cmap_subtable.rb
- lib/hexapdf/font/true_type/table/directory.rb
- lib/hexapdf/font/true_type/table/glyf.rb
- lib/hexapdf/font/true_type/table/head.rb
- lib/hexapdf/font/true_type/table/hhea.rb
- lib/hexapdf/font/true_type/table/hmtx.rb
- lib/hexapdf/font/true_type/table/kern.rb
- lib/hexapdf/font/true_type/table/loca.rb
- lib/hexapdf/font/true_type/table/maxp.rb
- lib/hexapdf/font/true_type/table/name.rb
- lib/hexapdf/font/true_type/table/os2.rb
- lib/hexapdf/font/true_type/table/post.rb
- lib/hexapdf/font/true_type_wrapper.rb
- lib/hexapdf/font/type1.rb
- lib/hexapdf/font/type1/afm_parser.rb
- lib/hexapdf/font/type1/character_metrics.rb
- lib/hexapdf/font/type1/font.rb
- lib/hexapdf/font/type1/font_metrics.rb
- lib/hexapdf/font/type1/pfb_parser.rb
- lib/hexapdf/font/type1_wrapper.rb
- lib/hexapdf/font_loader.rb
- lib/hexapdf/font_loader/from_configuration.rb
- lib/hexapdf/font_loader/from_file.rb
- lib/hexapdf/font_loader/standard14.rb
- lib/hexapdf/font_loader/variant_from_name.rb
- lib/hexapdf/image_loader.rb
- lib/hexapdf/image_loader/jpeg.rb
- lib/hexapdf/image_loader/pdf.rb
- lib/hexapdf/image_loader/png.rb
- lib/hexapdf/importer.rb
- lib/hexapdf/layout.rb
- lib/hexapdf/layout/box.rb
- lib/hexapdf/layout/box_fitter.rb
- lib/hexapdf/layout/column_box.rb
- lib/hexapdf/layout/container_box.rb
- lib/hexapdf/layout/frame.rb
- lib/hexapdf/layout/image_box.rb
- lib/hexapdf/layout/inline_box.rb
- lib/hexapdf/layout/line.rb
- lib/hexapdf/layout/list_box.rb
- lib/hexapdf/layout/numeric_refinements.rb
- lib/hexapdf/layout/page_style.rb
- lib/hexapdf/layout/style.rb
- lib/hexapdf/layout/table_box.rb
- lib/hexapdf/layout/text_box.rb
- lib/hexapdf/layout/text_fragment.rb
- lib/hexapdf/layout/text_layouter.rb
- lib/hexapdf/layout/text_shaper.rb
- lib/hexapdf/layout/width_from_polygon.rb
- lib/hexapdf/name_tree_node.rb
- lib/hexapdf/number_tree_node.rb
- lib/hexapdf/object.rb
- lib/hexapdf/parser.rb
- lib/hexapdf/pdf_array.rb
- lib/hexapdf/rectangle.rb
- lib/hexapdf/reference.rb
- lib/hexapdf/revision.rb
- lib/hexapdf/revisions.rb
- lib/hexapdf/serializer.rb
- lib/hexapdf/stream.rb
- lib/hexapdf/task.rb
- lib/hexapdf/task/dereference.rb
- lib/hexapdf/task/merge_acro_form.rb
- lib/hexapdf/task/optimize.rb
- lib/hexapdf/task/pdfa.rb
- lib/hexapdf/test_utils.rb
- lib/hexapdf/tokenizer.rb
- lib/hexapdf/type.rb
- lib/hexapdf/type/acro_form.rb
- lib/hexapdf/type/acro_form/appearance_generator.rb
- lib/hexapdf/type/acro_form/button_field.rb
- lib/hexapdf/type/acro_form/choice_field.rb
- lib/hexapdf/type/acro_form/field.rb
- lib/hexapdf/type/acro_form/form.rb
- lib/hexapdf/type/acro_form/java_script_actions.rb
- lib/hexapdf/type/acro_form/signature_field.rb
- lib/hexapdf/type/acro_form/text_field.rb
- lib/hexapdf/type/acro_form/variable_text_field.rb
- lib/hexapdf/type/action.rb
- lib/hexapdf/type/actions.rb
- lib/hexapdf/type/actions/go_to.rb
- lib/hexapdf/type/actions/go_to_r.rb
- lib/hexapdf/type/actions/launch.rb
- lib/hexapdf/type/actions/set_ocg_state.rb
- lib/hexapdf/type/actions/uri.rb
- lib/hexapdf/type/annotation.rb
- lib/hexapdf/type/annotations.rb
- lib/hexapdf/type/annotations/appearance_generator.rb
- lib/hexapdf/type/annotations/border_effect.rb
- lib/hexapdf/type/annotations/border_styling.rb
- lib/hexapdf/type/annotations/circle.rb
- lib/hexapdf/type/annotations/interior_color.rb
- lib/hexapdf/type/annotations/line.rb
- lib/hexapdf/type/annotations/link.rb
- lib/hexapdf/type/annotations/markup_annotation.rb
- lib/hexapdf/type/annotations/square.rb
- lib/hexapdf/type/annotations/square_circle.rb
- lib/hexapdf/type/annotations/text.rb
- lib/hexapdf/type/annotations/widget.rb
- lib/hexapdf/type/catalog.rb
- lib/hexapdf/type/cid_font.rb
- lib/hexapdf/type/cmap.rb
- lib/hexapdf/type/embedded_file.rb
- lib/hexapdf/type/file_specification.rb
- lib/hexapdf/type/font.rb
- lib/hexapdf/type/font_descriptor.rb
- lib/hexapdf/type/font_simple.rb
- lib/hexapdf/type/font_true_type.rb
- lib/hexapdf/type/font_type0.rb
- lib/hexapdf/type/font_type1.rb
- lib/hexapdf/type/font_type3.rb
- lib/hexapdf/type/form.rb
- lib/hexapdf/type/graphics_state_parameter.rb
- lib/hexapdf/type/icon_fit.rb
- lib/hexapdf/type/image.rb
- lib/hexapdf/type/info.rb
- lib/hexapdf/type/mark_information.rb
- lib/hexapdf/type/marked_content_reference.rb
- lib/hexapdf/type/metadata.rb
- lib/hexapdf/type/names.rb
- lib/hexapdf/type/namespace.rb
- lib/hexapdf/type/object_reference.rb
- lib/hexapdf/type/object_stream.rb
- lib/hexapdf/type/optional_content_configuration.rb
- lib/hexapdf/type/optional_content_group.rb
- lib/hexapdf/type/optional_content_membership.rb
- lib/hexapdf/type/optional_content_properties.rb
- lib/hexapdf/type/outline.rb
- lib/hexapdf/type/outline_item.rb
- lib/hexapdf/type/output_intent.rb
- lib/hexapdf/type/page.rb
- lib/hexapdf/type/page_label.rb
- lib/hexapdf/type/page_tree_node.rb
- lib/hexapdf/type/resources.rb
- lib/hexapdf/type/struct_elem.rb
- lib/hexapdf/type/struct_tree_root.rb
- lib/hexapdf/type/trailer.rb
- lib/hexapdf/type/viewer_preferences.rb
- lib/hexapdf/type/xref_stream.rb
- lib/hexapdf/utils.rb
- lib/hexapdf/utils/bit_field.rb
- lib/hexapdf/utils/bit_stream.rb
- lib/hexapdf/utils/graphics_helpers.rb
- lib/hexapdf/utils/lru_cache.rb
- lib/hexapdf/utils/math_helpers.rb
- lib/hexapdf/utils/object_hash.rb
- lib/hexapdf/utils/pdf_doc_encoding.rb
- lib/hexapdf/utils/sorted_tree_node.rb
- lib/hexapdf/version.rb
- lib/hexapdf/writer.rb
- lib/hexapdf/xref_section.rb