Class: Fontisan::Commands::PackCommand
- Inherits:
-
Object
- Object
- Fontisan::Commands::PackCommand
- Defined in:
- lib/fontisan/commands/pack_command.rb
Overview
Command for packing multiple fonts into a TTC/OTC collection
This command provides CLI access to font collection creation functionality. It loads multiple font files and combines them into a single TTC (TrueType Collection) or OTC (OpenType Collection) file with shared table deduplication to save space. It also supports creating dfont (Apple Data Fork Font) suitcases.
Instance Method Summary collapse
-
#initialize(font_paths, options = {}) ⇒ PackCommand
constructor
Initialize pack command.
-
#run ⇒ Hash
Execute the pack command.
Constructor Details
#initialize(font_paths, options = {}) ⇒ PackCommand
Initialize pack command
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fontisan/commands/pack_command.rb', line 49 def initialize(font_paths, = {}) @font_paths = font_paths @options = @output_path = [:output] @format = [:format] ? parse_format([:format]) : nil @optimize = .fetch(:optimize, true) @analyze = .fetch(:analyze, false) @verbose = .fetch(:verbose, false) end |
Instance Method Details
#run ⇒ Hash
Execute the pack command
Loads all fonts, analyzes tables, and creates a TTC/OTC/dfont collection. Optionally displays analysis before building.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/fontisan/commands/pack_command.rb', line 76 def run puts "Loading #{@font_paths.size} fonts..." if @verbose # Load all fonts fonts = load_fonts # Auto-detect format if not specified @format ||= auto_detect_format(fonts) puts "Auto-detected format: #{@format}" if @verbose && !@options[:format] # Build collection based on format if @format == :dfont build_dfont(fonts) else build_ttc_otc(fonts) end rescue Fontisan::Error => e raise Fontisan::Error, "Collection packing failed: #{e.}" rescue StandardError => e raise Fontisan::Error, "Unexpected error during packing: #{e.}" end |