Class: Fontisan::Commands::InstanceCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/fontisan/commands/instance_command.rb

Overview

CLI command for generating static font instances from variable fonts

Provides command-line interface for:

  • Instancing at specific coordinates

  • Using named instances

  • Converting output format during instancing

  • Listing available instances

  • Validation before generation

  • Dry-run mode for previewing

  • Progress tracking

  • Parallel batch generation

Examples:

Instance at coordinates

fontisan instance variable.ttf --wght=700 --output=bold.ttf

Instance with validation

fontisan instance variable.ttf --wght=700 --validate --output=bold.ttf

Dry-run to preview

fontisan instance variable.ttf --wght=700 --dry-run

Instance with progress

fontisan instance variable.ttf --wght=700 --progress --output=bold.ttf

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize, #run

Constructor Details

This class inherits a constructor from Fontisan::Commands::BaseCommand

Instance Method Details

#execute(input_path, options = {}) ⇒ Object

Instance a variable font at specified coordinates

Parameters:

  • input_path (String)

    Path to variable font file



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
# File 'lib/fontisan/commands/instance_command.rb', line 40

def execute(input_path, options = {})
  # Load variable font
  font = load_font(input_path)

  # Validate font if requested
  validate_font(font) if options[:validate]

  # Create instancer
  instancer = Variable::Instancer.new(font)

  # Handle list-instances option
  if options[:list_instances]
    list_instances(instancer)
    return
  end

  # Handle dry-run mode
  if options[:dry_run]
    preview_instance(instancer, options)
    return
  end

  # Determine output path
  output_path = determine_output_path(input_path, options)

  # Generate instance
  if options[:named_instance]
    instance_named(instancer, options[:named_instance], output_path,
                   options)
  else
    instance_coords(instancer, extract_coordinates(options), output_path,
                    options)
  end

  puts "Static font instance written to: #{output_path}"
rescue VariationError => e
  $stderr.puts "Variation Error: #{e.detailed_message}"
  exit 1
rescue StandardError => e
  $stderr.puts "Error: #{e.message}"
  $stderr.puts e.backtrace.first(5).join("\n") if options[:verbose]
  exit 1
end