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. Thin Thor-facing wrapper around Glyphs::Pipeline: opt-in gate + experimental warning live here; the pipeline assembly (block loading, fetcher, per-block specs) lives in Glyphs::Pipeline.

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.

Takes a resolved version string; CLI callers resolve via VersionResolver.resolve once and thread it through. See Candidate 4 of the 2026-06-29 architecture review.

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.



36
37
38
# File 'lib/ucode/commands/glyphs.rb', line 36

def experimental_warning
  ExperimentalWarning
end

Instance Method Details

#call(version, output_root:, block_filter: nil, force: false, monolith_path: Glyphs::Pipeline::DEFAULT_MONOLITH_PATH, include_glyphs: false, warn: nil) ⇒ Hash

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

Parameters:

  • version (String)

    resolved UCD version

  • 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: Glyphs::Pipeline::DEFAULT_MONOLITH_PATH)

    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.



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

def call(version, output_root:,
         block_filter: nil, force: false,
         monolith_path: Glyphs::Pipeline::DEFAULT_MONOLITH_PATH,
         include_glyphs: false, warn: nil)
  return skipped(version) unless include_glyphs

  warn&.puts(ExperimentalWarning)

  pipeline = Glyphs::Pipeline.new(
    version: version,
    block_filter: block_filter,
    monolith_path: monolith_path,
  )
  specs = pipeline.build_specs(force: force)

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