Class: Ucode::Glyphs::EmbeddedFonts::CodepointMapper::CorrelatorStrategy
- Inherits:
-
Strategy
- Object
- Strategy
- Ucode::Glyphs::EmbeddedFonts::CodepointMapper::CorrelatorStrategy
- Defined in:
- lib/ucode/glyphs/embedded_fonts/codepoint_mapper/correlator_strategy.rb
Overview
Strategy 2 — caller-supplied pillar-2 config. Renders the configured pages to SVG and runs Ucode::Glyphs::EmbeddedFonts::ContentStreamCorrelator to match specimen glyphs to hex labels positionally.
Instance Method Summary collapse
-
#initialize(source:, correlator_configs:, mutool_draw:) ⇒ CorrelatorStrategy
constructor
A new instance of CorrelatorStrategy.
- #map(descriptor) ⇒ Object
- #positional? ⇒ Boolean
- #supports?(descriptor) ⇒ Boolean
Constructor Details
#initialize(source:, correlator_configs:, mutool_draw:) ⇒ CorrelatorStrategy
Returns a new instance of CorrelatorStrategy.
18 19 20 21 22 23 |
# File 'lib/ucode/glyphs/embedded_fonts/codepoint_mapper/correlator_strategy.rb', line 18 def initialize(source:, correlator_configs:, mutool_draw:) super() @source = source @correlator_configs = correlator_configs @mutool_draw = mutool_draw end |
Instance Method Details
#map(descriptor) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ucode/glyphs/embedded_fonts/codepoint_mapper/correlator_strategy.rb', line 35 def map(descriptor) config = @correlator_configs[descriptor.font_obj_id] return {} if config.page_numbers.nil? || config.page_numbers.empty? svg = @mutool_draw.svg(@source.pdf_to_s, *config.page_numbers) ContentStreamCorrelator.new(config).correlate(svg) end |
#positional? ⇒ Boolean
31 32 33 |
# File 'lib/ucode/glyphs/embedded_fonts/codepoint_mapper/correlator_strategy.rb', line 31 def positional? true end |
#supports?(descriptor) ⇒ Boolean
25 26 27 28 |
# File 'lib/ucode/glyphs/embedded_fonts/codepoint_mapper/correlator_strategy.rb', line 25 def supports?(descriptor) descriptor.cid_map_kind == :identity && @correlator_configs.key?(descriptor.font_obj_id) end |