chiark / gitweb /
build system
[xfonts-traditional] / mkrules
1 #!/bin/bash
2 set -e
3 set -o pipefail
4 rm -f rules/foundries
5 rm -f rules/*.rules rules/foundries.new
6
7 chars () {
8         for c in $rest; do
9                 ord=`perl -e 'print ord($ARGV[0]),"\n" or die $!' "$c"`
10                 ./printrule >&3 "$bad" "$good" $height \
11                         "^ENCODING $ord$" $partial "$c"
12         done
13 }
14
15 while read keyword rest; do
16         case "$keyword" in
17         '#'|'') continue ;;
18         pcf)
19                 pcf=$rest
20                 for f in good bad; do
21                         out=$f/$pcf.bdf
22                         zcat $f/$pcf.pcf.gz | pcf2bdf >$out
23                         eval "$f=\$out"
24                 done
25                 ;;
26         rules)
27                 newfoundry=$rest
28                 eval `perl -ne '
29                         next unless s/^BBX\s+//;
30                         s/\s+$//;
31                         s/\s+/,/g;
32                         s/[-+]?\b\d+\b/ sprintf "%d", $& /ge;
33                         m/^\d+\,(\d+)\b/ or die;
34                         print "key=$_; height=$1\n" or die $!;
35                         exit;
36                 ' <$good`
37                 oldfoundry=`perl -ne '
38                         next unless s/^FOUNDRY\s+\"?//;
39                         s/\"?\s+$//;
40                         print or die $!;
41                         exit;
42                 ' <$good`
43                 printf "%s %s" "$oldfoundry" "$newfoundry" >>rules/foundries.new
44                 exec 3>rules/$newfoundry,$key.rules
45                 echo >&3 '# -*- perl -*-'
46                 echo >&3 '# autogenerated by mkrules'
47                 echo >&3 'sub {'
48                 ;;
49         endrules)
50                 echo >&3 '}'
51                 exec 3</dev/null
52                 ;;
53         entire)
54                 partial=0
55                 chars
56                 ;;
57         partial)
58                 partial=1
59                 chars
60                 ;;
61         *)
62                 echo >&2 "??? $keyword"
63                 exit 1
64                 ;;
65         esac
66 done
67
68 mv rules/foundries.new rules/foundries