trfn: decide character type based on the previous glyphs
[neatmkfn.git] / gen.sh
blobab88ad701b1ca8d82334328fe5fd37d278062e68
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 $FP/$3 | ./mktrfn $4 -a -b -r$RES -t $1 -p $2 >$TP/$1
30 # converting otf and ttf fonts; needs fontforge or lcdf-typetools
31 function otfconv
33 FN="$1"
34 AFM="/tmp/.mktrfn.afm"
35 if [ "$USELCDF" == "1" ]; then
36 cat $2 | cfftot1 2>/dev/null | t1rawafm >$AFM 2>/dev/null
37 else
38 echo -e "Open (\"$2\")\nGenerate(\"$AFM\")" | fontforge >/dev/null 2>&1
40 cat $AFM | ./mktrfn -b -a -r$RES -t $FN -p $FN -k50 | \
41 sed "/^ligatures /s/ $LIGIGN//g" >$TP/$FN
42 rm $AFM
45 # The standard fonts
46 afmconv R Times-Roman n021003l.afm
47 afmconv I Times-Italic n021023l.afm
48 afmconv B Times-Bold n021004l.afm
49 afmconv BI Times-BoldItalic n021024l.afm
50 afmconv S Symbol s050000l.afm -s
51 afmconv S1 Times-Roman n021003l.afm -s
52 afmconv AR AvantGarde-Book a010013l.afm
53 afmconv AI AvantGarde-BookOblique a010033l.afm
54 afmconv AB AvantGarde-Demi a010015l.afm
55 afmconv AX AvantGarde-DemiOblique a010035l.afm
56 afmconv H Helvetica n019043l.afm
57 afmconv HI Helvetica-Oblique n019063l.afm
58 afmconv HB Helvetica-Bold n019044l.afm
59 afmconv HX Helvetica-BoldOblique n019064l.afm
60 afmconv Hr Helvetica-Narrow n019043l.afm
61 afmconv Hi Helvetica-Narrow-Oblique n019063l.afm
62 afmconv Hb Helvetica-Narrow-Bold n019044l.afm
63 afmconv Hx Helvetica-Narrow-BoldOblique n019064l.afm
64 afmconv KR Bookman-Light b018012l.afm
65 afmconv KI Bookman-LightItalic b018032l.afm
66 afmconv KB Bookman-Demi b018015l.afm
67 afmconv KX Bookman-DemiItalic b018035l.afm
68 afmconv NR NewCenturySchlbk-Roman c059013l.afm
69 afmconv NI NewCenturySchlbk-Italic c059033l.afm
70 afmconv NB NewCenturySchlbk-Bold c059016l.afm
71 afmconv NX NewCenturySchlbk-BoldItalic c059036l.afm
72 afmconv PA Palatino-Roman p052003l.afm
73 afmconv PR Palatino-Roman p052003l.afm
74 afmconv PI Palatino-Italic p052023l.afm
75 afmconv PB Palatino-Bold p052004l.afm
76 afmconv PX Palatino-BoldItalic p052024l.afm
77 afmconv C Courier n022003l.afm
78 afmconv CO Courier n022003l.afm
79 afmconv CW Courier n022003l.afm
80 afmconv CI Courier-Oblique n022023l.afm
81 afmconv CB Courier-Bold n022004l.afm
82 afmconv CX Courier-BoldOblique n022024l.afm
83 afmconv ZI ZapfChancery-MediumItalic z003034l.afm
84 afmconv ZD ZapfDingbats d050000l.afm
86 # For otf and ttf files, we assume the postscript name of the font
87 # can be obtained by dropping its extension. Otherwise, remove the
88 # -p argument of mktrfn in otfconv function.
90 for f in $FP/*.otf $FP/*.ttf
92 FN="`basename $f .otf`"
93 FN="`basename $FN .ttf`"
94 echo $FN
95 otfconv $FN $f
96 done