[net.sources] MAKEFONT Font Editing Script

donn (10/20/82)

#! /bin/csh
#
# makefont
#
# Install a new font after expanding and editing an old one with cpfont.
# 10/19/82  Donn Seeley  UCSD Linguistics Dept.  sdcsvax!sdamos!donn
#

set path = ( ~donn/bin /usr/ucb /bin /usr/bin )

unalias	*
unset	noclobber
alias	vf	'/usr/lib/vfontinfo -z0 -v'
alias	suffix	'echo \!* | awk '\''BEGIN{FS="."}{print $NF}'\'


if ( $#argv >= 1 ) then
	set	fontfile	= $argv[1]
	shift	argv
else
	echo -n "Fontfile: "
	set	fontfile	= "$<"
endif

if ( ! (-e "$fontfile" && -r "$fontfile" && -f "$fontfile") ) then
	echo "Can't open $fontfile"
	exit 1
endif



#
# Does the fontfile need rasterizing? If it ends in a number, it's already done.
#
suffix "$fontfile" | egrep -s '^[0-9]*$'
if ( $status ) then
	set	newff		= $fontfile:t
	set	newff		= $newff:r
	echo "Rasterizing $fontfile"
	devf < $fontfile > /tmp/$newff
	if ( $status ) then
		echo "devf failed on $fontfile -- check format"
		rm -f /tmp/$newff
		exit 1
	endif
	set	fontfile	= /tmp/$newff
endif



#
# Set up width table
#
if ( $#argv >= 1 ) then
	set	widthtable	= $argv[1]
	shift	argv
else
	echo -n "Width table suffix (2 letters): "
	set	widthtable	= "$<"
endif

echo "Making width table ft$widthtable"
vwidth $fontfile `suffix $fontfile` > /tmp/ft$widthtable.c
(cd /tmp; cc -c ft$widthtable.c; strip ft$widthtable.o)
mv /tmp/ft$widthtable.o /usr/lib/font/ft$widthtable
rm -f /tmp/ft$widthtable.c



#
# Set up fontinfo file
#
set	fontinfofile	= $fontfile:t
set	fontinfofile	= $fontinfofile:r
if ( ! -e /usr/lib/fontinfo/$fontinfofile ) then
	echo "Making fontinfo file $fontinfofile"
	#
	# This could be more sophisticated, I suppose.
	#
	echo ".fp \np $widthtable" > /usr/lib/fontinfo/$fontinfofile
	echo -n "Any ligatures? "
	if ( "$<" != "y" ) then
		echo ".lg 0" >> /usr/lib/fontinfo/$fontinfofile
	endif
endif



#
# Install the font.
#
echo "Installing font $fontfile:t"
mv $fontfile /usr/lib/vfont
rotate < $fontfile > /usr/lib/vfont/${fontfile:t}r
rm $fontfile

==============================================================================

.TH MAKEFONT 1
.SH NAME
makefont \- make a new vtroff font
.SH SYNOPSIS
.B makefont
[ targetfont [ widthtable ] ]
.SH DESCRIPTION
.I Makefont
is part of a system for modifying the character sets
provided with 4.1 BSD
.I vtroff(1).
The premise of the system is that the
.I cpfont(1)
program produces a version of the character set, or `fontfile',
which prints on ordinary terminals rather than just on Versatecs.
Each character plotted on the Versatec
is actually a `bitmap', consisting of a pattern of dots;
the file you get from
.I cpfont(1)
has diagrams of each bitmap
in which there are two printing characters for each dot
and two blanks for each empty space.
(The reason for two characters per bit is that
printing characters are taller than they are wide
and thus you need a pair of characters to make a square dot.)
You edit this file to add or delete dots from characters,
shift dots around or even make new characters,
then you use
.I makefont(1)
to install a new fontfile which you can use with
.I vtroff(1).
.PP
Here is an example of how to use this system:
.nf
.in +3
.sp
% cpfont
Source font? nonie.r.10
Target font? donn.r.10
Copied and expanded donn.r.10.v
% vi donn.r.10.v

   ... edit the font ...

% makefont
Fontfile: donn.r.10.v
Rasterizing donn.r.10.v
Width table suffix (2 letters): Dr
Making width table ftDr
Making fontinfo file donn.r
Any ligatures? no
Installing font donn.r.10
% vtroff -1 donn.r -2 nonie.i -3 nonie.b -ms rogue.gallery
%
.sp
.in -3
.fi
.PP
To go through the various questions
.I makefont
asks, firstly it asks for the name of a fontfile.
If the fontfile ends in `.v',
.I makefont
runs it through the
.I devf(1)
program to turn it into a bitmap fontfile.
It then asks for the last two letters of a
.I troff(1)
width table name,
which should not be the same as a standard width table file.
The width table name for Nonie is `ftnr', for example.
You can be assured of avoiding duplication of names by
combining an upper and a lower case letter.
.I Makefont
runs
.I vwidth(1)
on the font and installs the width table,
then asks about a fontinfo file if one doesn't already exist.
This file will live in /usr/lib/fontinfo and
is used to tell troff useful things about the font,
such as whether it has ligatures.
When this is in place,
the font is rotated with
.I rotate(1)
for sideways printing on narrow Versatecs
and installed.
You may then run
.I vtroff(1)
to print with your new font.
If you have an incomplete font\-only a roman font
and no italic or bold\-then you must specify
each font separately for it to look right; see the example.
.PP
.I "Tricks to font editing."
The best way to make a new character is to find an unused or
useless character (see the Berkeley Font Catalog's table of Font Layout
Positions) and replace it with a character that is very similar to the
one you want to create.
I've had no luck changing the special font so I suggest
you replace things like the fraction signs, the dagger,
the copyright symbol, etc. from a standard font.
Simply delete all the lines in the expanded file dealing with
the old character and replace them with the copy
that you plan to munge into a new character.
The first number in the header of a character is its unique identification;
modify the number for the new character so
that it is the same as that of the one being replaced,
or else it will replace the character you copied it from
or worse yet simply disappear.
You may then edit away at the letter until you have it in satisfactory
shape.
Some restrictions on editing\-you can't add or delete rows and columns at
the left or top edges (unless you are clever;
see the manual entry for
.I devf
for details).
It's okay to add or subtract positions on the right or bottom.
Similarly, it doesn't matter whether the lines are padded out
with spaces on the right.
To get your new character with
.I vtroff(1)
just type
in the letter or escape sequence for the character you replaced (see
the Font Layout again).
For example if you replaced the copyright symbol
you just use `\e(co', and so on.
If you change a normal printing character
you needn't do anything special\-every
instance of that letter will be different.
For an unused character with no
.I troff(1)
escape sequence you can sometimes just put a bare control character in your
file\-this hasn't been tested rigorously.
Remember that italics, boldface and special characters
are not on the roman font and you must edit these too
if you expect a new letter to exist across the full range.
.PP
.I "Special reminder:"
When editing a bitmap,
remember that the two square brackets `[]'
represent a single printing dot;
what is more, the bracket pairs must be aligned
in columns or else you will surely not get what you expect.
Examples:
.ne 6
.sp 0.5v
.nf
.in +3
.cs 1 32
[][]            [][]
  [][]           [][]
[][]            [][]
RIGHT           WRONG
.cs
.in -3
.fi
.SH FILES
.ta 3i
.nf
/usr/lib/vfont	Directory of vtroff fontfiles
/usr/lib/font	Directory of troff width tables
/usr/lib/fontinfo	Directory of fontinfo files
.fi
.SH AUTHOR
Donn Seeley, UCSD Linguistics Dept.
.SH BUGS
Sigh.  Send me mail.

One bug known already: either all the relevant directories
must be writeable or `makefont' must run setuid.
Too bad.

Don't forget to install `vfontinfo', `rotate' and `vwidth'.
The sources live in the `vpr' source directory.
`Devf' comes with this distribution.