Class: Fontisan::StitcherCli

Inherits:
Thor
  • Object
show all
Defined in:
lib/fontisan/stitcher_cli.rb

Overview

CLI subcommand for multi-source font stitching.

fontisan stitch --source latin=PATH --source jp=PATH \
--output out.ttf \
--include-range latin=0x41-0x5A \
--include-range jp=0x3040-0x309F

Instance Method Summary collapse

Instance Method Details

#stitchObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fontisan/stitcher_cli.rb', line 27

def stitch
  stitcher = Stitcher.new

  options[:source].each do |spec|
    label, path = spec.split("=", 2)
    font = load_source(path)
    stitcher.add_source(label, font)
  end

  options[:include_range]&.each do |spec|
    label, range_str = spec.split("=", 2)
    lo, hi = parse_range(range_str)
    stitcher.include_range(lo..hi, from: label)
  end

  options[:include_codepoints]&.each do |spec|
    label, cps_str = spec.split("=", 2)
    cps = cps_str.split(",").map { |h| Integer(h) }
    stitcher.include_codepoints(cps, from: label)
  end

  stitcher.include_notdef(from: options[:notdef_from]) if options[:notdef_from]

  stitcher.write_to(options[:output], format: options[:to].to_sym)
  puts "wrote #{options[:output]} (#{File.size(options[:output])} bytes)"
end