diff options
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-x | Master/texmf-dist/scripts/installfont/installfont-tl | 532 |
1 files changed, 532 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/installfont/installfont-tl b/Master/texmf-dist/scripts/installfont/installfont-tl new file mode 100755 index 00000000000..703104e262c --- /dev/null +++ b/Master/texmf-dist/scripts/installfont/installfont-tl @@ -0,0 +1,532 @@ +#!/bin/bash +# +# installfont-tl [options] +# +# installs a LaTeX font family (Postscript Type1, Truetype, Opentype) +# (font series from light to ultra bold + (faked) small caps + faked +# slanted, but no expert fonts) for using with LaTeX (TeXLive) +# The script tries to rename the fonts automatically (optional). +# Otherwise the *.afm and *.pfb files must be named in Karl Berry scheme +# (e.g. 5bbr8a.pfb) +# (tested with Ubuntu 9.10) v1.5 (14.09.2010) +# (C) Josef Kleber, Christoph Bier 2009-2010 License: LPPL +# +VERSION="v1.5 (2010/09/14)" +# +FONTFAMILY="5bb" +FONTNAME="Softmaker Barbedor" +FONTCOMMAND="FFBarbedor" +FONTSCALEPREFIX="Sbb" +FONTTYPE="pst1" +PACKAGENAME="barbedor" +PACKAGEDATE="2010/03/05" +PACKAGEVERSION="v1.0" +MAPFILENAME="" +OFN="false" +LOCALTEXMF="`kpsexpand '$TEXMFHOME'`" +FONTSUBDIR="MyFonts/Barbedor" +# Font encoding default: 8a (AdobeStandardEncoding) +FONTENCODING="8a" +# Font cut default: r (regular) don't change! +FONTCUT="r" +# +OTFFONTFEATURES="-fkern -fliga" +UNINSTALL="false" +INSTALLAS="rmdefault" +SMFFSTY="%" +# +function printHelp() +{ + echo -e \ + " `basename $0` [options]\n"\ + " installs a font family for using it with LaTeX\n\n"\ + " Options:\n\n"\ + " -f, --fontfamily Name of the LaTeX font family, e.g. ptm (Adobe Times)\n\n"\ + " -n, --fontname Font name, e.g. Adobe Times\n\n"\ + " -c, --fontcommand Name of the command that will switch to the font\n\n"\ + " -P, --fontscaleprefix prefix of the scale macro, which should be different\n"\ + " for each font (no digits allowed)\n\n"\ + " -t, --fonttype Font type (pst1(default)|ttf|otf)\n\n"\ + " -p, --packagename Name of the LaTeX package\n\n"\ + " -d, --packagedate Date of the LaTeX package\n\n"\ + " -v, --packageversion Version of the LaTeX package\n\n"\ + " -l, --localtexmf root of your local TeX tree, e.g. /cygdrive/c/LocalTeXMF\n\n"\ + " -m, --mapfilename file name of the map file\n\n"\ + " -O. --origfontname use original font names instead of Karl Berry names\n\n"\ + " -s, --fontsubdir location where the fonts and support files should be\n"\ + " installed, e.g. MyFonts/AdobeTimes\n\n"\ + " -e, --fontencoding encoding of the font\n"\ + " (default: 8a (AdobeStandardEncoding))\n\n"\ + " -o, --otffontfeatures choosing Opentype font features\n"\ + " (default: -fkern -fliga)\n\n"\ + " -u, --uninstall will uninstall the font family. You must specify\n"\ + " --localtexmf and --fontsubdir\n\n"\ + " -R, --rmdefault installs font family as roman (serif) font family (default)\n\n"\ + " -S, --sfdefault installs font family as sans serif font family\n\n"\ + " -T, --ttdefault installs font family as typewriter font family\n\n"\ + " -V, --version will print the version number of `basename $0`\n\n"\ + " -h, --help will print this help statement\n\n"\ + " See http://latex.josef-kleber.de/index.htm or\n"\ + " http://latex.josef-kleber.de/en_index.htm\n"\ + " for more information" + exit 0; +} +function printVersion() +{ + echo "This is version $VERSION of `basename $0`" + exit 0; +} +# +if [ $# -eq 0 ] +then + echo -e "`basename $0`: Could not find command line arguments.\nUse the '--help' option for explanation." + echo -e "Continue with default script variables? (y/n)" + read ANSWER + if [ $ANSWER = "n" -o $ANSWER = "N" ] + then + exit 1 + fi +fi +# +LONGOPTS="fontfamily:,fontname:,fontcommand:,fontscaleprefix:,fonttype:,packagename:,packagedate:,packageversion:,mapfilename:,origfilename,localtexmf:,fontsubdir:,fontencoding:,otffontfeatures:,uninstall,rmdefault,sfdefault,ttdefault,version,help" +SHORTOPTS="f:n:c:P:t:p:d:v:m:Ol:s:e:o:uRSTVh" +ARGS=$(getopt -l "$LONGOPTS" "$SHORTOPTS" "$@") +if [ $? -ne 0 ] +then + echo -e "`basename $0`: Could not process command line arguments.\nUse the '--help' option for explanation." + exit 1 +fi +# +eval set -- "$ARGS" +# +while [ $# -gt 0 ]; do + ARG=$1 + case "$ARG" in + --help|-h) shift; printHelp;; + --version|-V) shift; printVersion;; + --rmdefault|-R) shift; INSTALLAS="rmdefault";; + --sfdefault|-S) shift; INSTALLAS="sfdefault";; + --ttdefault|-T) shift; INSTALLAS="ttdefault";; + --uninstall|-u) shift; UNINSTALL="true";; + --fontfamily|-f) shift; FONTFAMILY="$1"; shift;; + --fontname|-n) shift; FONTNAME="$1"; shift;; + --fontcommand|-c) shift; FONTCOMMAND="$1"; shift;; + --fontscaleprefix|-P) shift; FONTSCALEPREFIX="$1"; shift;; + --fonttype|-t) shift; FONTTYPE="$1"; shift;; + --packagename|-p) shift; PACKAGENAME="$1"; shift;; + --packagedate|-d) shift; PACKAGEDATE="$1"; shift;; + --packageversion|-v) shift; PACKAGEVERSION="$1"; shift;; + --mapfilename|-m) shift; MAPFILENAME="$1"; shift;; + --origfontname|-O) shift; OFN="true";; + --localtexmf|-l) shift; LOCALTEXMF="$1"; shift;; + --fontsubdir|-s) shift; FONTSUBDIR="$1"; shift;; + --fontencoding|-e) shift; FONTENCODING="$1"; shift;; + --otffontfeatures|-o) shift; FONTFAMILY="$1"; shift;; + --) shift; break;; + *) break;; + esac +done +# +if [ -z $MAPFILENAME ] +then + MAPFILENAME=$FONTFAMILY +fi +# +typeset -i STEP=0 +# +if [ $UNINSTALL = "true" ] +then + DIR="${LOCALTEXMF}/fonts/tfm/${FONTSUBDIR}/" + echo -e "$\n\n$DIR" + DIR="${LOCALTEXMF}/fonts/vf/${FONTSUBDIR}/" + echo $DIR + DIR="${LOCALTEXMF}/fonts/type1/${FONTSUBDIR}/" + echo $DIR + DIR="${LOCALTEXMF}/fonts/map/dvips/${FONTSUBDIR}/" + echo $DIR + DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/" + echo $DIR + echo -e "\n\nDo you want to delete these directories? (y/n)" + read ANSWER + if [ $ANSWER = "y" -o $ANSWER = "Y" ] + then + DIR="${LOCALTEXMF}/fonts/tfm/${FONTSUBDIR}/" + rm -f -r $DIR + DIR="${LOCALTEXMF}/fonts/vf/${FONTSUBDIR}/" + rm -f -r $DIR + DIR="${LOCALTEXMF}/fonts/type1/${FONTSUBDIR}/" + rm -f -r $DIR + DIR="${LOCALTEXMF}/fonts/map/dvips/${FONTSUBDIR}/" + rm -f -r $DIR + DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/" + rm -f -r $DIR + exit 0 + else + exit 1 + fi +fi +# +if [ $FONTTYPE = "ttf" ] +then + ((STEP++)) + echo -e "\n\n$STEP) Convert font(s) to Postscript Type1\n\n" + for file in *.TTF; + do + mv "$file" "${file%TTF}ttf" 2>>/dev/null; + done + for file in *.ttf; + do + ttf2pt1 -a -b -l adobestd "$file"; + done +fi +# +if [ $FONTTYPE = "otf" ] +then + ((STEP++)) + echo -e "\n\n$STEP) Convert font(s) to Postscript Type1\n\n" + for file in *.OTF; + do + mv "$file" "${file%OTF}otf" 2>>/dev/null; + done + for file in *.otf; + do + otftotfm $OTFFONTFEATURES -e - "$file" 555; + done + for file in *.pfb; + do + pf2afm "$file"; + done + rm *.tfm + rm *.enc +fi +# +echo -e "\n\nTry to rename the font(s) automatically? (y/n)" +read ANSWER +if [ $ANSWER = "y" -o $ANSWER = "Y" ] +then + ((STEP++)) + echo -e "\n\n$STEP) Renaming fonts\n\n" + mkdir -p Backup + cp *.afm *.AFM ./Backup 2>>/dev/null + cp *.pfb *.PFB ./Backup 2>>/dev/null + for file in *.AFM; + do + mv "$file" "${file%AFM}afm" 2>>/dev/null; + done + for file in *.PFB; + do + mv "$file" "${file%PFB}pfb" 2>>/dev/null; + done + FONTNUMBER=$(ls -al *.pfb 2>>/dev/null | wc -l) + if [ $FONTNUMBER -le 1 ] + then + if [ $FONTNUMBER -eq 0 ] + then + echo "No font(s) to rename!" + exit 1 + else + for file in *.afm; + do + mv "$file" ${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; + done + for file in *.pfb; + do + mv "$file" ${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; + echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.pfb}/" >>map.sed; + done + fi + else + mkdir -p Rename + # rename small caps font(s) + FILES=$(grep -e "Smc" -e "Caps" -e "SCOsF" *.afm | cut -d':' -f1 | uniq) + for file in $FILES + do + FWEIGHT=$(grep -e "Weight" "$file" | cut -d' ' -f2 | sed -e "s/\r//") + if [ $FWEIGHT = "Bold" -o $FWEIGHT = "Xbold" -o $FWEIGHT = "XBold" ] + then + FONTCUT="bc" + else + FONTCUT="rc" + fi + mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; + mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; + echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; + done + # rename the light font(s) + FILES=$(grep -e "Light" *.afm | cut -d':' -f1 | uniq) + for file in $FILES + do + ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) + if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] + then + FONTCUT="li" + else + FONTCUT="l" + fi + SMFFSTY="\RequirePackage{softmakerfreefont}%" + mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; + mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; + echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; + done + # rename the semi(bold) font + FILES=$(grep -e "Semibold" -e "SemiBold" *.afm | cut -d':' -f1 | uniq) + for file in $FILES + do + ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) + if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] + then + FONTCUT="si" + else + FONTCUT="s" + fi + SMFFSTY="\RequirePackage{softmakerfreefont}%" + mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; + mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; + echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; + done + # rename the demi(bold) font + FILES=$(grep -e "FontName" -e "FullName" *.afm | grep -e "Demi" -e "Demibold" -e "DemiBold" | cut -d':' -f1 | uniq) + for file in $FILES + do + ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) + if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] + then + FONTCUT="di" + else + FONTCUT="d" + fi + SMFFSTY="\RequirePackage{softmakerfreefont}%" + mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; + mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; + echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; + done + # rename the extra bold font + FILES=$(grep -e "Extrabold" -e "ExtraBold" *.afm | cut -d':' -f1 | uniq) + for file in $FILES + do + ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) + if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] + then + FONTCUT="xi" + else + FONTCUT="x" + fi + SMFFSTY="\RequirePackage{softmakerfreefont}%" + mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; + mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; + echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; + done + # rename the ultra bold/heavy font + FILES=$(grep -e "Heavy" -e "Ultrabold" -e "UltraBold" *.afm | cut -d':' -f1 | uniq) + for file in $FILES + do + ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) + if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] + then + FONTCUT="ui" + else + FONTCUT="u" + fi + SMFFSTY="\RequirePackage{softmakerfreefont}%" + mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; + mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; + echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; + done + # rename the bold font + FILES=$(grep -e "Bold" -e "bold" *.afm | cut -d':' -f1 | uniq) + for file in $FILES + do + ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) + if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] + then + FONTCUT="bi" + else + FONTCUT="b" + fi + mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; + mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; + echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; + done + # rename the regular font + FILES=$(grep -e "Regular" -e "Medium" -e "Book" --exclude=installfont * | grep -e ".afm" | cut -d':' -f1 | uniq) + for file in $FILES + do + ITALICANGLE=$(grep -e "ItalicAngle" "$file" | tr ' ' '+' | cut -d'+' -f2 | cut -d'.' -f1) + if [ $ITALICANGLE -lt 0 -o $ITALICANGLE -gt 0 ] + then + FONTCUT="ri" + else + FONTCUT="r" + fi + mv "$file" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.afm; + mv "${file%afm}pfb" ./Rename/${FONTFAMILY}${FONTCUT}${FONTENCODING}.pfb; + echo -e "s/<${FONTFAMILY}${FONTCUT}${FONTENCODING}/<${file%.afm}/" >>map.sed; + done + mv ./Rename/* . + rmdir ./Rename + fi + ls -al *.pfb *.afm + echo -e "\n\nPlease check the font name(s). Continue? (y/n)" + read ANSWER + if [ $ANSWER = "n" -o $ANSWER = "N" ] + then + rm *.afm + rm *.pfb + rm *.sed + mv ./Backup/* . + rmdir ./Backup + exit 1 + fi +fi +# +((STEP++)) +echo -e "\n\n$STEP) Creating metrics and virtual fonts\n\n" +cat >${FONTFAMILY}-drv.tex <<EOF +\input fontinst.sty +\needsfontinstversion{1.926} +\recordtransforms{${FONTFAMILY}-rec.tex} +\latinfamily{${FONTFAMILY}}{} +\endrecordtransforms +\bye +EOF +tex ${FONTFAMILY}-drv.tex +# +((STEP++)) +echo -e "\n\n$STEP) Compiling metrics and virtual fonts\n\n" +for file in *.pl; +do + pltotf $file ${file%pl}tfm; +done +for file in *.vpl; +do + vptovf $file ${file%vpl}vf ${file%vpl}tfm; +done +# +((STEP++)) +echo -e "\n\n$STEP) Creating the map file\n\n" +cat >${FONTFAMILY}-map.tex <<EOF +\input finstmsc.sty +\resetstr{PSfontsuffix}{.pfb} +\adddriver{dvips}{${FONTFAMILY}.map} +\input ${FONTFAMILY}-rec.tex +\donedrivers +\bye +EOF +tex ${FONTFAMILY}-map.tex +if [ $OFN = "true" ] +then + sed -f map.sed ${FONTFAMILY}.map >${MAPFILENAME}.map + unix2dos ${MAPFILENAME}.map 2>>/dev/null; + rm ${FONTFAMILY}.map + UMAP="${MAPFILENAME}" +else + UMAP="${FONTFAMILY}" +fi +# +((STEP++)) +echo -e "\n\n$STEP) Creating the style file" +cat >${PACKAGENAME}.sty <<EOF +\NeedsTeXFormat{LaTeX2e}% +\ProvidesPackage{$PACKAGENAME}[$PACKAGEDATE $PACKAGEVERSION $FONTNAME]% +${SMFFSTY}% +\RequirePackage{textcomp}% +\RequirePackage{xkeyval}% +\define@key{${PACKAGENAME}.sty}{scaled}[1.0]% +{% + \def\\${FONTSCALEPREFIX}@scale{#1}% +}% +\define@key{${PACKAGENAME}.sty}{leading}[1.0]% +{% + \linespread{#1}% +}% +\ExecuteOptionsX{scaled}% +\ProcessOptionsX\relax% +\renewcommand*{\\${INSTALLAS}}{$FONTFAMILY}% +\newcommand\\${FONTCOMMAND}{\fontfamily{$FONTFAMILY}\fontseries{m}\fontshape{n}\selectfont}% +\endinput% +EOF +# +((STEP++)) +echo -e "\n\n$STEP) Insert scale factor into the fd files" +cat >installfont.sed <<EOF +9 i\\ +\\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 +s/<-> /<-> \\\\${FONTSCALEPREFIX}@@scale / +EOF +# +for file in *.fd; +do + mv $file ${file%fd}fdb; + sed -f installfont.sed ${file%fd}fdb >$file; +done +# +((STEP++)) +echo -e "\n\n$STEP) Installing font(s) and support files" +DIR="${LOCALTEXMF}/fonts/tfm/${FONTSUBDIR}/" +if [ ! -d $DIR ] +then + mkdir -p $DIR +fi +mv *.tfm $DIR +DIR="${LOCALTEXMF}/fonts/vf/${FONTSUBDIR}/" +if [ ! -d $DIR ] +then + mkdir -p $DIR +fi +mv *.vf $DIR +DIR="${LOCALTEXMF}/fonts/type1/${FONTSUBDIR}/" +if [ $OFN = "true" ] +then + cd Backup + if [ ! -d $DIR ] + then + mkdir -p $DIR + fi + cp *.pfb $DIR + cd .. +else + if [ ! -d $DIR ] + then + mkdir -p $DIR + fi + cp *.pfb $DIR +fi +DIR="${LOCALTEXMF}/fonts/map/dvips/${FONTSUBDIR}/" +if [ ! -d $DIR ] +then + mkdir -p $DIR +fi +mv *.map $DIR +DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/" +if [ ! -d $DIR ] +then + mkdir -p $DIR +fi +mv *.fd $DIR +DIR="${LOCALTEXMF}/tex/latex/${FONTSUBDIR}/" +if [ ! -d $DIR ] +then + mkdir -p $DIR +fi +mv *.sty $DIR +# +((STEP++)) +echo -e "\n\n$STEP) Include the map file" +echo -e "\n\n" +updmap --enable Map ${UMAP}.map +rm *.mtx +rm *.pl +rm *.vpl +rm *.log +rm *.tex +rm *.fdb +rm *.sed +if [ -d Backup ] +then + rm *.afm + rm *.pfb + mv ./Backup/* . + rmdir ./Backup +fi +echo -e "\n\nThe font(s) should be installed now!" +exit 0
\ No newline at end of file |