> I usually don't do that. The reason is that the lifecycle
> of a typical document, at least of the ones I usually have,
> is very different from that of typical software: My documents
> are written at a certain time, then finished, and remain
> essentially unmodified from that point on. Nevertheless, I
> do want to be able to regenerate them years later. Thus, if
> I would keep the macros separate from the document, I would
> have to worry about compatibility. On the other hand, the
> old documents typically do not benefit from bugfixes to the
> macros, since a bug that had affected them would typically
> have been fixed during their own development - this is since
> a relevant bug is a visible one (very different from software
> again). So what I do is: I keep the macros with each document
> and copy the best or latest version of them each time I start
> a new one. At least for my situation, I've found that this is
> by far the most convenient approach.
I agree. This was also what I had in mind when I said
"keeping the actual text and the formatting macros separate".
I was thinking of "separate" as in "not having text and macros
intermingled in the same file".
In principle, one would also have to keep the necessary fonts
together with the document. But the font modifications I was
thinking of are more in the sense of fixing design deficiencies
that shouldn't have been there in the first place [okay, that
goes for *all* software bugs], and, furthermore, these are not
changes one would make on a document-by-document basis (in
contrast to customization of the macros, which are usually
not bug fixes but adaptations to the style of the document).
Reproducing a document *exactly* usually isn't my main concern
(you can save a PDF for that). I also find that my views on
what's important in typography change over the years, so that
when I need a new copy of an old document I usually reformat
it anyway (what's important is the text content). But still,
keeping a reference version around is handy, and here your idea
of keeping font adaptations such as kernpairs (as opposed to
the complete font files themselves) together with the document
is particularly attractive -- not necessarily for the purpose
of being able to exactly reproduce the document, but instead
as a personal reminder of what you thought was important when
initially formatting the document, and which might still be
relevant when switching to a different font, layout style, etc.
> I always try to avoid modifications to fonts; I often find
> the .char request handy in such situations.
I don't think I'm really keen on modifying fonts either.
I was just surprised to find that there's no real consensus
on how to position italic characters within the design grid.
----------------------------------------------------------------
Anyway, as promised, here's my font installation script
(as yet without provision for a "PFA-edited" directory;
I'm still thinking on how to best handle that).
The fonts are given the Postscript FontName as internalname.
This way the names should be reasonably unique and I don't
have to think up arbitrary new names. The recommended way
to access the fonts is with the 3-argument version of "fp".
E.g., at the beginning of the document say
.fp 1 TR Utopia-Regular
.fp 2 TI Utopia-Italic
.fp 7 HB LubalinGraph-Demi
(etc.)
.EQ
gfont TI
grfont TR
.EN
and then the rest of the document can simply assume that
font "TR" refers to the roman/regular font used for body
text, and font "HB" refers to a bold font used for section
headers, etc.
#!/bin/bash
# set -x
TERMSGR0=`tput sgr0` # normal (all attributes off)
TERMBOLD=`tput bold` # bold or extra bright
TERMSMSO=`tput smso` # standout (usually reverse video)
FONTDIR="$HOME/lib/fonts"
DITMAPSDIR="$FONTDIR"/DIT-edited/devps/generate
DITEDITDIR="$FONTDIR"/DIT-edited/devps
DITGENRDIR="$FONTDIR"/DIT-generated/devps
AFMORIGDIR="$FONTDIR"/AFM-original
AFMGENRDIR="$FONTDIR"/AFM-generated
AFMEDITDIR="$FONTDIR"/AFM-edited
PFAORIGDIR="$FONTDIR"/PFA-original
# PFAEDITDIR="$FONTDIR"/PFA-edited
GROFF_FONT_PATH="$DITEDITDIR":"$DITGENRDIR"
GS_FONTPATH="$PFAORIGDIR"
GS_LIB="$FONTDIR/utils"
export GS_FONTPATH GS_LIB GROFF_FONT_PATH
if test $# -eq 0
then
echo "Create font description files for groff."
echo "Usage: `basename \"$0\"` _postscript-font-file_ ..."
echo "Edit the script itself to change installation directories."
exit
fi
# Main loop: process all file names on the command line.
for file
do
echo -n "${TERMSMSO}$file:${TERMSGR0} "
srcfile="$file"
dirname="`dirname \"$file\"`"
# Binary or ASCII?
# Could also use file magic here, but we assume the user is
# smart enough to not throw junk at this script.
case "$srcfile" in
*.PFB ) ispfb=true; basename="`basename \"$srcfile\" .PFB`";;
*.pfb ) ispfb=true; basename="`basename \"$srcfile\" .pfb`";;
*.PFA ) ispfb=false; basename="`basename \"$srcfile\" .PFA`";;
*.pfa ) ispfb=false; basename="`basename \"$srcfile\" .pfa`";;
* ) ispfb=false; basename="`basename \"$srcfile\"`";;
esac
if test $ispfb = true
then
tempfile=`tempfile`
pfbtops <"$srcfile" >"$tempfile"
srcfile="$tempfile"
fi
# Determine the name of the font the file encodes.
fontname=`sed -ne '1,50s%.*/FontName.*/\([^ ]*\).*%\1%p' <"$srcfile"`
if test -z "$fontname"
then
echo "no FontName found. Ignoring file."
test $ispfb = true && rm "$tempfile"
continue
fi
echo "$fontname"
ditfile="$DITGENRDIR/$fontname"
pfafile="$PFAORIGDIR/$fontname.pfa"
# Overwrite without warning, because the installation directory is where
# we put copies of the fonts we use, we *never* keep our master copies
# of the font files there.
echo " Copying file..."
cp "$srcfile" "$pfafile"
test $ispfb = true && rm "$tempfile"
# Try to find a corresponding AFM file.
makeafm=true
usepfm=false
# Look for a customized AFM file.
afmfile="$AFMEDITDIR/$fontname.afm"
if test -f "$afmfile"
then
echo " Using custom AFM file."
makeafm=false
fi
# Look for an installed AFM file.
if test $makeafm = true
then
afmfile="$AFMORIGDIR/$fontname.afm"
if test -f "$afmfile"
then
echo " Using installed AFM file."
makeafm=false
fi
fi
# Look for an AFM file in the vicinity of the source file.
if test $makeafm = true
then
afmfile="$AFMORIGDIR/$fontname.afm"
for tryfile in \
"$dirname"/"$basename".[Aa][Ff][Mm] \
"$dirname"/[Aa][Ff][Mm]/"$basename".[Aa][Ff][Mm] \
"$dirname"/../[Aa][Ff][Mm]/"$basename".[Aa][Ff][Mm]
do
if test -f "$tryfile"
then
echo " Found an AFM file."
cp "$tryfile" "$afmfile"
makeafm=false
break
fi
done
fi
# Look for a PFM file in the vicinity of the source file.
if test $makeafm = true
then
pfmfile="$PFAORIGDIR/$fontname.pfm"
for tryfile in \
"$dirname"/"$basename".[Pp][Ff][Mm] \
"$dirname"/[Pp][Ff][Mm]/"$basename".[Pp][Ff][Mm] \
"$dirname"/../[Pp][Ff][Mm]/"$basename".[Pp][Ff][Mm]
do
if test -f "$tryfile"
then
echo " Found a PFM file."
cp "$tryfile" "$pfmfile"
usepfm=true
break
fi
done
fi
# No AFM file found. Generate one, possibly with the aid of a PFM file.
if test $makeafm = true
then
echo " Generating AFM file..."
# An AFM file generated with the help of a PFM file is more like
# an original AFM file than a generated AFM file, so perhaps put it
# in AFMORIGDIR?
afmfile="$AFMGENRDIR/$fontname.afm"
gs -q -dNODISPLAY -dSAFER -dDELAYSAFER \
MakeTransformedFont.ps \
-- pf2afm.ps "$PFAORIGDIR/$fontname"
test $usepfm = true && rm -f "$pfmfile"
# Sometimes pf2afm fails. Fall back to getafm.
if test -s "$PFAORIGDIR/$fontname.afm"
then
mv "$PFAORIGDIR/$fontname.afm" "$afmfile"
else
echo "${TERMBOLD}pf2afm failed! Using getafm...${TERMSGR0}"
rm "$PFAORIGDIR/$fontname.afm"
getafm $fontname |
cat $FONTDIR/utils/MakeTransformedFont.ps "$pfafile" - |
gs -q -DNODISPLAY -dSAFER - >"$afmfile"
fi
fi
case $fontname in
*Ital* | *It | *Obl* | *Slanted* | *Script* | CMTI[0-9]* | CMMI[0-9]* )
isitalic=true
italic="-i 50" ;;
* )
isitalic=false
italic="" ;;
esac
case $fontname in
Symbol | Symbol-Bold | CMEX* | CMSY* )
encoding=""
special="-s"
# mapfile="$DITMAPSDIR/symbolchars" ;;
mapfile="$DITMAPSDIR/symbolmap" ;;
Symbol-Slanted | *-Symbol-Slanted | *-Symbol-Bold-Slanted )
encoding=""
special="-s"
mapfile="$DITMAPSDIR/lgreekmap" ;;
CMMI* )
encoding="-e $$DITMAPSDIR/text.enc"
special="-s"
mapfile="$DITMAPSDIR/mathitalicmap" ;;
ZapfDingbats )
encoding=""
special="-s"
mapfile="$DITMAPSDIR/dingbats.map" ;;
* )
encoding="-e $DITMAPSDIR/text.enc"
special=""
mapfile="$DITMAPSDIR/textmap" ;;
esac
test $makeafm = true -a $isitalic = true &&
echo "${TERMBOLD}Check AFM file for ItalicAngle!${TERMSGR0}"
echo " Generating DIT file..."
echo " $special $italic $encoding $mapfile"
afmtodit $special $italic $encoding -d "$DITEDITDIR"/DESC \
$afmfile $mapfile "$ditfile"
# Ugh! grops doesn't understand absolute file names???
echo " Updating \"download\" file..."
if grep -q "^$fontname " "$DITEDITDIR"/download
then
sed -i -e "/^$fontname /c\
$fontname ../../PFA-original/$fontname.pfa" "$DITEDITDIR"/download
else
echo "$fontname ../../PFA-original/$fontname.pfa"
>>"$DITEDITDIR"/download
fi
# End of main loop.
done