ref: da07a4750328cb29751092ef3f1ae2f0fd09d110
parent: 53d774f598ab4e2d83d2493abb0eeacd6e59c1d8
author: Ali Gholami Rudi <ali@rudi.ir>
date: Fri Feb 21 11:49:23 EST 2014
gen.sh: add USELCDF to use lcdf-typetools instead of fontforge
--- a/gen.sh
+++ b/gen.sh
@@ -9,12 +9,9 @@
RES="720"
# pattern of ligatures to ignore
LIGIGN="\(ct\|st\|sp\|Rp\)"
-# pattern of allowed opentype features
-OTFFEATS="\(swsh\|titl\|smcp\|case\)"
+# use lcdf-typetools instead of fontforge for otf files
+USELCDF="0"
-# otherwise sort and grep would be too slow
-export LC_ALL="C"
-
# creating DESC
mkdir -p $TP
echo "fonts 10 R I B BI CW H HI HB S1 S" >$TP/DESC
@@ -27,35 +24,29 @@
function afmconv
{
echo $1
- cat $FP/$3 | ./mktrfn $4 -a -r$RES -t $1 -p $2 >$TP/$1
+ cat $FP/$3 | ./mktrfn $4 -a -b -r$RES -t $1 -p $2 >$TP/$1
}
-# converting otf and ttf fonts; needs heirloom's otfdump
-# otfconv troff_name postscript_name font_path
+# converting otf and ttf fonts; needs fontforge or lcdf-typetools
function otfconv
{
- ODOUT="/tmp/.mktrfn.otfdump"
- FEATS="`otfdump -s $3 | cut -f2 -d ' ' | sort | uniq`"
- echo "$1: `echo $FEATS | tr '\n' ' '`"
- otfdump -nc $3 >$ODOUT
- otfdump -k $3 | sort | uniq >>$ODOUT
- # without any substitutions
- cat $ODOUT | ./mktrfn $4 -r$RES -p $2 | sed "/^ligatures /s/ $LIGIGN//g" >$TP/$1
- for FEAT in `echo $FEATS | tr ' ' '\n' | sed "/$OTFFEATS/!d"`
- do
- echo " $1.$FEAT"
- (otfdump -s $3 | grep "^feature $FEAT" | sort | uniq; cat $ODOUT) | \
- ./mktrfn $4 -r$RES -p $2 | \
- sed "/^ligatures /s/ $LIGIGN//g" >$TP/$1.$FEAT
- done
- rm $ODOUT
+ FN="$1"
+ AFM="/tmp/.mktrfn.afm"
+ if [ "$USELCDF" == "1" ]; then
+ cat $2 | cfftot1 2>/dev/null | t1rawafm >$AFM 2>/dev/null
+ else
+ echo -e "Open (\"$2\")\nGenerate(\"$AFM\")" | fontforge >/dev/null 2>&1
+ fi
+ cat $AFM | ./mktrfn -b -a -r$RES -t $FN -p $FN -k50 | \
+ sed "/^ligatures /s/ $LIGIGN//g" >$TP/$FN
+ rm $AFM
}
# The standard fonts
afmconv R Times-Roman n021003l.afm
-afmconv I Times-Italic n021023l.afm -b
+afmconv I Times-Italic n021023l.afm
afmconv B Times-Bold n021004l.afm
-afmconv BI Times-BoldItalic n021024l.afm -b
+afmconv BI Times-BoldItalic n021024l.afm
afmconv S Symbol s050000l.afm -s
afmconv S1 Times-Roman n021003l.afm -s
afmconv AR AvantGarde-Book a010013l.afm
@@ -63,32 +54,32 @@
afmconv AB AvantGarde-Demi a010015l.afm
afmconv AX AvantGarde-DemiOblique a010035l.afm
afmconv H Helvetica n019043l.afm
-afmconv HI Helvetica-Oblique n019063l.afm -b
+afmconv HI Helvetica-Oblique n019063l.afm
afmconv HB Helvetica-Bold n019044l.afm
-afmconv HX Helvetica-BoldOblique n019064l.afm -b
+afmconv HX Helvetica-BoldOblique n019064l.afm
afmconv Hr Helvetica-Narrow n019043l.afm
-afmconv Hi Helvetica-Narrow-Oblique n019063l.afm -b
+afmconv Hi Helvetica-Narrow-Oblique n019063l.afm
afmconv Hb Helvetica-Narrow-Bold n019044l.afm
-afmconv Hx Helvetica-Narrow-BoldOblique n019064l.afm -b
+afmconv Hx Helvetica-Narrow-BoldOblique n019064l.afm
afmconv KR Bookman-Light b018012l.afm
-afmconv KI Bookman-LightItalic b018032l.afm -b
+afmconv KI Bookman-LightItalic b018032l.afm
afmconv KB Bookman-Demi b018015l.afm
-afmconv KX Bookman-DemiItalic b018035l.afm -b
+afmconv KX Bookman-DemiItalic b018035l.afm
afmconv NR NewCenturySchlbk-Roman c059013l.afm
-afmconv NI NewCenturySchlbk-Italic c059033l.afm -b
+afmconv NI NewCenturySchlbk-Italic c059033l.afm
afmconv NB NewCenturySchlbk-Bold c059016l.afm
-afmconv NX NewCenturySchlbk-BoldItalic c059036l.afm -b
+afmconv NX NewCenturySchlbk-BoldItalic c059036l.afm
afmconv PA Palatino-Roman p052003l.afm
afmconv PR Palatino-Roman p052003l.afm
-afmconv PI Palatino-Italic p052023l.afm -b
+afmconv PI Palatino-Italic p052023l.afm
afmconv PB Palatino-Bold p052004l.afm
-afmconv PX Palatino-BoldItalic p052024l.afm -b
+afmconv PX Palatino-BoldItalic p052024l.afm
afmconv C Courier n022003l.afm
afmconv CO Courier n022003l.afm
afmconv CW Courier n022003l.afm
-afmconv CI Courier-Oblique n022023l.afm -b
+afmconv CI Courier-Oblique n022023l.afm
afmconv CB Courier-Bold n022004l.afm
-afmconv CX Courier-BoldOblique n022024l.afm -b
+afmconv CX Courier-BoldOblique n022024l.afm
afmconv ZI ZapfChancery-MediumItalic z003034l.afm
afmconv ZD ZapfDingbats d050000l.afm
@@ -96,12 +87,10 @@
# can be obtained by dropping its extension. Otherwise, remove the
# -p argument of mktrfn in otfconv function.
-for f in $FP/*.otf
+for f in $FP/*.otf $FP/*.ttf
do
- otfconv "`basename $f .otf`" "`basename $f .otf`" "$f" -k50
-done
-
-for f in $FP/*.ttf
-do
- otfconv "`basename $f .ttf`" "`basename $f .ttf`" "$f" -k50
+ FN="`basename $f .otf`"
+ FN="`basename $FN .ttf`"
+ echo $FN
+ otfconv $FN $f
done