#!/bin/bash # # otf-to-latex.sh, written 25 August 2005 by Michael A. Cleverly # # This script is documented at http://blog.cleverly.com/permalinks/180.html # Distributed under the OLL: # Get it, use it, share it, improve it, but don't blame me. # # # You'll need to edit these if you're installing something other than # Adobe's MinionPro. # # You should copy the $TYPEFACE-*.otf fonts, along with this script, into # a temporary working directory and run the script from there. # VENDOR=adobe TYPEFACE=MinionPro # Hopefully you won't need to edit anything following this... function need_program() { local WHICH local PROGRAM PROGRAM="$1" if [ -z "$PROGRAM" ] then echo "need_program requires the name of a program to look for..." exit 1 fi WHICH=`which "$PROGRAM"` if [ -z "$WHICH" ] then echo "Could not find a required program, $PROGRAM, in the \$PATH" exit 1 else echo "Using $PROGRAM found at $WHICH" fi } need_program kpsewhich; kpsewhich --version need_program otftotfm; otftotfm --version need_program otfinfo; otfinfo --version need_program cfftot1; cfftot1 --version need_program pltotf; pltotf --version need_program t1dotlessj; t1dotlessj --version need_program vptovf; vptovf --version need_program texhash; texhash --version need_program updmap; updmap --version need_program pdflatex; pdflatex --version need_program fontinst; ls -l `which fontinst` need_program basename need_program sed # Discover the path to the top of local TEXMF directory tree LTEX=`kpsewhich --expand-var '$TEXMFLOCAL'` if [ "$LTEX" = "" ] then echo "FATAL: Can't divine where \$TEXMFLOCAL is!" exit 1 fi if [ ! -d "$LTEX" ] then echo "FATAL: $LTEX is not a directory" exit 1 fi if [ ! -w "$LTEX" ] then echo "FATAL: You don't have write permission to $LTEX :-(" exit 1 fi if [ "`kpsewhich ly1.enc`" = "" ] then echo "FATAL: Cannot find a required encoding file!" echo echo "You need to copy (at least) the ly1 encoding from the fontools/share" echo "to somewhere under $LTEX/fonts/enc" echo echo "Otherwise otftotfm won't be able to convert the font..." echo echo "You can get fontools from:" echo echo " http://www.ctan.org/tex-archive/fonts/utilities/fontools/" exit 1 fi function die() { echo "An error occured while working on $FILE" exit 1 } # clean up previous version if it exists FILE="$TYPEFACE.bat" rm -rf $FILE* tmp/ test.* mkdir tmp/ autoinst --manual $TYPEFACE*.otf || die if [ ! -r $FILE ]; then die; fi # Trying w/o --pl sed -e 's/^otftotfm /otftotfm --verbose --no-updmap --tfm-directory=. --pl-directory=. --vf-directory=. --vpl-directory=. --encoding-directory=. --type1-directory=. /' -e 's/\(.*\) \([^ ]*\)$/FILE=\2; \1 \2 || die/' $TYPEFACE.bat | sed -e 's/ --pl / /' > $TYPEFACE.bat.sh . $TYPEFACE.bat.sh echo echo echo "Attempting to convert .pl files to .tfm files (if necessary)" echo for PL in `ls *--$TYPEFACE-*.pl` do if [ ! -f "$PL" ]; then continue; fi FILE=`basename $PL .pl`.tfm if [ -f "$FILE" ] then echo "The .tfm version of $PL already exists" else pltotf -verbose "$PL" "$FILE" || die fi done echo echo "Done converting .pl files to .tfm files" echo function move_files() { EXTENSION=$1 DESTINATION=$2 if [ "$DESTINATION" = "" ] then echo "\$@ = $@" echo "move_files called with incorrect parameters" exit 1 fi FILE="$DESTINATION/" mkdir -p "$FILE" || die echo "*.$EXTENSION files will go in $DESTINATION/" ls -l `pwd`/*.$EXTENSION | tee ls.tmp N_FILES=`cat ls.tmp | wc -l` if [ ! -w "$DESTINATION" ] then echo "FATAL: You don't have write permission to $DESTINATION" exit 1 fi if [ $N_FILES -eq 0 ] then echo "No .$EXTENSION files found to be moved to $DESTINATION" else FILE=$DESTINATION mkdir -p $FILE/ || die cp `pwd`/*.$EXTENSION tmp/ mv -fv `pwd`/*.$EXTENSION $DESTINATION/ fi } # DIRECTORY VARIABLES # Cf. http://www.tug.org/texlive/mapenc.html move_files tfm "$LTEX/fonts/tfm/$VENDOR/$TYPEFACE" move_files vf "$LTEX/fonts/vf/$VENDOR/$TYPEFACE" move_files pl "$LTEX/fonts/pl/$VENDOR/$TYPEFACE" move_files vpl "$LTEX/fonts/vpl/$VENDOR/$TYPEFACE" move_files pfb "$LTEX/fonts/type1/$VENDOR/$TYPEFACE" move_files enc "$LTEX/fonts/enc/dvips/$VENDOR" move_files map "$LTEX/fonts/map/dvips/$VENDOR" move_files fd "$LTEX/tex/latex/$VENDOR" move_files sty "$LTEX/tex/latex/$VENDOR" # Rebuild the teTeX databases texhash $LTEX updmap # Create a test document echo "\documentclass{article}" > test.tex echo "\usepackage{$TYPEFACE}" >> test.tex echo "\begin{document}" >> test.tex echo "This is a test. This is only a test. Have a nice day." >> test.tex echo "\end{document}" >> test.tex # Big test: run it through pdflatex pdflatex test.tex