otf: clean up
[neatmkfn.git] / gen.sh
blob04c12ac4c8ef0b0c311b27fe5110396678845d8c
1 #!/bin/sh
2 # Generate a neatroff output device
4 # ghostscript font directory; it may contain otf and ttf files also
5 FP="/mnt/file/gs/fonts"
6 # output device directory
7 TP="/root/queue/devutf"
8 # device resolution
9 RES="720"
10 # pattern of ligatures to ignore
11 LIGIGN="\(ct\|st\|sp\|Rp\)"
12 # use lcdf-typetools instead of fontforge for otf files
13 USELCDF="0"
15 # creating DESC
16 mkdir -p $TP
17 echo "fonts 10 R I B BI CW H HI HB S1 S" >$TP/DESC
18 echo "res $RES" >>$TP/DESC
19 echo "hor 1" >>$TP/DESC
20 echo "ver 1" >>$TP/DESC
21 echo "unitwidth 10" >>$TP/DESC
23 # afmconv troff_name postscript_name font_filename
24 function afmconv
26 echo $1
27 cat $3 | ./mkfn $4 -a -b -r$RES -t $1 -p $2 | \
28 sed "/^ligatures /s/ $LIGIGN//g" >$TP/$1
31 # converting otf and ttf fonts; needs fontforge or lcdf-typetools
32 function otfconv
34 FN="$1"
35 AFM="/tmp/.neatmkfn.afm"
36 if [ "$USELCDF" == "1" ]; then
37 cat $2 | cfftot1 2>/dev/null | t1rawafm >$AFM 2>/dev/null
38 else
39 echo -e "Open(\"$2\")\nGenerate(\"$AFM\")" | fontforge >/dev/null 2>&1
41 cat $AFM | ./mkfn -b -a -r$RES -t $FN -p $FN -k5 | \
42 sed "/^ligatures /s/ $LIGIGN//g" >$TP/$FN
43 rm $AFM
46 # The standard fonts
47 afmconv R Times-Roman $FP/n021003l.afm
48 afmconv I Times-Italic $FP/n021023l.afm
49 afmconv B Times-Bold $FP/n021004l.afm
50 afmconv BI Times-BoldItalic $FP/n021024l.afm
51 afmconv S Symbol $FP/s050000l.afm -s
52 afmconv S1 Times-Roman $FP/n021003l.afm -s
53 afmconv AR AvantGarde-Book $FP/a010013l.afm
54 afmconv AI AvantGarde-BookOblique $FP/a010033l.afm
55 afmconv AB AvantGarde-Demi $FP/a010015l.afm
56 afmconv AX AvantGarde-DemiOblique $FP/a010035l.afm
57 afmconv H Helvetica $FP/n019003l.afm
58 afmconv HI Helvetica-Oblique $FP/n019023l.afm
59 afmconv HB Helvetica-Bold $FP/n019004l.afm
60 afmconv HX Helvetica-BoldOblique $FP/n019024l.afm
61 afmconv Hr Helvetica-Narrow $FP/n019043l.afm
62 afmconv Hi Helvetica-Narrow-Oblique $FP/n019063l.afm
63 afmconv Hb Helvetica-Narrow-Bold $FP/n019044l.afm
64 afmconv Hx Helvetica-Narrow-BoldOblique $FP/n019064l.afm
65 afmconv KR Bookman-Light $FP/b018012l.afm
66 afmconv KI Bookman-LightItalic $FP/b018032l.afm
67 afmconv KB Bookman-Demi $FP/b018015l.afm
68 afmconv KX Bookman-DemiItalic $FP/b018035l.afm
69 afmconv NR NewCenturySchlbk-Roman $FP/c059013l.afm
70 afmconv NI NewCenturySchlbk-Italic $FP/c059033l.afm
71 afmconv NB NewCenturySchlbk-Bold $FP/c059016l.afm
72 afmconv NX NewCenturySchlbk-BoldItalic $FP/c059036l.afm
73 afmconv PA Palatino-Roman $FP/p052003l.afm
74 afmconv PR Palatino-Roman $FP/p052003l.afm
75 afmconv PI Palatino-Italic $FP/p052023l.afm
76 afmconv PB Palatino-Bold $FP/p052004l.afm
77 afmconv PX Palatino-BoldItalic $FP/p052024l.afm
78 afmconv C Courier $FP/n022003l.afm
79 afmconv CO Courier $FP/n022003l.afm
80 afmconv CW Courier $FP/n022003l.afm
81 afmconv CI Courier-Oblique $FP/n022023l.afm
82 afmconv CB Courier-Bold $FP/n022004l.afm
83 afmconv CX Courier-BoldOblique $FP/n022024l.afm
84 afmconv ZI ZapfChancery-MediumItalic $FP/z003034l.afm
85 afmconv ZD ZapfDingbats $FP/d050000l.afm
87 # For otf and ttf files, we assume the postscript name of the font
88 # can be obtained by dropping its extension. Otherwise, remove the
89 # -p argument of mkfn in otfconv function.
91 for f in $FP/*.otf $FP/*.ttf
93 if [ -e "$f" ]; then
94 FN="`basename $f .otf`"
95 FN="`basename $FN .ttf`"
96 echo $FN
97 otfconv $FN $f
99 done