Class: Fontisan::Commands::ConvertCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Fontisan::Commands::ConvertCommand
- Defined in:
- lib/fontisan/commands/convert_command.rb
Overview
Command for converting fonts between formats
[‘ConvertCommand`](lib/fontisan/commands/convert_command.rb) provides CLI interface for font format conversion operations using the universal transformation pipeline. It supports:
-
Same-format operations (copy/optimize)
-
TTF ↔ OTF outline format conversion
-
Variable font operations (preserve/instance generation)
-
WOFF/WOFF2 compression
The command uses [‘TransformationPipeline`](lib/fontisan/pipeline/transformation_pipeline.rb) to orchestrate conversions with appropriate strategies.
Instance Method Summary collapse
-
#initialize(font_path, options = {}) ⇒ ConvertCommand
constructor
Initialize convert command.
-
#run ⇒ Hash
Execute the conversion.
Constructor Details
#initialize(font_path, options = {}) ⇒ ConvertCommand
Initialize convert command
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fontisan/commands/convert_command.rb', line 67 def initialize(font_path, = {}) super(font_path, ) # Convert string keys to symbols for Thor compatibility opts = .transform_keys(&:to_sym) @output_path = opts[:output] # Parse target format @target_format = parse_target_format(opts[:to]) # Extract ConversionOptions if provided @conv_options = (opts) # Parse coordinates if string provided @coordinates = if opts[:coordinates] parse_coordinates(opts[:coordinates]) elsif opts[:instance_coordinates] opts[:instance_coordinates] end @instance_index = opts[:instance_index] @preserve_variation = opts[:preserve_variation] @preserve_hints = opts.fetch(:preserve_hints, false) @collection_target_format = opts.fetch(:target_format, "preserve").to_s @validate = !opts[:no_validate] end |
Instance Method Details
#run ⇒ Hash
Execute the conversion
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/fontisan/commands/convert_command.rb', line 100 def run # Check if input is a collection if collection_file? convert_collection else convert_single_font end rescue ArgumentError # Let ArgumentError propagate for validation errors raise rescue StandardError => e raise Error, "Conversion failed: #{e.}" end |