From 39dbea21055688c0d6675d7aed4828c8b55bbf94 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 14 Feb 2015 20:36:38 +0100 Subject: [PATCH] font: convert-allfonts: generic search Drop font-specific search options, so a simple shell script can suffice (which in turn may even be replaced by make rules later on). --- tools/convert-allfonts | 122 +++++++++++++---------------------------- 1 file changed, 37 insertions(+), 85 deletions(-) diff --git a/tools/convert-allfonts b/tools/convert-allfonts index 9d75e06..54322f5 100755 --- a/tools/convert-allfonts +++ b/tools/convert-allfonts @@ -1,98 +1,50 @@ -#!/usr/bin/env perl -use strict; -use warnings; -no warnings 'syntax'; # if assignment +#!/bin/sh +set -u -use List::Util 'first'; -use File::Basename 'dirname'; +cd $(dirname "$0") -chdir dirname $0; +CONVBIN=./mkttfinfo +OUTDIR=../ttfsupport -my $convbin = './mkttfinfo'; -my $outdir = '../ttfsupport'; -my @ttfpath = ('~/.fonts', '../data/osx-fonts'); # local fallbacks +INC=~/.fonts/\ /usr/share/fonts/truetype/ +INC=$INC\ ../data/macfonts/ -if (my $mspath = '/usr/share/fonts/truetype/msttcorefonts') { - if (my $src = first { -e } map { glob "$_/Verdana.ttf" } $mspath, @ttfpath) { - system $convbin, $src, "$outdir/verdana.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/Times_New_Roman.ttf" } $mspath, @ttfpath) { - system $convbin, $src, "$outdir/times.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/Arial.ttf" } $mspath, @ttfpath) { - system $convbin, $src, "$outdir/arial.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/Courier_New.ttf" } $mspath, @ttfpath) { - system $convbin, $src, "$outdir/courier.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/Comic_Sans_MS.ttf" } $mspath, @ttfpath) { - system $convbin, $src, "$outdir/comic.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/Georgia.ttf" } $mspath, @ttfpath) { - system $convbin, $src, "$outdir/georgia.inc.pl"; - } +convfont () { + find $INC -name "$1" -print -quit | + xargs -i $CONVBIN {} $OUTDIR/$2.inc.pl } -if (my $ampath = '/usr/share/fonts/truetype/macfonts') { - if (my $src = first { -e } map { glob "$_/Lucida?Grande.ttf" } $ampath, @ttfpath) { - system $convbin, $src, "$outdir/lucida.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/AppleGaramond.ttf" } $ampath, @ttfpath) { - system $convbin, $src, "$outdir/garamond.inc.pl"; - } -} +# /usr/share/fonts/truetype/msttcorefonts +convfont Verdana.ttf verdana +convfont Times_New_Roman.ttf times +convfont Arial.ttf arial +convfont Courier_New.ttf courier +convfont Comic_Sans_MS.ttf comic +convfont Georgia.ttf georgia -if (my $dvpath = '/usr/share/fonts/truetype/ttf-dejavu') { - if (my $src = first { -e } map { glob "$_/DejaVuSans.ttf" } $dvpath, @ttfpath) { - system $convbin, $src, "$outdir/dvsans.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/DejaVuSerif.ttf" } $dvpath, @ttfpath) { - system $convbin, $src, "$outdir/dvserif.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/DejaVuSansMono.ttf" } $dvpath, @ttfpath) { - system $convbin, $src, "$outdir/dvmono.inc.pl"; - } -} +convfont 'arial*uni*.ttf' ariuni -if (my $gdpath = '/usr/share/fonts/truetype/droid') { - if (my $src = first { -e } map { glob "$_/DroidSans.ttf" } $gdpath, @ttfpath) { - system $convbin, $src, "$outdir/droid.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/DroidSerif.ttf" } $gdpath, @ttfpath) { - system $convbin, $src, "$outdir/droidserif.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/DroidSansMono.ttf" } $gdpath, @ttfpath) { - system $convbin, $src, "$outdir/droidmono.inc.pl"; - } -} +# ../data/macfonts +convfont Lucida\?Grande.ttf lucida +convfont AppleGaramond.ttf garamond -if (my $grpath = '/usr/share/fonts/truetype/roboto') { - if (my $src = first { -e } map { glob "$_/Roboto-Regular.ttf" } $grpath, @ttfpath) { - system $convbin, $src, "$outdir/roboto.inc.pl"; - } -} +# /usr/share/fonts/truetype/ttf-dejavu +convfont DejaVuSans.ttf dvsans +convfont DejaVuSerif.ttf dvserif +convfont DejaVuSansMono.ttf dvmono -if (my $gnpath = '/usr/share/fonts/truetype/noto') { - if (my $src = first { -e } map { glob "$_/NotoSans-Regular.ttf" } $gnpath, @ttfpath) { - system $convbin, $src, "$outdir/noto.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/NotoSerif-Regular.ttf" } $gnpath, @ttfpath) { - system $convbin, $src, "$outdir/noto.inc.pl"; - } -} +# /usr/share/fonts/truetype/droid +convfont DroidSans.ttf droid +convfont DroidSerif.ttf droidserif +convfont DroidSansMono.ttf droidmono +# /usr/share/fonts/truetype/roboto +convfont Roboto-Regular.ttf roboto +# /usr/share/fonts/truetype/noto +convfont NotoSans-Regular.ttf noto +convfont NotoSerif-Regular.ttf notoserif -{ - if (my $src = first { -e } map { glob "$_/code2000.ttf" } @ttfpath) { - system $convbin, $src, "$outdir/c2k.inc.pl"; - } - if (my $src = first { -e } map { glob "$_/arial*uni*.ttf" } @ttfpath) { - system $convbin, $src, "$outdir/ariuni.inc.pl"; - } -} +# /usr/share/fonts/truetype/unifont +convfont unifont.ttf unifont -if (my $gupath = '/usr/share/fonts/truetype/unifont') { - if (my $src = first { -e } map { glob "$_/unifont.ttf" } $gupath, @ttfpath) { - system $convbin, $src, "$outdir/unifont.inc.pl"; - } -} +convfont code2000.ttf c2k -- 2.30.0