| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Bash script to make glyph list from afm file. |
| 4 |
# The glyph list is then used in making the etx file and for reglyphing. |
| 5 |
|
| 6 |
# SYNTAX: |
| 7 |
# afmtoglyphlist AfmFile GlyphListFile EncFile |
| 8 |
|
| 9 |
# The EncFile is a PostScript encoding vector for dvips. |
| 10 |
# If a glyph name from the AFM file appears in the encoding vector, |
| 11 |
# then the script puts \ok as the second parameter to \declareglyph. |
| 12 |
|
| 13 |
AfmFile=$1 |
| 14 |
GlyphList=$2 |
| 15 |
EncFile=$3 |
| 16 |
|
| 17 |
echo "Creating glyph list $GlyphList from $AfmFile for $EncFile" |
| 18 |
|
| 19 |
MaxLines=`wc -l $AfmFile | cut -d" " -f 1` |
| 20 |
|
| 21 |
echo " $MaxLines lines in afm file." |
| 22 |
|
| 23 |
LineNum=1 |
| 24 |
UnknownGlyph=1 |
| 25 |
ProccessingChars=FALSE |
| 26 |
echo "% glyph list $GlyphList " > $GlyphList |
| 27 |
echo "% Created by afmtoglyhlist from $AfmFile for encoding $EncFile" >> $GlyphList |
| 28 |
echo "% on `date`." >> $GlyphList |
| 29 |
while [ $LineNum -le $MaxLines ]; |
| 30 |
do |
| 31 |
Line=`head -n $LineNum $AfmFile | tail -1` |
| 32 |
#echo "$LineNum: $Line" |
| 33 |
|
| 34 |
if [ "$ProcessingChars" == "TRUE" ] |
| 35 |
then |
| 36 |
if [ "`echo \"$Line\" | grep EndCharMetrics`" != "" ] |
| 37 |
then |
| 38 |
ProcessingChars=FALSE |
| 39 |
LineNum=$((MaxLines+1)) |
| 40 |
else |
| 41 |
# process a character |
| 42 |
Char=`echo "$Line" | cut -d" " -f 8` |
| 43 |
if [ "$Char" != "" ] |
| 44 |
then |
| 45 |
if [ "`grep -x '[[:space:]]*/'$Char'[[:space:]]*' $EncFile`" != "" ] |
| 46 |
then |
| 47 |
echo '\declareglyph{'$Char'}{\ok}{}{}' >> $GlyphList |
| 48 |
else |
| 49 |
echo '\declareglyph{'$Char'}{unknown'$UnknownGlyph'}' >> $GlyphList |
| 50 |
UnknownGlyph=$((UnknownGlyph+1)) |
| 51 |
fi |
| 52 |
fi |
| 53 |
fi |
| 54 |
|
| 55 |
else |
| 56 |
if [ "`echo \"$Line\" | grep StartCharMetrics`" != "" ] |
| 57 |
then |
| 58 |
ProcessingChars=TRUE |
| 59 |
fi |
| 60 |
fi |
| 61 |
|
| 62 |
LineNum=$((LineNum+1)) |
| 63 |
done |
| 64 |
|
| 65 |
echo "Done." |