git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
font: file ids and os grouping
[sheet.git]
/
tools
/
convert-ttf.pl
diff --git
a/tools/convert-ttf.pl
b/tools/convert-ttf.pl
index 3a7cc0e009809eb8f88629146f789123e5e0cfa3..95b26a085cb0ff9e4bfa335ece0710ac999409bf 100755
(executable)
--- a/
tools/convert-ttf.pl
+++ b/
tools/convert-ttf.pl
@@
-6,7
+6,8
@@
use warnings;
use Data::Dump 'pp';
use Font::TTF::Font;
use Data::Dump 'pp';
use Font::TTF::Font;
-my ($ttfname, $outfile) = @ARGV;
+my ($ttfuri, $outfile) = @ARGV;
+$ttfuri or die "usage error\n";
for ($outfile || ()) {
!-e $_ or die "Output file $outfile already exists\n";
for ($outfile || ()) {
!-e $_ or die "Output file $outfile already exists\n";
@@
-14,12
+15,23
@@
for ($outfile || ()) {
select $output;
}
select $output;
}
+my %FONTID = (
+ 'Times New Roman' => 'times',
+ 'DejaVu Sans' => 'dv ss',
+ 'DejaVu Serif' => 'dv serif',
+ 'Code2000' => 'c2k',
+ 'GNU Unifont' => 'guf',
+ 'Droid Sans' => 'droid',
+ 'Droid Serif' => 'droid serif',
+);
+
{
{
- my $ttf = Font::TTF::Font->open($ttf
name
)
- or die "Cannot open truetype in $ttf
name
: $!";
+ my $ttf = Font::TTF::Font->open($ttf
uri
)
+ or die "Cannot open truetype in $ttf
uri
: $!";
+ my $ttfname = ($ttfuri =~ m{([^/.]+) (?:[.]ttf)? \z}msx)[0];
my %meta = (
my %meta = (
-
filename => $ttfname
,
+
source => $ttfuri
,
name => $ttf->{name}->read->find_name(4) || $ttfname,
version => $ttf->{head}->{fontRevision},
date => (map {
name => $ttf->{name}->read->find_name(4) || $ttfname,
version => $ttf->{head}->{fontRevision},
date => (map {
@@
-29,6
+41,7
@@
for ($outfile || ()) {
}
} $ttf->{head}->getdate),
);
}
} $ttf->{head}->getdate),
);
+ $meta{id} = $FONTID{ $meta{name} } // lc $ttfname;
say pp(\%meta), ',';
my $support = $ttf->{cmap}->find_ms->{val};
say pp(\%meta), ',';
my $support = $ttf->{cmap}->find_ms->{val};