Class: Ucode::Commands::GlyphsCommand

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

Overview

‘ucode glyphs` — extract per-codepoint SVGs from Code Charts PDFs. Builds block specs from the cached Blocks.txt + per-block PDFs (or monolith fallback), then drains them through the Glyphs::Writer worker pool.

**Status (v0.1): EXPERIMENTAL.** The cell-extraction pipeline currently includes cell-border decorations alongside the actual character outline because the Code Charts PDFs composite the two into a single glyph definition. The output is therefore not yet suitable for end-user display. The command is retained so the pipeline can be iterated on without churning the CLI surface, but callers MUST opt in via ‘include_glyphs: true` (CLI: `–include-glyphs`) and will receive a printed warning. Tracked for v0.2.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.experimental_warningString

Returns the experimental-status banner. Exposed so the CLI and BuildCommand surface the same message verbatim.

Returns:

  • (String)

    the experimental-status banner. Exposed so the CLI and BuildCommand surface the same message verbatim.



39
40
41
# File 'lib/ucode/commands/glyphs.rb', line 39

def experimental_warning
  ExperimentalWarning
end

Instance Method Details

#call(version_intent, output_root:, block_filter: nil, force: false, monolith_path: MonolithPath, include_glyphs: false, warn: nil) ⇒ Hash

Returns aggregated Writer tally + version, or a ‘skipped` payload when opt-in is false.

Parameters:

  • version_intent (nil, :default, :latest, String)
  • output_root (String, Pathname)
  • block_filter (Array<String>, nil) (defaults to: nil)

    block ids to limit to; nil = every block

  • force (Boolean) (defaults to: false)

    re-fetch PDFs even when cached

  • monolith_path (String, Pathname, nil) (defaults to: MonolithPath)

    path to CodeCharts.pdf for fallback slicing; defaults to ./CodeCharts.pdf

  • include_glyphs (Boolean) (defaults to: false)

    opt-in for the experimental v0.1 pipeline. When false (default), the command returns a ‘skipped` payload without touching disk.

  • warn (IO, nil) (defaults to: nil)

    when provided, the experimental warning is written here exactly once before work begins.

Returns:

  • (Hash)

    aggregated Writer tally + version, or a ‘skipped` payload when opt-in is false.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ucode/commands/glyphs.rb', line 58

def call(version_intent, output_root:,
         block_filter: nil, force: false, monolith_path: MonolithPath,
         include_glyphs: false, warn: nil)
  return skipped(version_intent) unless include_glyphs

  warn&.puts(ExperimentalWarning)
  version = VersionResolver.resolve(version_intent)
  root = Pathname.new(output_root)

  blocks = load_blocks(version, block_filter)
  fetcher = build_fetcher(version, monolith_path, blocks)
  specs = blocks.map { |block| spec_for(block, fetcher, force) }.compact

  writer = Glyphs::Writer.new(output_root: root,
                               parallel_workers: workers)
  tally = writer.write_all(specs)
  tally.merge(version: version, block_count: specs.size)
end