gen.sh: limit the number of scripts to include
[neatmkfn.git] / gen.sh
blobdd1cb4dcf3b6b0b988f1df2573d68ce4192f4a29
1 #!/bin/sh
2 # Generate a neatroff output device
4 FP="/path/to/gs/fonts" # ghostscript fonts directory; should be in GS_FONTPATH
5 TP="/path/to/font/devutf" # output device directory
6 RES="720" # device resolution
7 SCR="-Slatn,arab" # scripts to include
8 LIGIGN="\(ct\|st\|sp\|Rp\)" # pattern of ligatures to ignore
10 test -n "$1" && FP="$1"
11 test -n "$2" && TP="$2"
13 # creating DESC
14 mkdir -p $TP
15 echo "fonts 10 R I B BI CW H HI HB S1 S" >$TP/DESC
16 echo "res $RES" >>$TP/DESC
17 echo "hor 1" >>$TP/DESC
18 echo "ver 1" >>$TP/DESC
19 echo "unitwidth 10" >>$TP/DESC
21 # afmconv troff_name font_path extra_mktrfn_options
22 afmconv()
24 echo $1
25 cat $2 | ./mkfn -a -b -r$RES -t "$1" $3 $4 $5 $6 $7 | \
26 sed "/^ligatures /s/ $LIGIGN//g" >$TP/$1
29 # ttfconv troff_name font_path extra_mktrfn_options
30 ttfconv()
32 echo $1
33 cat $2 | ./mkfn -b -l -o -r$RES $SCR -t $1 $3 $4 $5 $6 $7 | \
34 sed "/^ligatures /s/ $LIGIGN//g" >$TP/$1
37 # otfconv troff_name font_path extra_mktrfn_options
38 otfconv()
40 TTF="/tmp/.neatmkfn.ttf"
41 # convert the OTF file to TTF using fontforge
42 fontforge -lang=ff -c "Open(\"$2\"); Generate(\"$TTF\");" >/dev/null 2>&1
43 ttfconv $1 $TTF $3 $4 $5 $6 $7
44 rm $TTF
47 # The standard fonts
48 afmconv R $FP/n021003l.afm -pTimes-Roman
49 afmconv I $FP/n021023l.afm -pTimes-Italic
50 afmconv B $FP/n021004l.afm -pTimes-Bold
51 afmconv BI $FP/n021024l.afm -pTimes-BoldItalic
52 afmconv S $FP/s050000l.afm -pSymbol -s
53 afmconv S1 $FP/n021003l.afm -pTimes-Roman -s
54 afmconv AR $FP/a010013l.afm -pAvantGarde-Book
55 afmconv AI $FP/a010033l.afm -pAvantGarde-BookOblique
56 afmconv AB $FP/a010015l.afm -pAvantGarde-Demi
57 afmconv AX $FP/a010035l.afm -pAvantGarde-DemiOblique
58 afmconv H $FP/n019003l.afm -pHelvetica
59 afmconv HI $FP/n019023l.afm -pHelvetica-Oblique
60 afmconv HB $FP/n019004l.afm -pHelvetica-Bold
61 afmconv HX $FP/n019024l.afm -pHelvetica-BoldOblique
62 afmconv Hr $FP/n019043l.afm -pHelvetica-Narrow
63 afmconv Hi $FP/n019063l.afm -pHelvetica-Narrow-Oblique
64 afmconv Hb $FP/n019044l.afm -pHelvetica-Narrow-Bold
65 afmconv Hx $FP/n019064l.afm -pHelvetica-Narrow-BoldOblique
66 afmconv KR $FP/b018012l.afm -pBookman-Light
67 afmconv KI $FP/b018032l.afm -pBookman-LightItalic
68 afmconv KB $FP/b018015l.afm -pBookman-Demi
69 afmconv KX $FP/b018035l.afm -pBookman-DemiItalic
70 afmconv NR $FP/c059013l.afm -pNewCenturySchlbk-Roman
71 afmconv NI $FP/c059033l.afm -pNewCenturySchlbk-Italic
72 afmconv NB $FP/c059016l.afm -pNewCenturySchlbk-Bold
73 afmconv NX $FP/c059036l.afm -pNewCenturySchlbk-BoldItalic
74 afmconv PA $FP/p052003l.afm -pPalatino-Roman
75 afmconv PR $FP/p052003l.afm -pPalatino-Roman
76 afmconv PI $FP/p052023l.afm -pPalatino-Italic
77 afmconv PB $FP/p052004l.afm -pPalatino-Bold
78 afmconv PX $FP/p052024l.afm -pPalatino-BoldItalic
79 afmconv C $FP/n022003l.afm -pCourier
80 afmconv CO $FP/n022003l.afm -pCourier
81 afmconv CW $FP/n022003l.afm -pCourier
82 afmconv CI $FP/n022023l.afm -pCourier-Oblique
83 afmconv CB $FP/n022004l.afm -pCourier-Bold
84 afmconv CX $FP/n022024l.afm -pCourier-BoldOblique
85 afmconv ZI $FP/z003034l.afm -pZapfChancery-MediumItalic
86 afmconv ZD $FP/d050000l.afm -pZapfDingbats
88 # The first argument of afmconv, ttfconv, and otfconv is the troff
89 # name of the font and their second argument is its path. Any other
90 # argument is passed to mkfn directly. The postscript names of the
91 # fonts are inferred from the fonts themselves To change that, you
92 # can specify their names via the -p argument of *conv functions.
94 find $FP/ -name '*.afm' | while read FN
96 afmconv `basename $FN .afm` $FN
97 done
99 find $FP/ -name '*.ttf' | while read FN
101 ttfconv `basename $FN .ttf` $FN
102 done
104 find $FP/ -name '*.otf' | while read FN
106 otfconv `basename $FN .otf` $FN
107 done