X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/e9aeedc51047d8d5e9e45c5253c776f8994da965..3a0c83394d5783715fab2be29fa1a9cfc3574e28:/src/librarian/font-optimizer/obfuscate-font.pl diff --git a/src/librarian/font-optimizer/obfuscate-font.pl b/src/librarian/font-optimizer/obfuscate-font.pl deleted file mode 100755 index 0850426..0000000 --- a/src/librarian/font-optimizer/obfuscate-font.pl +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use lib 'ext/Font-TTF/lib'; -use Font::TTF::Font; - -use Getopt::Long; - -main(); - -sub help { - print <{name}{strings}[$id]; - for my $plat (0..$#$str) { - next unless $str->[$plat]; - for my $enc (0..$#{$str->[$plat]}) { - next unless $str->[$plat][$enc]; - for my $lang (keys %{$str->[$plat][$enc]}) { - next unless exists $str->[$plat][$enc]{$lang}; - if ($verbose) { - print "Setting string $_ (plat $plat, enc $enc) to \"$val\"\n"; - } - $str->[$plat][$enc]{$lang} = $val; - } - } - } -} - -sub strip_names { - my ($font, $verbose) = @_; - - print "Stripping names\n" if $verbose; - - $font->{name}->read; - - for (16, 17, 18) { - if ($verbose and $font->{name}{strings}[$_]) { - print "Deleting string $_\n"; - } - $font->{name}{strings}[$_] = undef; - } - - for (1, 3, 5) { - set_name($font, $_, '', $verbose); - } - - for (4, 6) { - set_name($font, $_, '-', $verbose); - } -} - -sub strip_post { - my ($font, $verbose) = @_; - - print "Stripping post table\n" if $verbose; - - # Replace it with the minimum necessary to work in browsers - # (particularly Opera is a bit fussy) - my $data = pack NNnnNNNNN => 0x10000, 0, 0, 0, 0, 0, 0, 0, 0; - $font->{post} = new Font::TTF::Table(dat => $data); -} - -sub main { - my $verbose = 0; - my $all; - my $names; - my $post; - - my $result = GetOptions( - 'verbose' => \$verbose, - 'all' => \$all, - 'names' => \$names, - 'post' => \$post, - ) or help(); - - @ARGV == 2 or help(); - - if (not ($all or $names or $post)) { help(); } - - my ($input_file, $output_file) = @ARGV; - - my $font = Font::TTF::Font->open($input_file) or die "Error opening $input_file: $!"; - - strip_names($font, $verbose) if $all or $names; - strip_post($font, $verbose) if $all or $post; - - $font->out($output_file); - - $font->release; -}