X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/ef7911fba9c330552599bc6eb9dc22606246dd7e..68b03397a0872d10d3627cea2b92ae36bd59183c:/font-optimizer/convert-eot.pl diff --git a/font-optimizer/convert-eot.pl b/font-optimizer/convert-eot.pl new file mode 100755 index 0000000..a5a1672 --- /dev/null +++ b/font-optimizer/convert-eot.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use lib 'ext/Font-TTF/lib'; +use Font::TTF::Font; +use Font::EOTWrapper; + +use Getopt::Long; + +main(); + +sub help { + print < \$verbose, + 'ttf-to-eot' => \$ttf_to_eot, + 'eot-to-ttf' => \$eot_to_ttf, + ) or help(); + + @ARGV == 2 or help(); + + my ($input_file, $output_file) = @ARGV; + + if ($ttf_to_eot and $eot_to_ttf) { + help(); + } + + if (not ($ttf_to_eot or $eot_to_ttf)) { + if ($input_file =~ /\.[ot]tf$/i and $output_file =~ /\.eot$/i) { + $ttf_to_eot = 1; + } elsif ($input_file =~ /\.eot$/i and $output_file =~ /\.[ot]tf$/i) { + $eot_to_ttf = 1; + } else { + help(); + } + } + + if ($ttf_to_eot) { + Font::EOTWrapper::convert($input_file, $output_file); + } elsif ($eot_to_ttf) { + Font::EOTWrapper::extract($input_file, $output_file); + } +}