Class: Ucode::Glyphs::EmbeddedFonts::TraceRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/glyphs/embedded_fonts/trace_runner.rb

Overview

Thin I/O wrapper around mutool trace <pdf> <page>.

Delegates the actual subprocess to Mutool::Trace and the XML parsing to TraceParser. Kept for backward compatibility with callers that pre-date the Mutool seam.

Instance Method Summary collapse

Constructor Details

#initialize(pdf_path, mutool: Mutool::Trace.new) ⇒ TraceRunner

Returns a new instance of TraceRunner.

Parameters:

  • pdf_path (Pathname, String)
  • mutool (Mutool::Trace) (defaults to: Mutool::Trace.new)

    injectable for tests



19
20
21
22
# File 'lib/ucode/glyphs/embedded_fonts/trace_runner.rb', line 19

def initialize(pdf_path, mutool: Mutool::Trace.new)
  @pdf_path = Pathname.new(pdf_path)
  @mutool = mutool
end

Instance Method Details

#trace(page_numbers) ⇒ Array<TraceGlyph>

Parameters:

  • page_numbers (Array<Integer>)

    1-based PDF page numbers

Returns:



26
27
28
29
30
31
32
33
# File 'lib/ucode/glyphs/embedded_fonts/trace_runner.rb', line 26

def trace(page_numbers)
  return [] if page_numbers.empty?

  page_numbers.flat_map do |page|
    xml = @mutool.call(@pdf_path, page)
    TraceParser.parse(xml)
  end
end