[pdftex] font expansion and virtual fonts

Oliver Heins olli at sopos.org
Thu Dec 12 16:41:34 CET 2002


I've experimented with pdftex's feature "font expansion" and must say
that I'm very much impressed.  The result looks great!

However, I don't know get it to work with virtual fonts (say a font
named pegr9d.tfm).  Yesterday night, during the local TUG meeting there
was the suggestion to try it with Thanh's mktextfm hack
(<ftp://ftp.cstug.cz/pub/tex/local/cstug/thanh/pdftex/ext>).
Unfortunately, we didn't get it to work.

We invoked the new script with "sh -v mktextfm putr8a+20" for an easy
run.  On the first try, we ran into an error saying "\_a_true" was
undefined.  Adding a line "\newif\if_a_" in ufntinst.sty helped for this
one, but then came a new error, saying "\record_transform" is
undefined.

Then, all the experts said: Uhhh, ask Thanh.  So I'm doing. :-)

Below is the output of "sh -v mktextfm putr8a+20"

Thanks for your help,
olli

,----
| #!/bin/sh
| # mktextfm -- make a new TFM file, because one wasn't found.
| # 
| # (If you change or delete the word `original' on the previous line,
| # installation won't write this script over yours.)
| # 
| # te at informatik.uni-hannover.de, kb at mail.tug.org, and infovore at xs4all.nl.
| # Public domain.
| 
| version='$Id: mktextfm,v 1.17 1998/02/16 08:56:13 olaf Exp $'
| progname=`echo $0 | sed 's%.*/%%'`
| echo $0 | sed 's%.*/%%'
| usage="Usage: $progname [--destdir DESTDIR] FONT.
| 
| Makes a TFM file for FONT, if possible. Use DESTDIR for the root of where
| to install into, either the absolute directory name to use (if it starts
| with a /) or relative to the default DESTDIR (if not)."
| 
| # Handle non-positional options, except for --version/--help
| while test $# -gt 0; do
|   case "$1" in
|     --destdir) shift; DEST="$1"; shift ;;
|     --destdir=*) DEST="`echo \"$1\" | sed 's/--destdir=//'`"; shift ;;
|     --version|-version) break ;;
|     --help|-help) break ;;
|     *) break ;;
|   esac
| done
| 
| # Common code for all scripts.
| : ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`}
| kpsewhich --expand-path='$TEXMFMAIN'
| : ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`}
| kpsewhich --format='web2c files' mktex.opt
| test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT="$MT_TEXMFMAIN/web2c/mktex.opt"
| if test ! -f "$MT_MKTEX_OPT"; then
|   echo "$progname: Cannot find mktex.opt; check your installation." >&2
|   exit 1
| fi
| 
| . "$MT_MKTEX_OPT"
| # mktex.opt -- common mktex* options, etc.
| # Meant to be sourced after $usage, $version, and $MT_TEXMFMAIN have been set.
| # 
| # te at informatik.uni-hannover.de and kb at mail.tug.org. Public domain.
| # $Id: mktex.opt,v 1.30 2001/11/10 20:15:51 olaf Exp $
|  
| if test "x$1" = x--help || test "x$1" = x-help; then
|   echo "$usage"
|   exit 0
| elif test "x$1" = x--version || test "x$1" = x-version; then
|   echo "`basename $0` $version"
|   kpsewhich --version
|   exit 0
| elif test $# -lt ${mt_min_args-1}; then
|   echo "$0: Missing argument(s)." >&2
|   echo "Try \``basename $0` --help' for more information." >&2
|   exit 1
| elif test $# -gt ${mt_max_args-1}; then
|   num=$#
|   while test $# -gt `expr $num - ${mt_max_args-1}`; do shift; done
|   echo "$0: Extra arguments $*." >&2
|   echo "Try \``basename $0` --help' for more information." >&2
|   exit 1
| fi
| 
| # MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use `;' to separate
| # directories in path lists whereas Unix uses `:'.
| # Create a variable that holds the right character to be used by the scripts.
| if test -z "$COMSPEC" && test -z "$ComSpec"; then SEP=':'; else SEP=';'; fi
| 
| # TEMPDIR needs to be unique to each process because of the possibility of two
| # people running dvips (or whatever) simultaneously.
| if test -n "$TMPDIR"; then
|   TEMPDIR="${TMPDIR}/mt$$.tmp"
| else
|   TEMPDIR="/tmp/mt$$.tmp"
| fi
| 
| # We want to output only filenames to standard output, but it's too
| # error-prone to write the scripts that way, so we direct stdout here.
| STDOUT="$TEMPDIR/mt$$.out"
| 
| # We will change search paths to include $KPSE_DOT. This is necessary
| # since we cd to $TEMPDIR.
| : ${KPSE_DOT=`pwd`}; export KPSE_DOT
| pwd
| 
| # Clean up on normal or abnormal exit.
| # The "cd /" is for MS-DOS and MS-Windows, where there is a separate
| # current directory on each drive, and therefore "cd $KPSE_DOT" might
| # still leave $TMPDIR current directory on its drive, in which case it
| # cannot be removed.
| trap 'rc=$?; cd /; cd "$KPSE_DOT"; test -f "$STDOUT" && cat "$STDOUT"; rm -rf "$TEMPDIR"; exit $rc' \
|   0 1 2 3 7 13 15
| 
| mkdir "$TEMPDIR" || exit 1
| cd "$TEMPDIR" || exit 1
| 
| # The alternative location for fonts.  The directory need not exist,
| # so we use --expand-var here.  We also perform a sanity check.
| : ${MT_VARTEXFONTS=`kpsewhich --expand-var='$VARTEXFONTS' | sed 's%^!!%%'`}
| kpsewhich --expand-var='$VARTEXFONTS' | sed 's%^!!%%'
| if test -z "$MT_VARTEXFONTS"; then
|   echo "$0: VARTEXFONTS is not defined.  Defaulting to \`$KPSE_DOT'." >&2
|   MT_VARTEXFONTS='$KPSE_DOT'
| fi
| 
| # The supporting scripts:
| : ${MT_MKTEXNAM=`kpsewhich --format='web2c files' mktexnam`}
| kpsewhich --format='web2c files' mktexnam
| test -n "$MT_MKTEXNAM" || MT_MKTEXNAM="$MT_TEXMFMAIN/web2c/mktexnam"
| : ${MT_MKTEXNAM_OPT=`kpsewhich --format='web2c files' mktexnam.opt`}
| kpsewhich --format='web2c files' mktexnam.opt
| test -n "$MT_MKTEXNAM_OPT" || MT_MKTEXNAM_OPT="$MT_TEXMFMAIN/web2c/mktexnam.opt"
| : ${MT_MKTEXDIR=`kpsewhich --format='web2c files' mktexdir`}
| kpsewhich --format='web2c files' mktexdir
| test -n "$MT_MKTEXDIR" || MT_MKTEXDIR="$MT_TEXMFMAIN/web2c/mktexdir"
| : ${MT_MKTEXDIR_OPT=`kpsewhich --format='web2c files' mktexdir.opt`}
| kpsewhich --format='web2c files' mktexdir.opt
| test -n "$MT_MKTEXDIR_OPT" || MT_MKTEXDIR_OPT="$MT_TEXMFMAIN/web2c/mktexdir.opt"
| : ${MT_MKTEXUPD=`kpsewhich --format='web2c files' mktexupd`}
| kpsewhich --format='web2c files' mktexupd
| test -n "$MT_MKTEXUPD" || MT_MKTEXUPD="$MT_TEXMFMAIN/web2c/mktexupd"
| 
| # mktexupd and mktexlsr make sure they're coordinated via this.  A copy of
| # the first string is found in mktexlsr.
| ls_R_magic='% ls-R -- filename database for kpathsea; do not change this line.'
| # Old ls-R files should continue to work.
| old_ls_R_magic='% ls-R -- maintained by MakeTeXls-R; do not change this line.'
| 
| # Read defaults from mktex.cnf if that file exists. Can be used to
| # overwrite anything defined below. Please use the same syntax as
| # given here (e.g. ``: ${MODE=ljfour}'', not just ``MODE=ljfour'', as
| # this can cause trouble (e.g. when the mode for mktexnam is
| # already specified on the command line).
| : ${MT_MKTEX_CNF=`kpsewhich --format='web2c files' mktex.cnf`}
| kpsewhich --format='web2c files' mktex.cnf
| test -n "$MT_MKTEX_CNF" && test -r "$MT_MKTEX_CNF" && . "$MT_MKTEX_CNF"
| # The mktex.cnf file, if it exists, can be used to tailor a setup to
| # local conditions.  If you use the mktex scripts, this file can contain
| # generic bourne shell code.  However, the C emulations of the scripts
| # do not handle anything beyond simple assignment of variables, and doing
| # more is not exactly recommended.
| #
| # To assign variables, use constructs like the examples below, which only
| # set unassigned variables.  The scripts may malfunction if you do
| # otherwise.
| #
| # Some examples of what you can the mktex.cnf file for:
| : ${MT_FEATURES=appendonlydir:varfonts}
| # : ${MODE=ljfour}
| # : ${BDPI=600}
| # : ${ps_to_pk=gsftopk}
| 
| # Possible features: appendonlydir dosnames fontmaps nomfdrivers nomode
| #                    stripsupplier striptypeface varfonts.
| if test -n "$COMSPEC"; then
|   : ${MT_FEATURES=appendonlydir:dosnames}
| else
|   : ${MT_FEATURES=appendonlydir}
| fi
| : ${MODE=ljfour}
| : ${BDPI=600}
| : ${DPI=600}
| : ${MAG=1.0}
| : ${ps_to_pk=gsftopk} # some prefer ps2pk
| 
| # Allow fonts to be read and written (especially in case we make
| # directories) by everyone.
| umask 0
| 
| # Cache values that may be useful for recursive calls.
| export MT_MKTEX_OPT MT_MKTEX_CNF 
| export MT_MKTEXNAM MT_MKTEXNAM_OPT
| export MT_MKTEXDIR MT_MKTEXDIR_OPT
| export MT_MKTEXUPD
| export MT_TEXMFMAIN MT_VARTEXFONTS
| 
| # start of redirection stdout -> stderr, stdin <- /dev/null
| (
| 
| NAME=`basename "$1" .tfm`
| MAG=1
| #DEST="$2"
| DPI=$BDPI
| 
| OIFS=$IFS; IFS=$SEP
| set x `"$MT_MKTEXNAM" $NAME $DPI $MODE $DEST`; shift
| IFS=$OIFS
| 
| PKDEST="$1"
| TFMDEST="$2"
| PKDESTDIR=`echo "$PKDEST" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
| TFMDESTDIR=`echo "$TFMDEST" | sed 's%/[^/][^/]*$%%'`
| PKNAME=`basename "$PKDEST"`
| TFMNAME=$NAME.tfm
| GFNAME=$NAME.$DPI'gf'
| 
| if test -r "$TFMDESTDIR/$TFMNAME"; then
|   echo "$progname: $TFMDESTDIR/$TFMNAME already exists." >&2
|   echo "$TFMDESTDIR/$TFMNAME" >$STDOUT
|   "$MT_MKTEXUPD" "$TFMDESTDIR" $TFMNAME
|   exit
| fi
| 
| # Try to create the destdir first. Do not create fonts, if this fails.
| "$MT_MKTEXDIR" "$TFMDESTDIR"
| if test ! -d "$TFMDESTDIR"; then
|   echo "$progname: mktexdir $TFMDESTDIR failed."
|   exit 1
| fi
| 
| case "$NAME" in
| cm*[+-][0-9]*|cs*[+-][0-9]*|vn*[+-][0-9]*)
|     BASE_MFNAME=`expr $NAME : '\(.*\)[+-][0-9]*$'`
|     EXPANSION=`expr $NAME : '.*\([+-][0-9]*\)$'`
|     echo "/^u#:=[0-9.]*\/[0-9.]*pt#;/a\\" > $NAME.sed
|     echo "u#:=u#$EXPANSION/1000u#;" >> $NAME.sed
|     sed -f $NAME.sed `kpsewhich $BASE_MFNAME.mf` > $NAME.mf
|     MFDESTDIR=`echo "$TFMDESTDIR" | sed 's%/tfm/%/source/%'`
|     "$MT_MKTEXDIR" "$MFDESTDIR" && mv -f $NAME.mf $MFDESTDIR
|     ;;
| tq*[+-][0-9]*)
|     BASE_MFNAME=`expr $NAME : '\(.*\)[+-][0-9]*$'`
|     EXPANSION=`expr $NAME : '.*\([+-][0-9]*\)$'`
|     echo "expansion_ratio := $EXPANSION;" > $NAME.mf
|     echo "input $BASE_MFNAME.mf" >> $NAME.mf
|     MFDESTDIR=`echo "$TFMDESTDIR" | sed 's%/tfm/%/source/%'`
|     "$MT_MKTEXDIR" "$MFDESTDIR" && mv -f $NAME.mf $MFDESTDIR
|     ;;
| *[+-][0-9]*)
|     EXPANSION_TAG=`expr $NAME : '.*\([+-][0-9]*\)$'`
|     ;;
| esac
| 
| if test "x$EXPANSION_TAG" = x; then
| cmd="mf \mode:=$MODE; mag:=$MAG; nonstopmode; input $NAME.mf"
| echo "$progname: Running $cmd"
| 
| $cmd </dev/null || {
|   grep '^!' $NAME.log >$$.errs 2>/dev/null
|   grep '^! Strange path' $$.errs >$$.strange 2>/dev/null
|   if cmp $$.errs $$.strange >/dev/null 2>&1 \
|     && test -s $$.strange >/dev/null 2>&1; then
|     echo "$progname: warning: \`$cmd' caused strange path errors." >&2
|   else
|     echo "$progname: \`$cmd' failed." >&2
|     test -s $NAME.log && mv -f $NAME.log "$KPSE_DOT"
|     exit 1;
|   fi
| }
| 
| else
| mktextfm.ext $NAME $TFMDESTDIR $STDOUT
| exit 0
| fi
| 
| test -r $TFMNAME || { echo "$progname: \`$cmd' failed to make $TFMNAME."; exit 1; }
| 
| # Install the TFM file carefully, since others may be working simultaneously.
| # Use cp when mv fails, since DOS will fail mv for deeply-nested directories.
| mv $TFMNAME "$TFMDESTDIR/tfm$$.tmp" 2>/dev/null \
|   || cp $TFMNAME "$TFMDESTDIR/tfm$$.tmp" || exit 1
| cd "$TFMDESTDIR" || exit 1
| chmod `kpsestat -xst,go-w .` tfm$$.tmp
| test -r $TFMNAME || mv tfm$$.tmp $TFMNAME || exit 1
| 
| # OK, success with the TFM.
| "$MT_MKTEXUPD" "$TFMDESTDIR" $TFMNAME
| echo "$TFMDESTDIR/$TFMNAME" >$STDOUT
| echo "$progname: $TFMDESTDIR/$TFMNAME: successfully generated." >&2
| 
| # Since we probably made a GF(->PK) file, too, may as well install it if
| # it's needed.
| cd $TEMPDIR
| if test -r $GFNAME && test ! -f "$PKDESTDIR/$PKNAME"; then
|   gftopk ./$GFNAME $PKNAME || exit 1
|   "$MT_MKTEXDIR" "$PKDESTDIR"
|   mv $PKNAME "$PKDESTDIR/pk$$.tmp" 2>/dev/null \
|     || cp $PKNAME "$PKDESTDIR/pk$$.tmp" || exit 1
|   cd "$PKDESTDIR" || exit 1
|   if test -f $PKNAME; then
|     rm -f pk$$.tmp
|   else
|     chmod `kpsestat -xst,go-w .` pk$$.tmp
|     mv pk$$.tmp $PKNAME
|     "$MT_MKTEXUPD" "$PKDESTDIR" $PKNAME
|   fi
| fi
| ) 1>&2 </dev/null
| basename "$1" .tfm
| "$MT_MKTEXNAM" $NAME $DPI $MODE $DEST
| echo "$PKDEST" | sed 's%/[^/][^/]*$%%'
| echo "$TFMDEST" | sed 's%/[^/][^/]*$%%'
| basename "$PKDEST"
| expr $NAME : '.*\([+-][0-9]*\)$'
| egrep: /home/olli/texmf/fontname/mminstance.map: Datei oder Verzeichnis nicht gefunden
| mktfm8z putr8a+20 putr8a
| TEXINPUTS = /tmp/mt2457.tmp:$TEXMF/tex/{plain,generic,}//
| This is TeX, Version 3.14159 (Web2C 7.3.7)
| (/tmp/mt2457.tmp/a.tex (/home/olli/texmf/tex/thanh/ufntinst.sty
| (/usr/share/texmf/tex/fontinst/base/fontinst.sty
| (/usr/share/texmf/tex/latex/graphics/trig.sty)
| No file fontinst.rc.
| )) (/tmp/mt2457.tmp/putr8a.afm
| ! Undefined control sequence.
| <argument> \italcorr_expression 
|                                 \x_width \bbox_llx \bbox_urx \bbox_lly \bbox...
| 
| \eval_expr #1->\global \result =#1
|                                   \relax 
| \afm_char ...x_llx \bbox_urx \bbox_lly \bbox_ury }
|                                                   \out_line {\ifnum -1<\char...
| 
| \afm_line #1^^M->\afm_command #1 \end_of_line 
|                                               \afm_line 
| l.23 C 32 ; WX 225 ; N space ; B 0 0 0 0 ;
|                                           
| ? 
| ! Emergency stop.
| <argument> \italcorr_expression 
|                                 \x_width \bbox_llx \bbox_urx \bbox_lly \bbox...
| 
| \eval_expr #1->\global \result =#1
|                                   \relax 
| \afm_char ...x_llx \bbox_urx \bbox_lly \bbox_ury }
|                                                   \out_line {\ifnum -1<\char...
| 
| \afm_line #1^^M->\afm_command #1 \end_of_line 
|                                               \afm_line 
| l.23 C 32 ; WX 225 ; N space ; B 0 0 0 0 ;
|                                           
| No pages of output.
| Transcript written on a.log.
| This is TeX, Version 3.14159 (Web2C 7.3.7)
| (/tmp/mt2457.tmp/b.tex (/home/olli/texmf/tex/thanh/ufntinst.sty
| (/usr/share/texmf/tex/fontinst/base/fontinst.sty
| (/usr/share/texmf/tex/latex/graphics/trig.sty)
| No file fontinst.rc.
| )) (/usr/share/texmf/tex/fontinst/base/8r.etx)
| ! Undefined control sequence.
| \mtxtomtx ...sion }}\out_line {}\record_transform 
|                                                   {#2}{\string \frommtx {#1}...
| 
| \transformfont ...2\mtxtomtx {\str {afm-name}}{#1}
|                                                   \mtxtopl {#1}{#1}}
| \installcsfont ...ncodefont {8r}{\frommtx {#4#3}}}
|                                                   \transformfont {#2x#3}{\re...
| l.4 \installcsfont{putr8a}{putr8r}{+20}{putr8a}
|                                                
| ? 
| ! Emergency stop.
| \mtxtomtx ...sion }}\out_line {}\record_transform 
|                                                   {#2}{\string \frommtx {#1}...
| 
| \transformfont ...2\mtxtomtx {\str {afm-name}}{#1}
|                                                   \mtxtopl {#1}{#1}}
| \installcsfont ...ncodefont {8r}{\frommtx {#4#3}}}
|                                                   \transformfont {#2x#3}{\re...
| l.4 \installcsfont{putr8a}{putr8r}{+20}{putr8a}
|                                                
| No pages of output.
| Transcript written on b.log.
| pltotf: Need one or two file arguments.
| Try `pltotf --help' for more information.
| vptovf: Need one to three file arguments.
| Try `vptovf --help' for more information.
| mv: Aufruf von stat für »*.tfm« nicht möglich: Datei oder Verzeichnis nicht gefunden
| /usr/share/texmf/web2c/mktexupd: /var/spool/texmf/tfm/adobe/utopia/*.tfm not a file.
| mv: Aufruf von stat für »*.vf« nicht möglich: Datei oder Verzeichnis nicht gefunden
| /usr/share/texmf/web2c/mktexupd: /var/spool/texmf/vf/adobe/utopia/*.vf not a file.
| rc=$?; cd /; cd "$KPSE_DOT"; test -f "$STDOUT" && cat "$STDOUT"; rm -rf "$TEMPDIR"; exit $rc
`----




More information about the pdftex mailing list