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 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
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
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 89 90 91 |
# File 'lib/fontisan/commands/convert_command.rb', line 61 def initialize(font_path, = {}) super(font_path, ) # Convert string keys to symbols for Thor compatibility. All command # code reads @options with symbol keys (e.g., @options[:quiet]); # normalizing once at construction is cleaner than threading a # second opts hash alongside @options. @options = .transform_keys(&:to_sym) @output_path = @options[:output] # Parse target format @target_format = parse_target_format(@options[:to]) # Extract ConversionOptions if provided @conv_options = (@options) # Parse coordinates if string provided @coordinates = if @options[:coordinates] parse_coordinates(@options[:coordinates]) elsif @options[:instance_coordinates] @options[:instance_coordinates] end @instance_index = @options[:instance_index] @preserve_variation = @options[:preserve_variation] @preserve_hints = @options.fetch(:preserve_hints, false) @collection_target_format = @options.fetch(:target_format, "preserve").to_s @validate = !@options[:no_validate] end |
Instance Method Details
#run ⇒ Hash
Execute the conversion
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/fontisan/commands/convert_command.rb', line 98 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 |