[comp.windows.news] X11R3 => NeWS font converter

don@BRILLIG.UMD.EDU (Don Hopkins) (11/29/88)

Here are a couple of scripts I put together to convert the fonts from
the X11R3 distribution into bitmap fonts for NeWS. If you have a copy
of the X11R3 source code online, just follow the instructions in
"makefonts" and you'll have more bitmap fonts than you'll know what to
do with! Note that this message contains two files: makefonts and
bfdtofb. You should chmod +x both of them. 

	-Don

makefonts: Cut here:====================================================
#!/bin/csh -f
#
# makefonts
#
# Shell script to convert the X11R3 fonts into NeWS fonts, using
# the "bdftofb" shell script.
#
# Instructions:
#
#   - Make a directory called "fonts", beneath the current directory.
#   - Point the XDIR variable in this shell script to your copy of the X11R3
#     source code distribution.
#   - Run this shell script, "makefonts".
#   - Sit back and relax for a while.
#   - Before you run NeWS, set the environment variable "FONTPATH" to
#     "/usr/NeWS/fonts:<wherever>/fonts". (Oh wtf, just merge the two
#     directories!)
#
# Note: The size of the FontDirectory dictionary in NeWS 1.1 is only 100.
# (It's hard wired.) However, you can fix this in init.ps by inserting
# the line "500 FontDirectory extend" right before the line
# "FontDirectory begin". 
#
# Copyright (C) 1988 by Don Hopkins. (don@brillig.umd.edu)
# University of Maryland Human Computer Interaction Lab.
# Feel free to redistribute this. Please send my your improvements!
#

# Point XDIR to the home of your X11R3 source distribution
set XDIR = /usr/src/new/X11R3

# Where to find the bdf files.
set XBDFDIR = $XDIR/fonts/bdf
set XCONTRIBDIR = $XDIR/contrib/fonts/bdf

# Include the new X11 fonts that work nicely with NeWS.
# (Charter and NewCenturySchlbk)
set X11FONTS = ($XBDFDIR/75dpi/{char,ncen}*.bdf)

# Include all the Mac fonts -- they're a blast!
set MACFONTS = ($XCONTRIBDIR/info-mac/*.bdf $XCONTRIBDIR/bmug/*.bdf)

# You could also include the X10 and old X11 fonts but they're pretty icky.

# Convert the mess:
bdftofb $X11FONTS
bdftofb $MACFONTS

# Group the font files into families for NeWS (by making .ff files).
bldfamily -dfonts

bdftofb: Cut here:======================================================
#!/bin/csh -f
#
# bdftofb
#
# Convert X11 .bdf font files to NeWS .afb font files,
# apply some heuristics to figure out their names,
# and dump out NeWS .fb files.
#
# Copyright (C) 1988 by Don Hopkins. (don@brillig.umd.edu)
# University of Maryland Human Computer Interaction Lab.
# Feel free to redistribute this. Please send my your improvements!
#
# Bugs: You can't run multiple instances of this shell script at once in 
# the same directory (because of the file "font-name"). 
# The heuristics to figure out the font name seem to work OK with the 
# X11R3 fonts, but they may need to be frobbed for other fonts.
#

foreach file ($*)
echo -n Converting $file ... 
rm -f font-name
set out = `basename $file:r.afb`
awk '\
/^FONT / { if ($2 == "Apple" && $3 == "Macintosh") \
		name = $4 \
	   else name = $2 \
	   if (name ~ /\.bdf$/) \
		name = substr(name, 1, length(name)-4) } \
/^FAMILY_NAME / { name = $2 } \
/^WEIGHT_NAME / { name = name "-" $2 } \
/^SLANT / { if ($2 == "\"I\"" && name !~ /.*Italic/) \
		name = name "Italic" } \
/^DEVICE_FONT_NAME / { name = $2 } \
/^COPYRIGHT "public domain"/ { next } \
/^STARTPROPERTIES/ , /^ENDPROPERTIES/ { next } \
{print} \
END { while ((name ~ /\n$/) || (name ~ /-[0-9]*$/)) \
	name = substr(name, 1, length(name)-1) \
      print name > "font-name" } \
' $file > $out
set name = `sed 's/"//g' < font-name`
echo Done.
echo -n Dumping $name ...
dumpfont -d fonts -n $name $out
rm $out
end
rm -f font-name