Class: Ucode::CodeChart::Extractor
- Inherits:
-
Object
- Object
- Ucode::CodeChart::Extractor
- Defined in:
- lib/ucode/code_chart/extractor.rb
Overview
Walks every assigned codepoint in a block and returns one Result per codepoint that any tier produced a glyph for.
This is not a new extraction pipeline — it composes the existing Glyphs::Resolver with per-block inputs (the block's Code Charts PDF + optionally Tier 1 and Pillar 3 sources). The Resolver owns tier selection; the Extractor owns inputs.
The REQ (R2) describes extraction via "locate the grid cell whose margin label matches the codepoint" — that was the v0.1 retired approach (cell-border compositing). The current path is the embedded-font walk (Pillar 1, via EmbeddedFonts::Catalog) with Pillar 2 (positional correlation) and Pillar 3 (Last Resort placeholders) as fallbacks.
Tier selection
Pillar 1 is always configured (the embedded font walk over the block's PDF). Tier 1 (real-font cmap) and Pillar 3 (Last Resort) are optional — the caller injects pre-built sources. This avoids forcing the Extractor to construct Last Resort eagerly, which would fail in environments where the UFO is not checked out.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#extract ⇒ Array<Result>
One Result per codepoint that any tier produced a glyph for.
-
#initialize(block:, pdf_path:, cache_dir: nil, tier1_sources: nil, pillar3_source: nil, assigned_only: false, codepoints: nil) ⇒ Extractor
constructor
A new instance of Extractor.
Constructor Details
#initialize(block:, pdf_path:, cache_dir: nil, tier1_sources: nil, pillar3_source: nil, assigned_only: false, codepoints: nil) ⇒ Extractor
Returns a new instance of Extractor.
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ucode/code_chart/extractor.rb', line 81 def initialize(block:, pdf_path:, cache_dir: nil, tier1_sources: nil, pillar3_source: nil, assigned_only: false, codepoints: nil) @block = block @pdf_path = Pathname.new(pdf_path) @cache_dir = cache_dir && Pathname.new(cache_dir) @tier1_sources = tier1_sources || [] @pillar3_source = pillar3_source @assigned_only = assigned_only @codepoints = codepoints end |
Instance Method Details
#extract ⇒ Array<Result>
Returns one Result per codepoint that any tier produced a glyph for. Codepoints no tier can serve are silently skipped (no Result yielded).
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/ucode/code_chart/extractor.rb', line 96 def extract resolver = build_resolver results = [] each_codepoint do |cp| resolver_result = resolver.resolve(cp) next unless resolver_result&.svg results << Result.new( codepoint: cp, svg: resolver_result.svg, tier: resolver_result.tier, provenance: resolver_result.provenance, base_font: resolver_result.base_font, gid: resolver_result.gid, source_page: resolver_result.source_page, source_cell: resolver_result.source_cell, extractor_version: Ucode::VERSION, ) end results end |