Class: Ucode::Commands::Audit::FontCommand

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

Overview

ucode audit font PATH — audit a single font file or fontist-resolvable name. Writes the per-face directory tree under <output_root>/font_audit/<label>/.

Auto-detects collection sources (TTC/OTC/dfong) and falls through to collection-style emission in that case — one tree per face. For an explicit, intent-revealing form, use CollectionCommand.

Pure: Thor never touches this. Real work is delegated to Glyphs::RealFonts::FontLocator (resolve spec → path), Audit::FaceAuditor (build report), and Audit::Emitter::FaceDirectory (write tree).

Defined Under Namespace

Classes: FaceOutcome, Result

Instance Method Summary collapse

Instance Method Details

#call(spec, output_root:, label: nil, unicode_version: nil, verbose: false, with_glyphs: false, brief: false, browse: false, install: true, reference: nil, universal_set_root: nil, with_missing_glyph_pages: false) ⇒ Result

Parameters:

  • spec (String)

    font spec — direct path, or label=path, or a fontist formula name.

  • label (String, nil) (defaults to: nil)

    output label override. Defaults to the report's postscript_name, or the file basename.

  • unicode_version (String, nil) (defaults to: nil)

    baseline UCD version.

  • verbose (Boolean) (defaults to: false)

    emit per-codepoint detail chunks.

  • with_glyphs (Boolean) (defaults to: false)

    emit per-codepoint SVG chunks (no-op until TODO 20 wires the 4-tier resolver).

  • brief (Boolean) (defaults to: false)

    cheap-extractor-only mode.

  • output_root (String, Pathname)

    parent directory; the audit root is <output_root>/font_audit.

  • browse (Boolean) (defaults to: false)

    also write the HTML browsers.

  • install (Boolean) (defaults to: true)

    allow fontist install on miss.

  • reference (Ucode::Audit::CoverageReference, nil) (defaults to: nil)

    the baseline to compare against (TODO 25). When nil, defaults to UCD-only inside FaceAuditor.

  • universal_set_root (String, Pathname, nil) (defaults to: nil)

    forwarded to Emitter::FaceDirectory for the face browser's universal-set section (TODO 26).

  • with_missing_glyph_pages (Boolean) (defaults to: false)

    forward per-block standalone missing-glyph galleries (TODO 26).

Returns:



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ucode/commands/audit/font_command.rb', line 57

def call(spec, output_root:, label: nil, unicode_version: nil, verbose: false,
         with_glyphs: false, brief: false, browse: false,
         install: true, reference: nil,
         universal_set_root: nil, with_missing_glyph_pages: false)
  located = locate(spec, install: install)
  reports = Array(audit_faces(located.path, unicode_version: unicode_version,
                                            brief: brief, reference: reference))

  face_label = label || derived_face_label(reports.first, located)
  sanitized = sanitize(face_label)

  directory = Ucode::Audit::Emitter::FaceDirectory.new(
    output_root: output_root,
    verbose: verbose,
    with_glyphs: with_glyphs,
    emit_browser: browse,
    universal_set_root: universal_set_root,
    with_missing_glyph_pages: with_missing_glyph_pages,
  )

  face_outcomes, top_dir =
    if reports.one?
      emit_standalone(directory, sanitized, reports.first)
    else
      emit_collection(directory, sanitized, reports, output_root)
    end

  Result.new(spec: spec, label: face_label, output_dir: top_dir.to_s,
             faces: face_outcomes)
rescue StandardError => e
  Result.new(spec: spec, error: "#{e.class}: #{e.message}")
end