font: mkttfinfo: find font files in common locations
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 19 Feb 2015 16:00:00 +0000 (17:00 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 19 Feb 2015 23:21:52 +0000 (00:21 +0100)
Integrate search logic in convert-allfonts so it can be replaced by
make rules.

tools/convert-allfonts
tools/mkttfinfo

index 54322f54d8aa000d688773c24597da5f87c8fc35..74d2518dae291faecf943e7c95a571b84450e4fc 100755 (executable)
@@ -6,12 +6,8 @@ cd $(dirname "$0")
 CONVBIN=./mkttfinfo
 OUTDIR=../ttfsupport
 
-INC=~/.fonts/\ /usr/share/fonts/truetype/
-INC=$INC\ ../data/macfonts/
-
 convfont () {
-       find $INC -name "$1" -print -quit |
-       xargs -i $CONVBIN {} $OUTDIR/$2.inc.pl
+       $CONVBIN "$1" $OUTDIR/$2.inc.pl
 }
 
 # /usr/share/fonts/truetype/msttcorefonts
index 864873aceb6824db6df194ab606dacc0c6e95793..8593be60dd0df6dd739121e54b1bf62f6d3c937d 100755 (executable)
@@ -9,6 +9,15 @@ use Font::TTF::Font;
 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 || ()) {
        open my $output, '>', $_ or die "Cannot write to $outfile: $!\n";
        select $output;