5 # ./strip_font.rb -n 'ArphicUkaiSubsetForTagua' -i /usr/share/fonts/truetype/arphic/ukai.ttf \
6 # -o data/themes/figurines/ShogiTTF/arphic-ukai.ttf $(find data/ -ipath '*shogi*.lua')
16 $options = OptionParser.new do |opt|
17 opt.banner = "Usage: strip_font.rb [options] luafiles"
19 opt.on( '-n', '--name FONT_NAME', 'Output font name' ) do |name| font_name = name end
20 opt.on( '-i', '--input INPUT_FONT', 'Input font') do |file| input_file = file end
21 opt.on( '-o', '--output OUTPUT_FONT', 'Font to generate') do |file| output_file = file end
31 File.open(file) do |f|
33 content.scan(/(["'])0x([0-9a-fA-F]{4})\1/).each do |match|
34 #print(match.inspect+"\n")
35 selection.add "SelectMore(0u"+match[1]+");"
41 Open("#{input_file}");
42 #{selection.to_a.join("\n")}
44 DetachAndRemoveGlyphs();
45 SetFontNames("#{font_name}", "#{font_name}", "#{font_name}");
47 Generate("#{output_file}");
50 # FIXME: find a better way to workaround this command which does not work any more
51 #system("echo -en #{a.inspect} | fontforge -c")
53 system("echo -en #{a.inspect} >ff-script.pe")
54 system("fontforge -script ff-script.pe")
55 script("rm ff-script.pe")