From: Mischa POSLAWSKY Date: Thu, 19 Feb 2015 16:00:00 +0000 (+0100) Subject: font: mkttfinfo: find font files in common locations X-Git-Tag: v1.7~140 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/0dbd7ab1eadd5fe5ba3cbc05299f9ff405b59c8a font: mkttfinfo: find font files in common locations Integrate search logic in convert-allfonts so it can be replaced by make rules. --- diff --git a/tools/convert-allfonts b/tools/convert-allfonts index 54322f5..74d2518 100755 --- a/tools/convert-allfonts +++ b/tools/convert-allfonts @@ -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 diff --git a/tools/mkttfinfo b/tools/mkttfinfo index 864873a..8593be6 100755 --- a/tools/mkttfinfo +++ b/tools/mkttfinfo @@ -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;