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) ⇒ Extractor
constructor
A new instance of Extractor.
Constructor Details
#initialize(block:, pdf_path:, cache_dir: nil, tier1_sources: nil, pillar3_source: nil) ⇒ Extractor
Returns a new instance of Extractor.
57 58 59 60 61 62 63 64 |
# File 'lib/ucode/code_chart/extractor.rb', line 57 def initialize(block:, pdf_path:, cache_dir: nil, tier1_sources: nil, pillar3_source: 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 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).
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ucode/code_chart/extractor.rb', line 69 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, ) end results end |