trfn_ch.h: fix ws digraph mapping
[neatmkfn.git] / gen.sh
blob8bffe86fcfaeb4bdc58d058ca9725d4715c9d953
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 CR HR 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() {
23 echo $1
24 T1="`dirname \"$2\"`/`basename \"$2\" .afm`.t1"
25 test -f "$T1" || T1="`dirname \"$2\"`/`basename \"$2\" .afm`.pfa"
26 test -f "$T1" || T1="`dirname \"$2\"`/`basename \"$2\" .afm`.pfb"
27 cat "$2" | ./mkfn -a -b -r$RES -t$1 -f "$T1" $3 $4 $5 $6 $7 | \
28 sed "/^ligatures /s/ $LIGIGN//g" >"$TP/$1"
31 # ttfconv troff_name font_path extra_mktrfn_options
32 ttfconv() {
33 echo $1
34 cat "$2" | ./mkfn -b -l -o -r$RES $SCR -t$1 -f "$2" $3 $4 $5 $6 $7 | \
35 sed "/^ligatures /s/ $LIGIGN//g" >"$TP/$1"
38 # otfconv troff_name font_path extra_mktrfn_options
39 otfconv() {
40 TTF="/tmp/.neatmkfn.ttf"
41 if ! command -v fontforge >/dev/null; then
42 echo "Fontforge is needed to convert OTF files to TTF!"
43 return 1
45 fontforge -lang=ff -c "Open(\"$2\"); Generate(\"$TTF\");" >/dev/null 2>&1
46 ttfconv "$1" $TTF $3 $4 $5 $6 $7
47 rm $TTF
50 # stdfont troff_name gs_font urw_font extra_mktrfn_options
51 stdfont() {
52 FN="$2"
53 test -f "$FN" || FN="$3"
54 test -f "$FN" || echo "$0: Font <$3> not found!" >&2
55 test -f "$FN" || exit 1
56 afmconv $1 "$FN" $4 $5 $6 $7 $8 $9
59 # The standard fonts; ghostscriptfonts or urw-core35
60 stdfont R "$FP/n021003l.afm" "$FP/NimbusRoman-Regular.afm" -pTimes-Roman
61 stdfont I "$FP/n021023l.afm" "$FP/NimbusRoman-Italic.afm" -pTimes-Italic
62 stdfont B "$FP/n021004l.afm" "$FP/NimbusRoman-Bold.afm" -pTimes-Bold
63 stdfont BI "$FP/n021024l.afm" "$FP/NimbusRoman-BoldItalic.afm" -pTimes-BoldItalic
64 stdfont S "$FP/s050000l.afm" "$FP/StandardSymbolsPS.afm" -pSymbol -s
65 stdfont S1 "$FP/n021003l.afm" "$FP/NimbusRoman-Regular.afm" -pTimes-Roman -s
66 stdfont AR "$FP/a010013l.afm" "$FP/URWGothic-Book.afm" -pAvantGarde-Book
67 stdfont AI "$FP/a010033l.afm" "$FP/URWGothic-BookOblique.afm" -pAvantGarde-BookOblique
68 stdfont AB "$FP/a010015l.afm" "$FP/URWGothic-Demi.afm" -pAvantGarde-Demi
69 stdfont AX "$FP/a010035l.afm" "$FP/URWGothic-DemiOblique.afm" -pAvantGarde-DemiOblique
70 stdfont HR "$FP/n019003l.afm" "$FP/NimbusSans-Regular.afm" -pHelvetica
71 stdfont HI "$FP/n019023l.afm" "$FP/NimbusSans-Italic.afm" -pHelvetica-Oblique
72 stdfont HB "$FP/n019004l.afm" "$FP/NimbusSans-Bold.afm" -pHelvetica-Bold
73 stdfont HX "$FP/n019024l.afm" "$FP/NimbusSans-BoldItalic.afm" -pHelvetica-BoldOblique
74 stdfont Hr "$FP/n019043l.afm" "$FP/NimbusSansNarrow-Regular.afm" -pHelvetica-Narrow
75 stdfont Hi "$FP/n019063l.afm" "$FP/NimbusSansNarrow-Oblique.afm" -pHelvetica-Narrow-Oblique
76 stdfont Hb "$FP/n019044l.afm" "$FP/NimbusSansNarrow-Bold.afm" -pHelvetica-Narrow-Bold
77 stdfont Hx "$FP/n019024l.afm" "$FP/NimbusSansNarrow-BoldOblique.afm" -pHelvetica-Narrow-BoldOblique
78 stdfont KR "$FP/b018012l.afm" "$FP/URWBookman-Light.afm" -pBookman-Light
79 stdfont KI "$FP/b018032l.afm" "$FP/URWBookman-LightItalic.afm" -pBookman-LightItalic
80 stdfont KB "$FP/b018015l.afm" "$FP/URWBookman-Demi.afm" -pBookman-Demi
81 stdfont KX "$FP/b018035l.afm" "$FP/URWBookman-DemiItalic.afm" -pBookman-DemiItalic
82 stdfont NR "$FP/c059013l.afm" "$FP/C059-Roman.afm" -pNewCenturySchlbk-Roman
83 stdfont NI "$FP/c059033l.afm" "$FP/C059-Italic.afm" -pNewCenturySchlbk-Italic
84 stdfont NB "$FP/c059016l.afm" "$FP/C059-Bold.afm" -pNewCenturySchlbk-Bold
85 stdfont NX "$FP/c059036l.afm" "$FP/C059-BdIta.afm" -pNewCenturySchlbk-BoldItalic
86 stdfont PA "$FP/p052003l.afm" "$FP/P052-Roman.afm" -pPalatino-Roman
87 stdfont PR "$FP/p052003l.afm" "$FP/P052-Roman.afm" -pPalatino-Roman
88 stdfont PI "$FP/p052023l.afm" "$FP/P052-Italic.afm" -pPalatino-Italic
89 stdfont PB "$FP/p052004l.afm" "$FP/P052-Bold.afm" -pPalatino-Bold
90 stdfont PX "$FP/p052024l.afm" "$FP/P052-BoldItalic.afm" -pPalatino-BoldItalic
91 stdfont CR "$FP/n022003l.afm" "$FP/NimbusMonoPS-Regular.afm" -pCourier
92 stdfont CI "$FP/n022023l.afm" "$FP/NimbusMonoPS-Italic.afm" -pCourier-Oblique
93 stdfont CB "$FP/n022004l.afm" "$FP/NimbusMonoPS-Bold.afm" -pCourier-Bold
94 stdfont CX "$FP/n022024l.afm" "$FP/NimbusMonoPS-BoldItalic.afm" -pCourier-BoldOblique
95 stdfont ZI "$FP/z003034l.afm" "$FP/Z003-MediumItalic.afm" -pZapfChancery-MediumItalic
97 # The first argument of afmconv, ttfconv, and otfconv is the troff
98 # name of the font and their second argument is its path. Any other
99 # argument is passed to mkfn directly. The postscript names of the
100 # fonts are inferred from the fonts themselves To change that, you
101 # can specify their names via the -p argument of *conv functions.
103 find "$FP/" -name '*.afm' | while read FN
105 afmconv `basename "$FN" .afm` "$FN"
106 done
108 find "$FP/" -name '*.ttf' | while read FN
110 ttfconv `basename "$FN" .ttf` "$FN"
111 done
113 find "$FP/" -name '*.otf' | while read FN
115 ttfconv `basename "$FN" .otf` "$FN"
116 done