| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# installfont-tl [options] |
| 4 |
# |
| 5 |
# installs a LaTeX font family (Postscript Type1, Truetype, Opentype) |
| 6 |
# (font series from light to ultra bold + (faked) small caps + faked |
| 7 |
# slanted, but no expert fonts) for using them with LaTeX (TeXLive) |
| 8 |
# The script tries to rename the fonts automatically (optional). |
| 9 |
# Otherwise the *.afm and *.pfb files must be named in Karl Berry scheme |
| 10 |
# (e.g. 5bbr8a.pfb) |
| 11 |
# (tested with TeXLive2013/Cygwin) v1.7 (15.07.2013) |
| 12 |
# (C) Josef Kleber 2009-2010,2013 License: LPPL |
| 13 |
# |
| 14 |
VERSION="v1.7 (2013/07/15)" |
| 15 |
# |
| 16 |
FONTFAMILY="5bb" |
| 17 |
FONTNAME="Softmaker Barbedor" |
| 18 |
FONTCOMMAND="FFBarbedor" |
| 19 |
FONTSCALEPREFIX="Sbb" |
| 20 |
FONTTYPE="pst1" |
| 21 |
PACKAGENAME="barbedor" |
| 22 |
PACKAGEDATE="2010/03/05" |
| 23 |
PACKAGEVERSION="v1.0" |
| 24 |
MAPFILENAME="" |
| 25 |
OFN="false" |
| 26 |
WINLOCALTEXMF="`kpsewhich --expand-var='$TEXMFLOCAL' | sed s/\r//`" |
| 27 |
USEDOS=`uname | cut -c1-6` |
| 28 |
if [ "$USEDOS" = "CYGWIN" ] |
| 29 |
then |
| 30 |
WINLOCALTEXMFII="`cygpath -u $WINLOCALTEXMF`" |
| 31 |
LOCALTEXMF="$WINLOCALTEXMFII" |
| 32 |
else |
| 33 |
LOCALTEXMF="$WINLOCALTEXMF" |
| 34 |
fi |
| 35 |
FONTSUBDIR="MyFonts/Barbedor" |
| 36 |
# Font encoding default: 8a (AdobeStandardEncoding) |
| 37 |
FONTENCODING="8a" |
| 38 |
# Font cut default: r (regular) don't change! |
| 39 |
FONTCUT="r" |
| 40 |
# |
| 41 |
OTFFONTFEATURES="-fkern -fliga" |
| 42 |
UNINSTALL="false" |
| 43 |
INSTALLAS="rmdefault" |
| 44 |
SMFFSTY="%" |
| 45 |
LOG="false" |
| 46 |
# |
| 47 |
function printHelp() |
| 48 |
{ |
| 49 |
echo -e \ |
| 50 |
" `basename $0` [options]\n"\ |
| 51 |
" installs a font family for using it with LaTeX\n\n"\ |
| 52 |
" Options:\n\n"\ |
| 53 |
" -f, --fontfamily Name of the LaTeX font family, e.g. ptm (Adobe Times)\n\n"\ |
| 54 |
" -n, --fontname Font name, e.g. Adobe Times\n\n"\ |
| 55 |
" -c, --fontcommand Name of the command that will switch to the font\n\n"\ |
| 56 |
" -P, --fontscaleprefix prefix of the scale macro, which should be different\n"\ |
| 57 |
" for each font (no digits allowed)\n\n"\ |
| 58 |
" -t, --fonttype Font type (pst1(default)|ttf|otf)\n\n"\ |
| 59 |
" -p, --packagename Name of the LaTeX package\n\n"\ |
| 60 |
" -d, --packagedate Date of the LaTeX package\n\n"\ |
| 61 |
" -v, --packageversion Version of the LaTeX package\n\n"\ |
| 62 |
" -l, --localtexmf root of your local TeX tree, e.g. /cygdrive/c/LocalTeXMF\n\n"\ |
| 63 |
" -m, --mapfilename file name of the map file\n\n"\ |
| 64 |
" -O. --origfontname use original font names instead of Karl Berry names\n\n"\ |
| 65 |
" -s, --fontsubdir location where the fonts and support files should be\n"\ |
| 66 |
" installed, e.g. MyFonts/AdobeTimes\n\n"\ |
| 67 |
" -e, --fontencoding encoding of the font\n"\ |
| 68 |
" (default: 8a (AdobeStandardEncoding))\n\n"\ |
| 69 |
" -o, --otffontfeatures choosing Opentype font features\n"\ |
| 70 |
" (default: -fkern -fliga)\n\n"\ |
| 71 |
" -u, --uninstall will uninstall the font family. You must specify\n"\ |
| 72 |
" --localtexmf and --fontsubdir\n\n"\ |
| 73 |
" -R, --rmdefault installs font family as roman (serif) font family (default)\n\n"\ |
| 74 |
" -S, --sfdefault installs font family as sans serif font family\n\n"\ |
| 75 |
" -T, --ttdefault installs font family as typewriter font family\n\n"\ |
| 76 |
" -V, --version will print the version number of `basename $0`\n\n"\ |
| 77 |
" -L, --log will write the terminal output of the main programms into the\n"\ |
| 78 |
" LOG file instead of the screen\n\n"\ |
| 79 |
" -h, --help will print this help statement\n\n"\ |
| 80 |
" See http://latex.josef-kleber.de/index.htm or\n"\ |
| 81 |
" http://latex.josef-kleber.de/en_index.htm\n"\ |
| 82 |
" for more information" |
| 83 |
exit 0; |
| 84 |
} |
| 85 |
function printVersion() |
| 86 |
{ |
| 87 |
echo "This is version $VERSION of `basename $0`" |
| 88 |
exit 0; |
| 89 |
} |
| 90 |
# |
| 91 |
if [ $# -eq 0 ] |
| 92 |
then |
| 93 |
echo -e "`basename $0`: Could not find command line arguments.\nUse the '--help' option for explanation." |
| 94 |
echo -e "Continue with default script variables? (y/n)" |
| 95 |
read ANSWER |
| 96 |
if [ $ANSWER = "n" -o $ANSWER = "N" ] |
| 97 |
then |
| 98 |
exit 1 |
| 99 |
fi |
| 100 |
fi |
| 101 |
# |
| 102 |
LONGOPTS="fontfamily:,fontname:,fontcommand:,fontscaleprefix:,fonttype:,packagename:,packagedate:,packageversion:,mapfilename:,origfilename,localtexmf:,fontsubdir:,fontencoding:,otffontfeatures:,uninstall,rmdefault,sfdefault,ttdefault,log,version,help" |
| 103 |
SHORTOPTS="f:n:c:P:t:p:d:v:m:Ol:s:e:o:uRSTVLh" |
| 104 |
ARGS=$(getopt -l "$LONGOPTS" "$SHORTOPTS" "$@") |
| 105 |
if [ $? -ne 0 ] |
| 106 |
then |
| 107 |
echo -e "`basename $0`: Could not process command line arguments.\nUse the '--help' option for explanation." |
| 108 |
exit 1 |
| 109 |
fi |
| 110 |
# |
| 111 |
eval set -- "$ARGS" |
| 112 |
# |
| 113 |
while [ $# -gt 0 ]; do |
| 114 |
ARG=$1 |
| 115 |
case "$ARG" in |
| 116 |
--help|-h) shift; printHelp;; |
| 117 |
--version|-V) shift; printVersion;; |
| 118 |
--rmdefault|-R) shift; INSTALLAS="rmdefault";; |
| 119 |
--sfdefault|-S) shift; INSTALLAS="sfdefault";; |
| 120 |
--ttdefault|-T) shift; INSTALLAS="ttdefault";; |
| 121 |
--uninstall|-u) shift; UNINSTALL="true";; |
| 122 |
--log|-L) shift; LOG="true";; |
| 123 |
--fontfamily|-f) shift; FONTFAMILY="$1"; shift;; |
| 124 |
--fontname|-n) shift; FONTNAME="$1"; shift;; |
| 125 |
--fontcommand|-c) shift; FONTCOMMAND="$1"; shift;; |
| 126 |
--fontscaleprefix|-P) shift; FONTSCALEPREFIX="$1"; shift;; |
| 127 |
--fonttype|-t) shift; FONTTYPE="$1"; shift;; |
| 128 |
--packagename|-p) shift; PACKAGENAME="$1"; shift;; |
| 129 |
--packagedate|-d) shift; PACKAGEDATE="$1"; shift;; |
| 130 |
--packageversion|-v) shift; PACKAGEVERSION="$1"; shift;; |
| 131 |
--mapfilename|-m) shift; MAPFILENAME="$1"; shift;; |
| 132 |
--origfontname|-O) shift; OFN="true";; |
| 133 |
--localtexmf|-l) shift; LOCALTEXMF="$1"; shift;; |
| 134 |
--fontsubdir|-s) shift; FONTSUBDIR="$1"; shift;; |
| 135 |
--fontencoding|-e) shift; FONTENCODING="$1"; shift;; |
| 136 |
--otffontfeatures|-o) shift; FONTFAMILY="$1"; shift;; |
| 137 |
--) shift; break;; |
| 138 |
*) break;; |
| 139 |
esac |
| 140 |
done |
| 141 |
# |
| 142 |
rm LOG 2>>/dev/null; |
| 143 |
# |
| 144 |
if [ -z $MAPFILENAME ] |
| 145 |
then |
| 146 |
MAPFILENAME=$FONTFAMILY |
| 147 |
fi |
| 148 |
# |
| 149 |
typeset -i STEP=0 |
| 150 |
# |
| 151 |
if [ $UNINSTALL = "true" ] |
| 152 |
then |
| 153 |
DIR="${LOCALTEXMF}/fonts/tfm/${FONTSUBDIR}/" |
| 154 |
echo -e "$\n\n$DIR" |
| 155 |
DIR="${LOCALTEXMF}/fonts/vf/${FONTSUBDIR}/" |
| 156 |
echo $DIR |
| 157 |
DIR="${LOCALTEXMF}/fonts/type1/${FONTSUBDIR}/" |
| 158 |
echo $DIR |
| 159 |
DIR="${LOCALTEXMF}/fonts/map/dvips/${FONTSUBDIR}/" |
| 160 |
echo $DIR |
| 161 |
DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/" |
| 162 |
echo $DIR |
| 163 |
echo -e "\n\nDo you want to delete these directories? (y/n)" |
| 164 |
read ANSWER |
| 165 |
if [ $ANSWER = "y" -o $ANSWER = "Y" ] |
| 166 |
then |
| 167 |
DIR="${LOCALTEXMF}/fonts/tfm/${FONTSUBDIR}/" |
| 168 |
rm -f -r $DIR |
| 169 |
DIR="${LOCALTEXMF}/fonts/vf/${FONTSUBDIR}/" |
| 170 |
rm -f -r $DIR |
| 171 |
DIR="${LOCALTEXMF}/fonts/type1/${FONTSUBDIR}/" |
| 172 |
rm -f -r $DIR |
| 173 |
DIR="${LOCALTEXMF}/fonts/map/dvips/${FONTSUBDIR}/" |
| 174 |
rm -f -r $DIR |
| 175 |
DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/" |
| 176 |
rm -f -r $DIR |
| 177 |
exit 0 |
| 178 |
else |
| 179 |
exit 1 |
| 180 |
fi |
| 181 |
fi |
| 182 |
# |
| 183 |
if [ $FONTTYPE = "ttf" ] |
| 184 |
then |
| 185 |
((STEP++)) |
| 186 |
echo -e "\n\n$STEP) Convert font(s) to Postscript Type1\n\n" |
| 187 |
for file in *.TTF; |
| 188 |
do |
| 189 |
mv "$file" "${file%TTF}ttf" 2>>/dev/null; |
| 190 |
done |
| 191 |
for file in *.ttf; |
| 192 |
do |
| 193 |
ttf2pt1 -a -b -l adobestd "$file"; |
| 194 |
done |
| 195 |
fi |
| 196 |
# |
| 197 |
if [ $FONTTYPE = "otf" ] |
| 198 |
then |
| 199 |
((STEP++)) |
| 200 |
echo -e "\n\n$STEP) Convert font(s) to Postscript Type1\n\n" |
| 201 |
for file in *.OTF; |
| 202 |
do |
| 203 |
mv "$file" "${file%OTF}otf" 2>>/dev/null; |
| 204 |
done |
| 205 |
for file in *.otf; |
| 206 |
do |
| 207 |
otftotfm $OTFFONTFEATURES -e - "$file" 555; |
| 208 |
done |
| 209 |
for file in *.pfb; |
| 210 |
do |
| 211 |
pf2afm "$file"; |
| 212 |
done |
| 213 |
rm *.tfm |
| 214 |
rm *.enc |
| 215 |
fi |
| 216 |
# |
| 217 |
echo -e "\n\nTry to rename the font(s) automatically? (y/n)" |
| 218 |
read ANSWER |
| 219 |
if [ $ANSWER = "y" -o $ANSWER = "Y" ] |
| 220 |
then |
| 221 |
((STEP++)) |
| 222 |
echo -e "\n\n$STEP) Renaming fonts\n\n" |
| 223 |
mkdir -p Backup |
| 224 |
cp *.afm *.AFM ./Backup 2>>/dev/null |
| 225 |
cp *.pfb *.PFB ./Backup 2>>/dev/null |
| 226 |
for file in *.AFM; |
| 227 |
do |
| 228 |
mv "$file" "${file%AFM}afm" 2>>/dev/null; |
| 229 |
done |
| 230 |
for file in *.PFB; |
| 231 |
do |
| 232 |
mv "$file" "${file%PFB}pfb" 2>>/dev/null; |
| 233 |
done |
| 234 |
FONTNUMBER=$(ls -al *.pfb 2>>/dev/null | wc -l) |
| 235 |
if [ $FONTNUMBER -le 1 ] |
| 236 |
then |
| 237 |
if [ $FONTNUMBER -eq 0 ] |
| 238 |
then |
| 239 |
echo "No font(s) to rename!" |
| 240 |
exit 1 |
| 241 |
else |
| 242 |
for file in *.afm; |
| 243 |
do |
| 244 |
mv "$file" ${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 245 |
done |
| 246 |
for file in *.pfb; |
| 247 |
do |
| 248 |
mv "$file" ${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 249 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.pfb}/" >>map.sed; |
| 250 |
done |
| 251 |
fi |
| 252 |
else |
| 253 |
mkdir -p Rename |
| 254 |
# rename small caps font(s) |
| 255 |
FILES=$(grep -e "Smc" -e "Caps" -e "SCOsF" *.afm | cut -d':' -f1 | uniq) |
| 256 |
for file in $FILES |
| 257 |
do |
| 258 |
FONTCUT="rc" |
| 259 |
FWEIGHT=$(grep -e "Light" "$file" | wc -l) |
| 260 |
if [ $FWEIGHT -gt 0 ] |
| 261 |
then |
| 262 |
FONTCUT="lc" |
| 263 |
else |
| 264 |
FWEIGHT=$(grep -e "Semibold" -e "SemiBold" "$file" | wc -l) |
| 265 |
if [ $FWEIGHT -gt 0 ] |
| 266 |
then |
| 267 |
FONTCUT="sc" |
| 268 |
else |
| 269 |
FWEIGHT=$(grep -e "Demi" -e "Demibold" -e "DemiBold" "$file" | wc -l) |
| 270 |
if [ $FWEIGHT -gt 0 ] |
| 271 |
then |
| 272 |
FONTCUT="dc" |
| 273 |
else |
| 274 |
FWEIGHT=$(grep -e "Extrabold" -e "ExtraBold" "$file" | wc -l) |
| 275 |
if [ $FWEIGHT -gt 0 ] |
| 276 |
then |
| 277 |
FONTCUT="xc" |
| 278 |
else |
| 279 |
FWEIGHT=$(grep -e "Heavy" -e "Ultrabold" -e "UltraBold" "$file" | wc -l) |
| 280 |
if [ $FWEIGHT -gt 0 ] |
| 281 |
then |
| 282 |
FONTCUT="uc" |
| 283 |
else |
| 284 |
FWEIGHT=$(grep -e "Bold" -e "bold" "$file" | wc -l) |
| 285 |
if [ $FWEIGHT -gt 0 ] |
| 286 |
then |
| 287 |
FONTCUT="bc" |
| 288 |
fi |
| 289 |
fi |
| 290 |
fi |
| 291 |
fi |
| 292 |
fi |
| 293 |
fi |
| 294 |
mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 295 |
mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 296 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; |
| 297 |
done |
| 298 |
# rename the extra light font(s) |
| 299 |
FILES=$(grep -e "XLight" -e "Xlight" -e "extra light" *.afm | cut -d':' -f1 | uniq) |
| 300 |
for file in $FILES |
| 301 |
do |
| 302 |
ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) |
| 303 |
if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] |
| 304 |
then |
| 305 |
FONTCUT="ji" |
| 306 |
else |
| 307 |
FONTCUT="j" |
| 308 |
fi |
| 309 |
mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 310 |
mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 311 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; |
| 312 |
SMFFSTY="\RequirePackage{softmakerfreefont}%" |
| 313 |
done |
| 314 |
# rename the light font(s) |
| 315 |
FILES=$(grep -e "Light" *.afm | cut -d':' -f1 | uniq) |
| 316 |
for file in $FILES |
| 317 |
do |
| 318 |
ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) |
| 319 |
if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] |
| 320 |
then |
| 321 |
FONTCUT="li" |
| 322 |
else |
| 323 |
FONTCUT="l" |
| 324 |
fi |
| 325 |
mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 326 |
mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 327 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; |
| 328 |
SMFFSTY="\RequirePackage{softmakerfreefont}%" |
| 329 |
done |
| 330 |
# rename the semi(bold) font |
| 331 |
FILES=$(grep -e "Semibold" -e "SemiBold" *.afm | cut -d':' -f1 | uniq) |
| 332 |
for file in $FILES |
| 333 |
do |
| 334 |
ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) |
| 335 |
if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] |
| 336 |
then |
| 337 |
FONTCUT="si" |
| 338 |
else |
| 339 |
FONTCUT="s" |
| 340 |
fi |
| 341 |
mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 342 |
mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 343 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; |
| 344 |
SMFFSTY="\RequirePackage{softmakerfreefont}%" |
| 345 |
done |
| 346 |
# rename the demi(bold) font |
| 347 |
FILES=$(grep -e "FontName" -e "FullName" *.afm | grep -e "Demi" -e "Demibold" -e "DemiBold" | cut -d':' -f1 | uniq) |
| 348 |
for file in $FILES |
| 349 |
do |
| 350 |
ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) |
| 351 |
if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] |
| 352 |
then |
| 353 |
FONTCUT="di" |
| 354 |
else |
| 355 |
FONTCUT="d" |
| 356 |
fi |
| 357 |
mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 358 |
mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 359 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; |
| 360 |
SMFFSTY="\RequirePackage{softmakerfreefont}%" |
| 361 |
done |
| 362 |
# rename the extra bold font |
| 363 |
FILES=$(grep -e "Extrabold" -e "ExtraBold" *.afm | cut -d':' -f1 | uniq) |
| 364 |
for file in $FILES |
| 365 |
do |
| 366 |
ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) |
| 367 |
if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] |
| 368 |
then |
| 369 |
FONTCUT="xi" |
| 370 |
else |
| 371 |
FONTCUT="x" |
| 372 |
fi |
| 373 |
mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 374 |
mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 375 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; |
| 376 |
done |
| 377 |
# rename the ultra bold/heavy font |
| 378 |
FILES=$(grep -e "Heavy" -e "Ultrabold" -e "UltraBold" *.afm | cut -d':' -f1 | uniq) |
| 379 |
for file in $FILES |
| 380 |
do |
| 381 |
ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) |
| 382 |
if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] |
| 383 |
then |
| 384 |
FONTCUT="ui" |
| 385 |
else |
| 386 |
FONTCUT="u" |
| 387 |
fi |
| 388 |
mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 389 |
mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 390 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; |
| 391 |
SMFFSTY="\RequirePackage{softmakerfreefont}%" |
| 392 |
done |
| 393 |
# rename the bold font |
| 394 |
FILES=$(grep -e "Bold" -e "bold" *.afm | cut -d':' -f1 | uniq) |
| 395 |
for file in $FILES |
| 396 |
do |
| 397 |
ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) |
| 398 |
if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] |
| 399 |
then |
| 400 |
FONTCUT="bi" |
| 401 |
else |
| 402 |
FONTCUT="b" |
| 403 |
fi |
| 404 |
mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 405 |
mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 406 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; |
| 407 |
done |
| 408 |
# rename the regular font |
| 409 |
FILES=$(grep -e "Regular" -e "Medium" -e "Book" --exclude=installfont * | grep -e ".afm" | cut -d':' -f1 | uniq) |
| 410 |
for file in $FILES |
| 411 |
do |
| 412 |
ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) |
| 413 |
if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] |
| 414 |
then |
| 415 |
FONTCUT="ri" |
| 416 |
else |
| 417 |
FONTCUT="r" |
| 418 |
fi |
| 419 |
mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; |
| 420 |
mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; |
| 421 |
echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; |
| 422 |
done |
| 423 |
mv ./Rename/* . |
| 424 |
rmdir ./Rename |
| 425 |
fi |
| 426 |
ls -al *.pfb *.afm |
| 427 |
echo -e "\n\nPlease check the font name(s). Continue? (y/n)" |
| 428 |
read ANSWER |
| 429 |
if [ $ANSWER = "n" -o $ANSWER = "N" ] |
| 430 |
then |
| 431 |
rm *.afm |
| 432 |
rm *.pfb |
| 433 |
rm *.sed |
| 434 |
mv ./Backup/* . |
| 435 |
rmdir ./Backup |
| 436 |
exit 1 |
| 437 |
fi |
| 438 |
fi |
| 439 |
# |
| 440 |
((STEP++)) |
| 441 |
echo -e "\n\n$STEP) Creating metrics and virtual fonts\n\n" |
| 442 |
cat >${FONTFAMILY}-drv.tex <<EOF |
| 443 |
\input fontinst.sty |
| 444 |
\needsfontinstversion{1.926} |
| 445 |
\recordtransforms{${FONTFAMILY}-rec.tex} |
| 446 |
\latinfamily{${FONTFAMILY}}{} |
| 447 |
\endrecordtransforms |
| 448 |
\bye |
| 449 |
EOF |
| 450 |
if [ $LOG = "true" ] |
| 451 |
then |
| 452 |
tex ${FONTFAMILY}-drv.tex >>LOG 2>&1 |
| 453 |
else |
| 454 |
tex ${FONTFAMILY}-drv.tex |
| 455 |
fi |
| 456 |
# |
| 457 |
((STEP++)) |
| 458 |
echo -e "\n\n$STEP) Compiling metrics and virtual fonts\n\n" |
| 459 |
for file in *.pl; |
| 460 |
do |
| 461 |
if [ $LOG = "true" ] |
| 462 |
then |
| 463 |
pltotf $file ${file%pl}tfm >>LOG 2>&1 |
| 464 |
else |
| 465 |
pltotf $file ${file%pl}tfm |
| 466 |
fi |
| 467 |
done |
| 468 |
for file in *.vpl; |
| 469 |
do |
| 470 |
if [ $LOG = "true" ] |
| 471 |
then |
| 472 |
vptovf $file ${file%vpl}vf ${file%vpl}tfm >>LOG 2>&1 |
| 473 |
else |
| 474 |
vptovf $file ${file%vpl}vf ${file%vpl}tfm |
| 475 |
fi |
| 476 |
done |
| 477 |
# |
| 478 |
((STEP++)) |
| 479 |
echo -e "\n\n$STEP) Creating the map file\n\n" |
| 480 |
cat >${FONTFAMILY}-map.tex <<EOF |
| 481 |
\input finstmsc.sty |
| 482 |
\resetstr{PSfontsuffix}{.pfb} |
| 483 |
\adddriver{dvips}{${FONTFAMILY}.map} |
| 484 |
\input ${FONTFAMILY}-rec.tex |
| 485 |
\donedrivers |
| 486 |
\bye |
| 487 |
EOF |
| 488 |
if [ $LOG = "true" ] |
| 489 |
then |
| 490 |
tex ${FONTFAMILY}-map.tex >>LOG 2>&1 |
| 491 |
else |
| 492 |
tex ${FONTFAMILY}-map.tex |
| 493 |
fi |
| 494 |
if [ $OFN = "true" ] |
| 495 |
then |
| 496 |
sed -f map.sed ${FONTFAMILY}.map >${MAPFILENAME}.map |
| 497 |
unix2dos ${MAPFILENAME}.map 2>>/dev/null; |
| 498 |
rm ${FONTFAMILY}.map |
| 499 |
UMAP="${MAPFILENAME}" |
| 500 |
else |
| 501 |
UMAP="${FONTFAMILY}" |
| 502 |
fi |
| 503 |
# |
| 504 |
((STEP++)) |
| 505 |
echo -e "\n\n$STEP) Creating the style file" |
| 506 |
cat >${PACKAGENAME}.sty <<EOF |
| 507 |
\NeedsTeXFormat{LaTeX2e}% |
| 508 |
\ProvidesPackage{$PACKAGENAME}[$PACKAGEDATE $PACKAGEVERSION $FONTNAME]% |
| 509 |
\RequirePackage{textcomp}% |
| 510 |
\RequirePackage{xkeyval}% |
| 511 |
\define@key{${PACKAGENAME}.sty}{scaled}[1.0]% |
| 512 |
{% |
| 513 |
\def\\${FONTSCALEPREFIX}@scale{#1}% |
| 514 |
}% |
| 515 |
\define@key{${PACKAGENAME}.sty}{leading}[1.0]% |
| 516 |
{% |
| 517 |
\linespread{#1}% |
| 518 |
}% |
| 519 |
\ExecuteOptionsX{scaled}% |
| 520 |
\ProcessOptionsX\relax% |
| 521 |
\renewcommand*{\\${INSTALLAS}}{$FONTFAMILY}% |
| 522 |
\newcommand\\${FONTCOMMAND}{\fontfamily{$FONTFAMILY}\fontseries{m}\fontshape{n}\selectfont}% |
| 523 |
\endinput% |
| 524 |
EOF |
| 525 |
# |
| 526 |
((STEP++)) |
| 527 |
echo -e "\n\n$STEP) Insert scale factor into the fd files" |
| 528 |
cat >installfont.sed <<EOF |
| 529 |
9 i\\ |
| 530 |
\\n\\\\expandafter\\\\ifx\\\\csname ${FONTSCALEPREFIX}@scale\\\\endcsname\\\\relax\\n \\\\let\\\\${FONTSCALEPREFIX}@@scale\\\\@empty\\n\\\\else\\n \\\\edef\\\\${FONTSCALEPREFIX}@@scale{s*[\\\\csname ${FONTSCALEPREFIX}@scale\\\\endcsname]}\\n\\\\fi\\n |
| 531 |
s/<-> /<-> \\\\${FONTSCALEPREFIX}@@scale / |
| 532 |
EOF |
| 533 |
# |
| 534 |
for file in *.fd; |
| 535 |
do |
| 536 |
mv $file ${file%fd}fdb; |
| 537 |
sed -f installfont.sed ${file%fd}fdb >$file; |
| 538 |
done |
| 539 |
# |
| 540 |
((STEP++)) |
| 541 |
echo -e "\n\n$STEP) Installing font(s) and support files" |
| 542 |
DIR="${LOCALTEXMF}/fonts/tfm/${FONTSUBDIR}/" |
| 543 |
if [ ! -d $DIR ] |
| 544 |
then |
| 545 |
mkdir -p $DIR |
| 546 |
fi |
| 547 |
mv *.tfm $DIR |
| 548 |
DIR="${LOCALTEXMF}/fonts/vf/${FONTSUBDIR}/" |
| 549 |
if [ ! -d $DIR ] |
| 550 |
then |
| 551 |
mkdir -p $DIR |
| 552 |
fi |
| 553 |
mv *.vf $DIR |
| 554 |
DIR="${LOCALTEXMF}/fonts/type1/${FONTSUBDIR}/" |
| 555 |
if [ $OFN = "true" ] |
| 556 |
then |
| 557 |
cd Backup |
| 558 |
if [ ! -d $DIR ] |
| 559 |
then |
| 560 |
mkdir -p $DIR |
| 561 |
fi |
| 562 |
cp *.pfb $DIR |
| 563 |
cd .. |
| 564 |
else |
| 565 |
if [ ! -d $DIR ] |
| 566 |
then |
| 567 |
mkdir -p $DIR |
| 568 |
fi |
| 569 |
cp *.pfb $DIR |
| 570 |
fi |
| 571 |
DIR="${LOCALTEXMF}/fonts/map/dvips/${FONTSUBDIR}/" |
| 572 |
if [ ! -d $DIR ] |
| 573 |
then |
| 574 |
mkdir -p $DIR |
| 575 |
fi |
| 576 |
mv *.map $DIR |
| 577 |
DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/" |
| 578 |
if [ ! -d $DIR ] |
| 579 |
then |
| 580 |
mkdir -p $DIR |
| 581 |
fi |
| 582 |
mv *.fd $DIR |
| 583 |
DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/" |
| 584 |
if [ ! -d $DIR ] |
| 585 |
then |
| 586 |
mkdir -p $DIR |
| 587 |
fi |
| 588 |
mv *.sty $DIR |
| 589 |
# |
| 590 |
((STEP++)) |
| 591 |
echo -e "\n\n$STEP) Update FNDB" |
| 592 |
echo -e "\n\n" |
| 593 |
texhash |
| 594 |
# |
| 595 |
((STEP++)) |
| 596 |
echo -e "\n\n$STEP) Include the map file" |
| 597 |
echo -e "\n\n" |
| 598 |
updmap --enable Map ${UMAP}.map |
| 599 |
rm *.mtx |
| 600 |
rm *.pl |
| 601 |
rm *.vpl |
| 602 |
rm *.log |
| 603 |
rm *.tex |
| 604 |
rm *.fdb |
| 605 |
rm *.sed |
| 606 |
if [ -d Backup ] |
| 607 |
then |
| 608 |
rm *.afm |
| 609 |
rm *.pfb |
| 610 |
mv ./Backup/* . |
| 611 |
rmdir ./Backup |
| 612 |
fi |
| 613 |
echo -e "\n\nThe font(s) should be installed now!" |
| 614 |
exit 0 |