git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
apl: click to expand all descriptions
[sheet.git]
/
tools
/
mkttfinfo
diff --git
a/tools/mkttfinfo
b/tools/mkttfinfo
index f69bbbb95e79adf89da39c2de64cb2420c99034b..3dfd8b75330483fd345ca20e5123875fae361766 100755
(executable)
--- a/
tools/mkttfinfo
+++ b/
tools/mkttfinfo
@@
-5,12
+5,27
@@
use warnings;
use Data::Dump 'pp';
use Font::TTF::Font;
use Data::Dump 'pp';
use Font::TTF::Font;
+use Getopt::Long;
+
+our $VERSION = '1.00';
+
+GetOptions(my %opt,
+ 'verbose|v!',
+);
my ($ttfuri, $outfile) = @ARGV;
$ttfuri or die "usage error\n";
my ($ttfuri, $outfile) = @ARGV;
$ttfuri or die "usage error\n";
+my $fontinc = $ENV{FONTINC} // '~/.fonts,/usr/share/fonts/truetype/*';
+if (!-e $ttfuri) {
+ my $found = (grep {-e} glob "{$fontinc}/$ttfuri")[0] or do {
+ warn "font not found: $ttfuri\n";
+ exit 1;
+ };
+ $ttfuri = $found;
+}
+
for ($outfile || ()) {
for ($outfile || ()) {
- !-e $_ or die "Output file $outfile already exists\n";
open my $output, '>', $_ or die "Cannot write to $outfile: $!\n";
select $output;
}
open my $output, '>', $_ or die "Cannot write to $outfile: $!\n";
select $output;
}
@@
-48,10
+63,12
@@
my %FONTID = (
} $ttf->{head}->getdate),
);
$meta{id} = $FONTID{ $meta{name} } // lc $ttfname;
} $ttf->{head}->getdate),
);
$meta{id} = $FONTID{ $meta{name} } // lc $ttfname;
- say pp(\%meta), ',';
+ say "# automatically generated by $0";
+ say '+', pp(\%meta), ',';
my $support = $ttf->{cmap}->find_ms->{val};
my $support = $ttf->{cmap}->find_ms->{val};
- warn scalar keys %$support, " characters read from $ttfname\n";
+ warn scalar keys %$support, " characters read from $ttfname\n"
+ if $opt{verbose};
say pp(sort { $a <=> $b } keys %$support);
}
say pp(sort { $a <=> $b } keys %$support);
}
@@
-63,7
+80,7
@@
mkttfinfo - Extract character coverage and metadata in TrueType font
=head1 SYNOPSIS
=head1 SYNOPSIS
- mkttfinfo <font.ttf> [<output.inc.pl>]
+ mkttfinfo
[-v]
<font.ttf> [<output.inc.pl>]
=head1 AUTHOR
=head1 AUTHOR