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