[comp.windows.news] Alternative fonts in psview

yap@me.utoronto.ca (Davin Yap) (08/04/89)

I would like to use NewCentury-Schlbook in the 'psview' previewer.  Any
hints on how to do this would be much appreciated.  In particular, if
anyone has an ".afm" to ".fm" translator, I'd really like to hear from
you.  If it matters, I'm using an Iris 4D/50G running a version of their
OS numbered 3.1417... (almost pi :-).

Thanks a bunch, Davin.
--
GOAL:  To dance the light fan- |Davin Yap, Mechanical Engineering, U of Toronto
tastic in the face of derision,| yap@me.toronto.edu     yap@me.utoronto.bitnet
from those bland at heart.     |       ...{pyramid,uunet}!utai!utme!yap

don@BRILLIG.UMD.EDU (Don Hopkins) (08/06/89)

   Date: Sat, 5 Aug 89 06:42:42 -0400
   From: sun-barr!cs.utexas.edu!wasatch!mailrus!jarvis.csri.toronto.edu!me!yap@decwrl.dec.com  (Davin Yap)

   I would like to use NewCentury-Schlbook in the 'psview' previewer.  Any
   hints on how to do this would be much appreciated.  In particular, if
   anyone has an ".afm" to ".fm" translator, I'd really like to hear from
   you.  If it matters, I'm using an Iris 4D/50G running a version of their
   OS numbered 3.1417... (almost pi :-).

   Thanks a bunch, Davin.
   --
   GOAL:  To dance the light fan- |Davin Yap, Mechanical Engineering, U of Toronto
   tastic in the face of derision,| yap@me.toronto.edu     yap@me.utoronto.bitnet
   from those bland at heart.     |       ...{pyramid,uunet}!utai!utme!yap

I have a script (enclosed) which converts the X11R3 .bdf fonts into NeWS
1.1 fonts, if that helps. That will get you several sizes of
NewCentury-Schlbook as bitmapped fonts. The X11/NeWS merge includes the
NewCentury-Schlbook family as Folio F3 outline fonts, so you can display
them at any point size, rotation, etc, and they even look very nice!  But
in the mean time if you can get by with a bitmapped font, and have the
X11R3 fonts sitting around, this script might help you. The sed script is
necessary since there is a minor incompatibility between the .bdf files X
fonts are distributed as and the .afb fonts that NeWS 1.1 dumpfont reads
in. It also has to heuristically determine reasonable font names, since
it would not be nice to use those-long-nasty-X-font-names.

The script will convert most of the interesting X11R3 bitmap fonts, which
is probably a lot more than you'd use at once (and it slows down NeWS 1.1
server startup considerably if there are lots of fonts in the font
directory -- "fixed in the merge"), so you should probably only convert
the fonts you need.

If you can't wait for the merge, and really need the font at arbitrary
sizes and rotations, and don't care how gross they look, you might be
able to do it by obtaining or generating font metrics files.  I have
heard that if dumpfont can find a font metrics file (.fm), NeWS 1.1 will
be able to scale and rotate the bitmaps (icky, but better than nothing).
(For example, look at what NeWS 1.1 does for huge point sizes and
rotations of Times-Roman, but not for Screen.)  I haven't tried this
myself though.  It's probably possible to write a PostScript program to
measure the bitmaps and write out font metrics files (then you put the
.fm file back in the same directory with the .bdf files and convert them
again).  Anybody know if this technique will work?  What's the difference
between ".afm" and ".fm" files, anyway?

	-Don

Here is the file, "xfonts.shar", which contains "Makefile" (a stub),
"README", "bdftofb", and "makefonts":

=== Cut here: 8X =======================================================
: Run this shell script with "sh" not "csh"
PATH=/bin:/usr/bin:/usr/ucb:/etc:$PATH
export PATH
all=false
if [ x$1 = x-a ]; then
	all=true
fi
echo Extracting Makefile
sed 's/^X//' <<'//go.sysin dd *' >Makefile
Xall:
X
Xclean:
X	rm -f core *~ *.BAK
//go.sysin dd *
if [ `wc -c < Makefile` != 34 ]; then
	made=false
	echo error transmitting Makefile --
	echo length should be 34, not `wc -c < Makefile`
else
	made=true
fi
if $made; then
	chmod 644 Makefile
	echo -n '	'; ls -ld Makefile
fi
echo Extracting README
sed 's/^X//' <<'//go.sysin dd *' >README
XThese fonts were made from the .bdf files in the X11R3 distribution.
XThey were converted to NeWS fonts by the "makefonts" and "bdftofb" 
Xshell scripts. 
X
X	-Don Hopkins
X
XInstructions for using makefonts:
X
X  - Make a directory called "fonts", beneath the current directory.
X  - Point the XDIR variable in this shell script to your copy of the X11R3
X    source code distribution.
X  - Run this shell script, "makefonts".
X  - Sit back and relax for a while.
X  - Before you run NeWS, set the environment variable "FONTPATH" to
X    "/usr/NeWS/fonts:<wherever>/fonts". (Oh wtf, just merge the two
X    directories!)
X
XNote: The size of the FontDirectory dictionary in NeWS 1.1 is only 100.
X(It's hard wired.) However, you can fix this in init.ps by inserting
Xthe line "500 FontDirectory extend pop" right before the line
X"FontDirectory begin". 
//go.sysin dd *
if [ `wc -c < README` != 835 ]; then
	made=false
	echo error transmitting README --
	echo length should be 835, not `wc -c < README`
else
	made=true
fi
if $made; then
	chmod 644 README
	echo -n '	'; ls -ld README
fi
echo Extracting bdftofb
sed 's/^X//' <<'//go.sysin dd *' >bdftofb
X#!/bin/csh -f
X# Convert X11 .bdf font files to NeWS .afb font files,
X# apply some heuristics to figure out their names,
X# and dump out NeWS .fb files.
X#
X# Copyright (C) 1988 by Don Hopkins. (don@brillig.umd.edu)
X# University of Maryland Human Computer Interaction Lab.
X# Feel free to redistribute this. Please send my your improvements!
X#
X# Bugs: You can't run multiple instances of this shell script at once in 
X# the same directory (because of the file "font-name"). 
X# The heuristics to figure out the font name seem to work OK with the 
X# X11R3 fonts, but they may need to be frobbed for other fonts.
X#
X
Xforeach file ($*)
Xecho -n Converting $file ... 
Xrm -f font-name
Xset out = `basename $file:r.afb`
Xawk '\
X/^FONT / { if ($2 == "Apple" && $3 == "Macintosh") \
X		name = $4 \
X	   else name = $2 \
X	   if (name ~ /\.bdf$/) \
X		name = substr(name, 1, length(name)-4) } \
X/^FAMILY_NAME / { name = $2 } \
X/^WEIGHT_NAME / { name = name "-" $2 } \
X/^SLANT / { if ($2 == "\"I\"" && name !~ /.*Italic/) \
X		name = name "Italic" } \
X/^DEVICE_FONT_NAME / { name = $2 } \
X/^COPYRIGHT "public domain"/ { next } \
X/^STARTPROPERTIES/ , /^ENDPROPERTIES/ { next } \
X{print} \
XEND { while ((name ~ /\n$/) || (name ~ /-[0-9]*$/)) \
X	name = substr(name, 1, length(name)-1) \
X      print name > "font-name" } \
X' $file > $out
Xset name = `sed 's/"//g' < font-name`
Xecho Done.
Xecho -n Dumping $name ...
Xdumpfont -d fonts -n $name $out
Xrm $out
Xend
Xrm -f font-name
//go.sysin dd *
if [ `wc -c < bdftofb` != 1444 ]; then
	made=false
	echo error transmitting bdftofb --
	echo length should be 1444, not `wc -c < bdftofb`
else
	made=true
fi
if $made; then
	chmod 755 bdftofb
	echo -n '	'; ls -ld bdftofb
fi
echo Extracting makefonts
sed 's/^X//' <<'//go.sysin dd *' >makefonts
X#!/bin/csh -f
X#
X# Shell script to convert the X11R3 fonts into NeWS fonts, using
X# the "bdftofb" shell script.
X#
X# Instructions:
X#
X#   - Make a directory called "fonts", beneath the current directory.
X#   - Point the XDIR variable in this shell script to your copy of the X11R3
X#     source code distribution.
X#   - Run this shell script, "makefonts".
X#   - Sit back and relax for a while.
X#   - Before you run NeWS, set the environment variable "FONTPATH" to
X#     "/usr/NeWS/fonts:<wherever>/fonts". (Oh wtf, just merge the two
X#     directories!)
X#
X# Note: The size of the FontDirectory dictionary in NeWS 1.1 is only 100.
X# (It's hard wired.) However, you can fix this in init.ps by inserting
X# the line "500 FontDirectory extend pop" right before the line
X# "FontDirectory begin". 
X#
X# Copyright (C) 1988 by Don Hopkins. (don@brillig.umd.edu)
X# University of Maryland Human Computer Interaction Lab.
X# Feel free to redistribute this. Please send my your improvements!
X#
X
X# Point XDIR to the home of your X11R3 source distribution
Xset XDIR = /usr/src/new/X11R3
X
X# Where to find the bdf files.
Xset XBDFDIR = $XDIR/fonts/bdf
Xset XCONTRIBDIR = $XDIR/contrib/fonts/bdf
X
X# Include the new X11 fonts that work nicely with NeWS.
X# (Charter and NewCenturySchlbk)
Xset X11FONTS = ($XBDFDIR/75dpi/{char,ncen}*.bdf)
X
X# Include all the Mac fonts -- they're a blast!
Xset MACFONTS = ($XCONTRIBDIR/info-mac/*.bdf $XCONTRIBDIR/bmug/*.bdf)
X
X# You could also include the X10 and old X11 fonts but they're pretty icky.
X
X# Convert the mess:
Xbdftofb $X11FONTS
Xbdftofb $MACFONTS
X
X# Group the font files into families for NeWS (by making .ff files).
Xbldfamily -dfonts
//go.sysin dd *
if [ `wc -c < makefonts` != 1648 ]; then
	made=false
	echo error transmitting makefonts --
	echo length should be 1648, not `wc -c < makefonts`
else
	made=true
fi
if $made; then
	chmod 755 makefonts
	echo -n '	'; ls -ld makefonts
fi