home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Otherware
/
Otherware_1_SB_Development.iso
/
mac
/
util
/
unix
/
sfonts.sha
< prev
next >
Wrap
Internet Message Format
|
1992-11-05
|
42KB
Date: Fri, 15 May 92 02:08 CDT
From: Dominik Hoffmann <HOFFMANN@macc.wisc.edu>
Subject: StripFonts-unix.shar
This is the Unix side of the StripFonts utility to be found in the info-mac/util
directory. It had been removed from the archive. It should probably go into the
info-mac/unix directory.
Thanks a lot
Dominik Hoffmann (I am not the author.)
--------------------------------------------------------------------------------
[This is essentially the same text as found in the "Readme" file in
the StripFonts.hqx archive.]
What is StripFonts?
------------------
StripFonts is a program designed to be useful to a very specific set
of people: those who frequently print documents by creating a
PostScript file on the Mac, transferring that file to a UNIX machine,
and sending it to a PostScript-compatible printer which is networked
to the UNIX machine. In particular, it is aimed at people who use
Adobe Type Manger, or who frequently use non-standard PostScript
typefaces; in other words, people who have PostScript outline fonts in
their system folders. It is also helpful to people using System 7, who
no longer have the option of omitting the Apple ProcSet from their
PostScript files.
The presence of outline fonts in the system folder causes the printer
driver to include a copy of the PostScript font definition of each
font used in the document. This is because there is no way for the
printer driver to know in advance which fonts will be available on the
particular printer that you end up using (different printers have
different sets of fonts built in, or on disk). When the printer is
connected to the Macintosh itself, this is not a problem, since the
Mac can ask the printer at the time of printing. However, this
interaction is not possible when the printing will be performed at a
later time from a different machine.
The font descriptions can increase the size of the PostScript file to
a startling degree, making the file-transfer process quite unwieldy.
This is where StripFonts comes into play. The StripFonts package
allows you remove the font definitions from a PostScript file before
sending it to the UNIX machine. It can learn which fonts are built in
to the printer that you will be using, and remove them "permanently"
from the file, which will speed up printing time as well. StripFonts
will also let you keep copies of non-built-in typefaces in a directory
under UNIX, and omit those font definitions during the transfer
between the Mac and the UNIX machine, saving greatly on transfer time.
They need to be re-inserted into the file before it can be printed, or
the printer will not be able to use the typefaces; the UNIX side of
StripFonts does this. A similar trick can be used to temporarily
remove the ProcSet which teaches the printer the "shorthand" that the
Mac's LaserWriter driver uses.
The current version of StripFonts can tell the difference between
PostScript and TrueType fonts, and has no problem keeping both
versions of a font, even if they have the same name. It also has an
"others" category for font types that it does not recognize; for
example, Macintosh bitmap fonts for which no outlines exist.
In my experience with using StripFonts, the time saved in uploading is
considerable. Typical documents (before stripping) for me are about
600K; after stripping they are cut down to about 40K. After adding the
support for multiple font types and ProcSet removal, I created a test
document using an Adobe PostScript font and a bitmap font. It was 300K
bytes long. Stripping out the fonts and the ProcSet cut it down to 2K!
The UNIX end reconstituted and printed it just fine.
Note that if you use TrueType fonts in a document the TrueType
rendering engine needs to be included so that the PostScript printer
knows how to deal with the fonts. This is pretty big, on the order of
100K all by itself. I don't see any easy way for StripFonts to remove
it, either, since there are no comments bracketing it to identify it
or provide a version number. I can't really trust the code itself to
remain static enough to blindly edit it out. Apple, you could help us
out here by making this code easier to locate.
Instructions
-----------
StripFonts comes in two parts, a Macintosh side, for which I supply a
standalone application, and a UNIX side, which is presently
implemented in C-shell scripts and Emacs LISP, to be interpreted by
the Free Software Foundation's GNU-Emacs editor. (Yes, I'm a little
schizophrenic to like both Macs and the F.S.F. but what can you do?)
If you don't have access to GNU-Emacs and don't want to try finding
and installing it, you could try lighting a fire under me (or someone
else) to write a more portable C version of the Unix side of
StripFonts. I will likely do it very soon if nobody else does, but
please let me know if you write one, so that I can include it in
future distributions!
The Mac application is called "StripFonts" and should be prominently
present in this archive. Directions on how to use it are in the file
"Mac help" until I manage to track down (or write) a nice
public-domain help interface which uses the Think Class Library, and
get a version of Think C that supports Balloon Help.
The UNIX portions are in a shar archive that was posted separately;
this archive has its own Readme file.
Distribution
-----------
StripFonts is free, and is distributed under John Rotenstein's
wonderful HappiWare licensing scheme: If you like it, remember to
smile! I would appreciate feedback about who is using the program,
stating what you like, and what you would like to see, but I can
obviously not promise to implement every suggested improvement since
I'm supposed to be working on my degree instead of this kind of
project.
If you really find the program useful, please send me a picture
postcard of your home town. If you're rich and want to help foster
future development by this impoverished student I wouldn't turn down
money either, but it should be clear that you are not expected (let
alone obligated) to pay for using this program.
Although it is free, it is not in the public domain in the following
sense: I retain the copyright on the package and set the terms under
which distribution may occur. Those terms are: You may freely
distribute copies of StripFonts as long as you do so in unmodified
form, and include all files and documentation which are present in
this archive. You may not charge for copies of StripFonts. User groups
and similar organizations may include StripFonts on disks of collected
software, as long as they do not charge more than $10 for the disks.
Bulletin boards, archives and anonymous FTP sites may freely offer
StripFonts. Portions of the code are Copyright (C) 1989 Symantec
Corporation; this does not adversely affect the above-outlined
distribution terms because of the reasonable nature of their licensing
agreement.
I can be reached as elliott@cs.wisc.edu or,
James Elliott
746 W. Main St. #302
Madison, WI 53715
Trademarks.
-----------
UNIX is a trademark of AT&T Bell Laboratories. PostScript and Adobe
Type Manager are trademarks of Adobe Systems, Inc.
-------------cut here-----------------------------------------------------------
#!/bin/sh
# This is a shell archive (shar 3.21)
# made 08/08/1991 22:55 UTC by elliott@veronica
# Source directory /var/home/elliott/stripfonts
#
# existing files WILL be overwritten
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 4961 -rw-r--r-- Readme
# 1774 -rwxr-xr-x list-fonts
# 5149 -rwxr-xr-x print
# 2609 -rwxr-xr-x strip-fonts
# 2649 -rwxr-xr-x strip-procsets
# 13838 -rw-r--r-- stripfonts.el
#
if touch 2>&1 | fgrep '[-amc]' > /dev/null
then TOUCH=touch
else TOUCH=true
fi
# ============= Readme ==============
echo "x - extracting Readme (Text)"
sed 's/^X//' << 'SHAR_EOF' > Readme &&
XFor More Information
X--------------------
X
XThe documentation describing what StripFonts does and who will find it
Xuseful is contained in a Macintosh TeachText document titled "Read Me",
Xand is part of the BinHexed Stuffit archive that contains the Macintosh
Xside of the package. Download and extract that archive and read the
Xfile if you are mystified about the purpose of this code.
X
X
XInstallation
X------------
X
XThe UNIX end of StripFonts consists of a set of functions written in
XGNU Emacs LISP (stripfonts.el), and a set of C-shell scripts to allow
Xconvenient access to those functions (print, list-fonts, strip-fonts
Xand strip-procsets).
X
XYou will probably only need to use the "print" and "list-fonts"
Xscripts; the other two are basically examples of how to call
Xindividual functions from the shell. For more details on the scripts
Xand functions themselves, read the comments in the files. Naturally,
Xyou can call the functions directly from within emacs if you have
Xloaded the stripfonts.el library. For myself, I have "autoload"
Xdirectives for the library in my .emacs, so that if I try and call the
Xmajor functions without previously loading the library, it will
Xautomagically be loaded.
X
XYou will want to put the scripts somewhere that is part of the shell
Xsearch-paths of the people who will be using them, and put
Xstripfonts.el somewhere that will be accessible to everyone since the
Xscripts need to be able to read it.
X
X
XConfiguration
X-------------
X
XThen you will need to edit the configuration section of each of the
Xscripts at least enough to set the value of the variable that tells
Xthe script where stripfonts.el can be found.
X
XYou will also need to edit the configuration variables in
Xstripfonts.el to determine where the font and ProcSet archives should
Xgo. Again, this should be somewhere accessible to all users of the
Xpackage.
X
XOnce you have done this, you should create those directories. You can
Xhave stripfonts.el do that for you: Run Emacs, load the stripfonts
Xlibrary (M-x load-file stripfonts.el), then execute the command
Xsetup-directories (M-x setup-directories). Make sure you've configured
Xthe variables properly first!
X
XFor faster performance, you might want to have emacs byte-compile the
Xstripfonts.el library, and then have the scripts load stripfonts.elc
Xinstead.
X
X
XEveryday use
X------------
X
XCreate a PostScript document on the Mac. Run StripFonts on it there.
XUpload the stripped version to UNIX. Use the "print" script to print
Xit out. This will automatically save copies of any new PostScript
Xfonts and ProcSets that were found in the document into the local
XStripFonts archive, and keep the minimal-sized version of the
Xdocument.
X
XWhenever you get new fonts or ProcSets this way, use the "list-fonts"
Xscript to generate an up-to-date list of the available fonts and
XProcSets, download this to the Mac and use it to update the Mac's
Xnotion of what fonts and ProcSets to remove for the uploading phase.
X
XIf you are using System 7.0, the PostScript output from the mac should
Xbe printable "as-is". If you are using an earlier version of the
Xsystem, you probably already know that the PostScript needs to be
Xchanged a little bit to work, and you will be using a package called
X"macps" to do this for you. You may continue to use macps in addition
Xto StripFonts; in fact, the "print" script will automatically feed its
Xoutput through macps if you give it the "-m" option when running it,
Xor edit its configuration variables such that this is the default.
X
X
XCopying
X-------
X
XStripFonts is free, and is distributed under John Rotenstein's
Xwonderful HappiWare licensing scheme: If you like it, remember to
Xsmile! I would appreciate feedback about who is using the program,
Xstating what you like, and what you would like to see, but I can
Xobviously not promise to implement every suggested improvement since
XI'm supposed to be working on my degree instead of this kind of
Xproject.
X
XIf you really find the program useful, please send me a picture
Xpostcard of your home town. If you're rich and want to help foster
Xfuture development by this impoverished student I wouldn't turn down
Xmoney either, but it should be clear that you are not expected (let
Xalone obligated) to pay for using this program.
X
XAlthough it is free, it is not in the public domain in the following
Xsense: I retain the copyright on the package and set the terms under
Xwhich distribution may occur. Those terms are: You may freely
Xdistribute copies of StripFonts as long as you do so in unmodified
Xform, and include all files and documentation which are present in
Xthis archive. You may not charge for copies of StripFonts. User
Xgroups and similar organizations may include StripFonts on disks of
Xcollected software, as long as they do not charge more than $10 for
Xthe disks. Bulletin boards, archives and anonymous FTP sites may
Xfreely offer StripFonts.
X
XI can be reached as elliott@cs.wisc.edu or,
X
X James Elliott
X 746 W. Main St. #302
X Madison, WI 53715
SHAR_EOF
$TOUCH -am 0614202591 Readme &&
chmod 0644 Readme ||
echo "restore of Readme failed"
set `wc -c Readme`;Wc_c=$1
if test "$Wc_c" != "4961"; then
echo original size 4961, current size $Wc_c
fi
# ============= list-fonts ==============
echo "x - extracting list-fonts (Text)"
sed 's/^X//' << 'SHAR_EOF' > list-fonts &&
X#!/bin/csh -f
X# list-fonts, shell-level command for generating a list of the fonts
X# which have been uploaded so far.
X#
X# This is part of the StripFonts package, (C) 1991 James Elliott
X# (elliott@cs.wisc.edu). See the global "Readme" file for
X# copying information. Requires the GNU Emacs LISP file
X# stripfonts.el in order to run (and thus, GNU Emacs as well).
X#
X# Use: This script should be run whenever you have added new fonts to
X# your UNIX stripfonts configuration (for example, by using the
X# "print" script to print a document that contained fonts that
X# were not previously uploaded). This script will create a file
X# called "StripTargets" which should be downloaded to the
X# Macintosh end of StripFonts, and opened within StripFonts
X# there, and saved as the default font list (see the Macintosh
X# documentation for more details if you need them).
X#
X# This will allow the Macintosh end of StripFonts to know
X# exactly what fonts you have available, compacting future
X# PostScript docments even more.
X#
X# Configuration: STRIPFONTS_DIR should be set to the name of the
X# directory which contains stripfonts.el. TMP_DIR should be
X# set to the name of a directory for temporary files; its
X# default setting is probably fine.
X
X# Find out what directories to use.
Xif (! $?STRIPFONTS_DIR) then
X set STRIPFONTS_DIR = "/var/elisp"
Xendif
Xif (! $?TMP_DIR) then
X set TMP_DIR = "/tmp"
Xendif
X
X# Create a file telling emacs what to do.
Xset ctrl_file = "$TMP_DIR/sfec.$$"
Xecho '(load "'$STRIPFONTS_DIR'/stripfonts")' >$ctrl_file
Xecho '(list-fonts "StripTargets")' >>$ctrl_file
X
X# Fire up Emacs to do the real work.
Xemacs -batch -l $ctrl_file
X/bin/rm -f $ctrl_file
SHAR_EOF
$TOUCH -am 0725171191 list-fonts &&
chmod 0755 list-fonts ||
echo "restore of list-fonts failed"
set `wc -c list-fonts`;Wc_c=$1
if test "$Wc_c" != "1774"; then
echo original size 1774, current size $Wc_c
fi
# ============= print ==============
echo "x - extracting print (Text)"
sed 's/^X//' << 'SHAR_EOF' > print &&
X#!/bin/csh -f
X# print, shell-level command for printing a Macintosh PostScript document
X# from which fonts and/or ProcSets have been stripped.
X#
X# This is part of the StripFonts package, (C) 1991 James Elliott
X# (elliott@cs.wisc.edu). See the global "Readme" file for
X# copying information. Requires the GNU Emacs LISP file
X# stripfonts.el in order to run (and thus, GNU Emacs as well).
X#
X# Use: This script should be run whenever you have a partially or
X# fully stripped document that you want to print. The default
X# behavior of this script is to strip any new fonts and ProcSets
X# from the document (so that they become available in the
X# archive and need not be uploaded from now on), then save the
X# stripped version (so that it takes less space), then create a
X# temporary file which includes all the fonts and ProcSets,
X# sending it to the printer.
X#
X# This default can be changed by supplying command-line
X# arguments, or editing the configuration variables as described
X# below. For example, you may wish to pipe the document through
X# macps (if the document was not created by the System 7 version
X# of the LaserWriter driver), or just write it to standard out
X# so that it can be part of a pipeline.
X#
X# Configuration: STRIPFONTS_DIR should be set to the name of the
X# directory which contains stripfonts.el. TMP_DIR should be
X# set to the name of a directory for temporary files which
X# will have enough room to hold the big PostScript files to
X# go to the printer.
X#
X# If you want the default behavior to be NOT to save the
X# stripped version of the file, change the line "set strip=1"
X# immediately below to read "set strip=0". Then, unless you
X# specify the "-s" option, stripped versions of documents will
X# not be saved. Note that new fonts and ProcSets will not be
X# automatically added to the archives either.
X#
X# If you want to send output through macps by default, change
X# the line "set use_macps=0" to "set use_macps=1". Then, unless
X# you specify the "+m" option, macps will be used.
X
X# Get the base name of this shell script. Have to do it this way
X# because a bug in tcsh prevents $0:t from working.
Xset progname=$0
Xset progname=$progname:t
X
X# Find out where the directories are supposed to be
Xif (! $?STRIPFONTS_DIR) then
X set STRIPFONTS_DIR = "/var/elisp"
Xendif
Xif (! $?TMP_DIR) then
X set TMP_DIR = "/tmp"
Xendif
X
X# Set up default behavior.
Xset strip=1
Xset use_macps=0
Xset strip_aldus=0
Xset printer=""
Xset files=""
Xset filter=0
X
X# Parse command-line arguments.
Xtop:
Xif ($#argv > 0) then
X switch ($1:q)
X
X case -P*:
X set printer = "$1:q"
X shift
X goto top
X
X case -t:
X set filter = 1
X shift
X goto top
X
X case -s:
X set strip = 1
X shift
X goto top
X
X case -m
X set use_macps = 1
X shift
X goto top
X
X case -a
X set strip_aldus = 1
X shift
X goto top
X
X case -*:
X echo "$progname"": unknown option, $1:q"
X goto usage
X
X case +t:
X set filter = 0
X shift
X goto top
X
X case +s:
X set strip = 0
X shift
X goto top
X
X case +m:
X set use_macps = 0
X shift
X goto top
X
X case +a
X set strip_aldus = 0
X shift
X goto top
X
X case +*:
X echo "$progname"": unknown option, $1:q"
X goto usage
X
X default:
X set files = "$files $1:q"
X shift
X goto top
X endsw
Xendif
X
X# If nothing to process, complain.
Xif ("$files" == "") goto usage
X
X# Create a file telling emacs what to do
Xset ctrl_file = "$TMP_DIR/sfec.$$"
Xecho '(load "'$STRIPFONTS_DIR'/stripfonts")' >$ctrl_file
X
X# Add commands to strip the new fonts, if appropriate
Xif ($strip != 0) then
X echo "(strip-fonts)" >>$ctrl_file
X echo "(strip-procsets)" >>$ctrl_file
X echo "(save-buffer)" >>$ctrl_file
Xendif
X
X# Similarly for stripping the Aldus error handler
Xif ($strip_aldus != 0) then
X echo "(strip-aldus-error-handler)" >>$ctrl_file
Xendif
X
X# Now a command to include the fonts for printing
Xecho "(include-fonts)" >>$ctrl_file
Xecho "(include-procsets)" >>$ctrl_file
X
X# And finally, pick a file for emacs to write the temporary results to
Xset dest_file = "$TMP_DIR/ps.$$"
Xecho '(write-file "'$dest_file'")' >>$ctrl_file
X
X# Now process each of the files
Xforeach i ($files)
X if ($filter == 0) then
X emacs -batch $i -l $ctrl_file
X if ($use_macps != 0) then
X macps $dest_file | lpr $printer
X else
X lpr $printer $dest_file
X endif
X else # Filter mode; output to stdout, and supress Emacs' messages.
X emacs -batch $i -l $ctrl_file >/dev/null
X if ($use_macps != 0) then
X macps $dest_file
X else
X cat $dest_file
X endif
X endif
X /bin/rm -f $dest_file
Xend
X
X# Clean up.
X/bin/rm -f $ctrl_file
Xgoto done
X
X# Give a description of how to invoke this script.
Xusage:
Xecho ""
Xecho "usage: $progname [-P <printer>] [-t] [+|-a] [+|-m] [+|-s] <files>"
Xecho " If '-t' is present, acts as a filter (writes to standard output)."
Xecho ""
X
Xecho "options ('-' activates, '+' deactivates):"
Xecho " a: remove Aldus error handler, if present"
Xecho " m: feed output through macps"
Xecho " s: strip file, archiving new fonts/ProcSets (active by default)"
X
Xdone:
SHAR_EOF
$TOUCH -am 0725170591 print &&
chmod 0755 print ||
echo "restore of print failed"
set `wc -c print`;Wc_c=$1
if test "$Wc_c" != "5149"; then
echo original size 5149, current size $Wc_c
fi
# ============= strip-fonts ==============
echo "x - extracting strip-fonts (Text)"
sed 's/^X//' << 'SHAR_EOF' > strip-fonts &&
X#!/bin/csh -f
X#
X# strip-fonts, shell-level command for stripping PostScript fonts from a
X# Macintosh PostScript document.
X#
X# This is part of the StripFonts package, (C) 1991 James Elliott
X# (elliott@cs.wisc.edu). See the global "Readme" file for
X# copying information. Requires the GNU Emacs LISP file
X# stripfonts.el in order to run (and thus, GNU Emacs as well).
X#
X# Use: This script should be run whenever you have uploaded a document
X# that contains "new" fonts, ie, fonts that are not yet part of
X# your archived set on this machine. It will copy the fonts into
X# the archive, so that you will not need to upload them in the
X# future. By default, it will also save the document with the
X# fonts stripped out so that it will use less space on disk. If
X# you are about to print the document, you should just let the
X# "print" script take care of this for you instead of using this
X# script; by default "print" strips and saves fonts.
X#
X# Configuration: STRIPFONTS_DIR should be set to the name of the
X# directory which contains stripfonts.el. If you want the
X# default behavior to be NOT saving the stripped file, change
X# the line "set save=1" immediately below to read "set save=0".
X# Then, unless you specify the "-s" option, stripped versions of
X# documents will not be saved.
X
X# Get the base name of this shell script. Have to do it this way
X# because a bug in tcsh prevents $0:t from working.
Xset progname=$0
Xset progname=$progname:t
X
X# Set up default behavior.
Xif (! $?STRIPFONTS_DIR) then
X set STRIPFONTS_DIR = "/var/elisp"
Xendif
Xset files=""
Xset save=1
X
X# Parse command-line arguments.
Xtop:
Xif ($#argv > 0) then
X switch ($1:q)
X
X case -s:
X set save = 1
X shift
X goto top
X
X case +s:
X set save = 0
X shift
X goto top
X
X case -*:
X echo "$progname"": unknown option, $1:q"
X goto usage
X
X case +*:
X echo "$progname"": unknown option, $1:q"
X goto usage
X
X default:
X set files = "$files $1:q"
X shift
X goto top
X endsw
Xendif
X
X# If nothing to process, complain.
Xif ("$files" == "") goto usage
X
X# Do what was specified.
Xforeach i ($files)
X if ($save == 0) then
X emacs -batch $i -l $STRIPFONTS_DIR/stripfonts -f strip-fonts
X else
X emacs -batch $i -l $STRIPFONTS_DIR/stripfonts -f strip-fonts \
X -f save-buffer
X endif
Xend
Xgoto done
X
X# Give a description of how to invoke this script.
Xusage:
Xecho ""
Xecho "usage: $progname [+|-s] <files>"
Xecho ""
X
Xecho "options ('-' activates, '+' deactivates):"
Xecho " s: save the shortened version of the files (active by default)"
X
Xdone:
SHAR_EOF
$TOUCH -am 0725170791 strip-fonts &&
chmod 0755 strip-fonts ||
echo "restore of strip-fonts failed"
set `wc -c strip-fonts`;Wc_c=$1
if test "$Wc_c" != "2609"; then
echo original size 2609, current size $Wc_c
fi
# ============= strip-procsets ==============
echo "x - extracting strip-procsets (Text)"
sed 's/^X//' << 'SHAR_EOF' > strip-procsets &&
X#!/bin/csh -f
X#
X# strip-procsets, shell-level command for stripping PostScript ProcSets
X# from a Macintosh PostScript document.
X#
X# This is part of the StripFonts package, (C) 1991 James Elliott
X# (elliott@cs.wisc.edu). See the global "Readme" file for
X# copying information. Requires the GNU Emacs LISP file
X# stripfonts.el in order to run (and thus, GNU Emacs as well).
X#
X# Use: This script should be run whenever you have uploaded a document
X# that contains "new" ProcSets, ie, ProcSets that are not yet
X# part of your archived set on this machine. It will copy the
X# ProcSets into the archive, so that you will not need to upload
X# them in the future. By default, it will also save the document
X# with the ProcSets stripped out so that it will use less space
X# on disk. If you are about to print the document, you should
X# just let the "print" script take care of this for you instead
X# of using this script; by default "print" strips and saves
X# procsets.
X#
X# Configuration: STRIPFONTS_DIR should be set to the name of the
X# directory which contains stripfonts.el. If you want the
X# default behavior to be NOT saving the stripped file, change
X# the line "set save=1" immediately below to read "set save=0".
X# Then, unless you specify the "-s" option, stripped versions of
X# documents will not be saved.
X
X# Get the base name of this shell script. Have to do it this way
X# because a bug in tcsh prevents $0:t from working.
Xset progname=$0
Xset progname=$progname:t
X
X# Set up default behavior.
Xif (! $?STRIPFONTS_DIR) then
X set STRIPFONTS_DIR = "/var/elisp"
Xendif
Xset files=""
Xset save=1
X
X# Parse command-line arguments.
Xtop:
Xif ($#argv > 0) then
X switch ($1:q)
X
X case -s:
X set save = 1
X shift
X goto top
X
X case +s:
X set save = 0
X shift
X goto top
X
X case -*:
X echo "$progname"": unknown option, $1:q"
X goto usage
X
X case +*:
X echo "$progname"": unknown option, $1:q"
X goto usage
X
X default:
X set files = "$files $1:q"
X shift
X goto top
X endsw
Xendif
X
X# If nothing to process, complain.
Xif ("$files" == "") goto usage
X
X# Do what was specified.
Xforeach i ($files)
X if ($save == 0) then
X emacs -batch $i -l $STRIPFONTS_DIR/stripfonts -f strip-procsets
X else
X emacs -batch $i -l $STRIPFONTS_DIR/stripfonts -f strip-procsets \
X -f save-buffer
X endif
Xend
Xgoto done
X
X# Give a description of how to invoke this script.
Xusage:
Xecho ""
Xecho "usage: $progname [+|-s] <files>"
Xecho ""
X
Xecho "options ('-' activates, '+' deactivates):"
Xecho " s: save the shortened version of the files (active by default)"
X
Xdone:
SHAR_EOF
$TOUCH -am 0725170991 strip-procsets &&
chmod 0755 strip-procsets ||
echo "restore of strip-procsets failed"
set `wc -c strip-procsets`;Wc_c=$1
if test "$Wc_c" != "2649"; then
echo original size 2649, current size $Wc_c
fi
# ============= stripfonts.el ==============
echo "x - extracting stripfonts.el (Text)"
sed 's/^X//' << 'SHAR_EOF' > stripfonts.el &&
X;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
X;; stripfonts.el --- UNIX end of StripFonts package.
X;; Author : James Elliott
X;; Created On : Sun Sep 9 13:21:59 1990
X;; Last Modified By: James Elliott
X;; Last Modified On: Fri Jun 14 18:17:56 1991
X;; Update Count : 48
X;; Status : Author uses frequently; first release to world.
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X;; This is part of the StripFonts package, (C) 1991 James Elliott
X;; (elliott@cs.wisc.edu). See the global "Readme" file for copying
X;; information.
X;;
X;; This file defines a set of functions which are useful in working
X;; with Macintosh PostScript files. In conjunction with the Macintosh
X;; end, the package allows font definitions and ProcSets to be omitted
X;; from the files while they are uploaded (and stored on disk) to save
X;; a great deal of time and space. These routines maintain an
X;; organized set of directories which keep copies of the fonts known
X;; so far (so that they need be uploaded only once), strip new fonts
X;; out of documents and into the archives, and re-insert the fonts and
X;; ProcSets into the documents at printing time.
X;;
X;; You may well wish to use the shell-scripts which were provided
X;; with this file as your primary interface to these functions. Most
X;; day-to-day needs can be filled by the "print" script, which calls
X;; functions in this file by running Emacs in batch mode. If you want
X;; to call the functions yourself, or understand how they work, feel
X;; free to browse through this code.
X
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;;
X;; Configuration variables: Edit the values of these variables to
X;; determine where to locate your font archives, etc.
X;;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X(defvar *font-directory* "/var/fonts/"
X "*Directory in which to find and install copies of the outline
Xfonts used in uploading Macintosh documents.")
X
X(defvar *ps-subdir* "PostScript/"
X "*Subdirectory name in which PostScript fonts should be placed.")
X
X(defvar *tt-subdir* "TrueType/"
X "*Subdirectory name in which TrueType fonts should be placed.")
X
X(defvar *unknown-subdir* "unknown/"
X "*Subdirectory name in which fonts of unknown format (e.g. bitmaps) should
Xbe placed.")
X
X(defvar *procset-subdir* "procsets/"
X "*Subdirectory name in which ProcSets should be placed.")
X
X(defvar *procset-info* (concat *font-directory* *procset-subdir* "info")
X "*File containing list of ProcSets and their file names.")
X
X(defvar *screen-files* '("UserPrep" "AdvUserPrep")
X "List of extraneous files in the fonts directory, such as user prep files,
Xwhich may be desirable in the inclusion process, but should not show up in
Xthe font list.")
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;;
X;; Run this function once to create the directories named above. You
X;; need to do this for StripFonts to work properly.
X;;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X(defun setup-directories ()
X "This function should just be run once when initially setting up your
XStripFonts package; it will create the directories needed by the routines
Xin this file, as specified by the variables above. Configure the variables
Xto your satisfaction before running this."
X
X (interactive "");
X
X (shell-command (concat "mkdir "
X (directory-file-name *font-directory*) " "
X (directory-file-name (concat *font-directory*
X *ps-subdir*)) " "
X (directory-file-name (concat *font-directory*
X *tt-subdir*)) " "
X (directory-file-name (concat *font-directory*
X *unknown-subdir*)) " "
X (directory-file-name (concat *font-directory*
X *procset-subdir*)))))
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;;
X;; Here are the functions themselves...
X;;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X(defun strip-fonts ()
X "Search through a Mac PS document for font definitions and replace them
Xwith include requests. If copies of the fonts are not already present in the
Xfont directory, add them."
X
X (interactive "")
X
X (let ((oldbuf (current-buffer))
X (buf (get-buffer-create "*strip-temp*"))
X subdir name-prefix
X name beg)
X
X (save-excursion
X (goto-char (point-min))
X (if (not (or (looking-at "%!PS-Adobe") (looking-at "%!PS-Stripped")))
X (error "File does not seem to be PostScript"))
X (if (looking-at "%!PS-Adobe")
X (progn
X (forward-char 10)
X (delete-region (point-min) (point))
X (insert "%!PS-Stripped")))
X (while (re-search-forward "^%%BeginFont: \\(.*\\)" nil t)
X (setq name (buffer-substring (match-beginning 1) (match-end 1)))
X (setq beg (match-beginning 0))
X (beginning-of-line 2)
X (if (looking-at "%!PS-AdobeFont-")
X (setq subdir *ps-subdir* name-prefix "p:")
X (if (looking-at "%!PS-TrueTypeFont-")
X (setq subdir *tt-subdir* name-prefix "t:")
X (setq subdir *unknown-subdir* name-prefix "u:")))
X (re-search-forward "^%%EndFont *\n")
X (kill-region beg (match-end 0))
X (insert (concat "%%#IncludeFont " name-prefix name "\n"))
X (if (null (file-readable-p (concat *font-directory* subdir name)))
X (progn
X (set-buffer buf)
X (erase-buffer)
X (yank)
X (write-file (concat *font-directory* subdir name))
X (set-buffer oldbuf)
X )
X )
X )
X (kill-buffer buf)
X)))
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X(defun procset-filename (name)
X "Return the name of the file containing the specified ProcSet, if it exists."
X
X (if (file-exists-p *procset-info*)
X (let ((oldbuf (current-buffer))
X (buf (get-buffer-create "*proc-temp*"))
X (result nil))
X (set-buffer buf)
X (erase-buffer)
X (insert-file *procset-info*)
X (goto-char (point-min))
X (if (re-search-forward (concat "^" (regexp-quote name) "\\s-*\t")
X nil t)
X (progn
X (end-of-line 1)
X (setq result (buffer-substring (match-end 0) (point)))))
X (set-buffer oldbuf)
X (kill-buffer buf)
X result
X )
X nil
X )
X)
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X
X(defun new-procset-filename (name)
X "Creates a new file name for the given ProcSet and adds it to the list."
X
X (let ((oldbuf (current-buffer))
X (buf (get-buffer-create "*proc-temp*"))
X (num 1))
X (set-buffer buf)
X (erase-buffer)
X (if (file-exists-p *procset-info*)
X (insert-file *procset-info*))
X (goto-char (point-max))
X (while (file-exists-p (concat *font-directory* *procset-subdir* "set_"
X num))
X (setq num (1+ num)))
X (insert name "\tset_" (int-to-string num) "\n")
X (write-file *procset-info*)
X (set-buffer oldbuf)
X (kill-buffer buf)
X (concat "set_" num)
X )
X)
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X
X(defun strip-procsets ()
X "Search through a Mac PS document for ProcSets and replace them with
Xinclude requests. If copies of the fonts are not already present in the
Xfont directory, add them."
X
X (interactive "")
X
X (let ((oldbuf (current-buffer))
X (buf (get-buffer-create "*strip-temp*"))
X name beg)
X
X (save-excursion
X (goto-char (point-min))
X (if (not (or (looking-at "%!PS-Adobe") (looking-at "%!PS-Stripped")))
X (error "File does not seem to be PostScript"))
X (while (re-search-forward "^%%BeginProcSet: \\(.*\\)" nil t)
X (setq name (buffer-substring (match-beginning 1) (match-end 1)))
X (setq beg (match-beginning 0))
X (re-search-forward "^%%EndProcSet *\n")
X (kill-region beg (match-end 0))
X (insert (concat "%%IncludeProcSet " name "\n"))
X (if (null (procset-filename name))
X (progn
X (set-buffer buf)
X (erase-buffer)
X (yank)
X (write-file (concat *font-directory* *procset-subdir*
X (new-procset-filename name)))
X (set-buffer oldbuf)
X )
X )
X )
X (kill-buffer buf)
X)))
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X
X(defun include-fonts ()
X "Search through a Mac PS document for font definitions that have been
Xelided, and replace them with the actual font definitions."
X
X (interactive "")
X
X (let (name name-prefix subdir)
X (save-excursion
X (goto-char (point-min))
X (if (not (or (looking-at "%!PS-Adobe") (looking-at "%!PS-Stripped")))
X (error "File does not seem to be PostScript"))
X (if (looking-at "%!PS-Stripped")
X (progn
X (forward-char 13)
X (delete-region (point-min) (point))
X (insert "%!PS-Adobe")))
X (while (re-search-forward "^%%#IncludeFont \\(.*\\)\n" nil t)
X (setq name (buffer-substring (match-beginning 1) (match-end 1)))
X (setq name-prefix (substring name 0 2))
X (setq name (substring name 2))
X (cond
X ((string-equal name-prefix "p:") (setq subdir *ps-subdir*))
X ((string-equal name-prefix "t:") (setq subdir *tt-subdir*))
X ((string-equal name-prefix "u:") (setq subdir *unknown-subdir*))
X (t (setq subdir *ps-subdir*)
X (setq name (concat name-prefix name))
X (message
X "Unknown or missing font prefix for %s; assuming PostScript"
X name)))
X (if (null (file-readable-p
X (concat *font-directory* subdir name)))
X (error "Font definition for %s is not available" name))
X (kill-region (match-beginning 0) (match-end 0))
X (insert-file (concat *font-directory* subdir name))
X )
X )
X )
X)
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X
X(defun include-procsets ()
X "Search through a Mac PS document for ProcSets that have been
Xelided, and replace them with the actual font definitions."
X
X (interactive "")
X
X (save-excursion
X (goto-char (point-min))
X (if (not (or (looking-at "%!PS-Adobe") (looking-at "%!PS-Stripped")))
X (error "File does not seem to be PostScript"))
X (while (re-search-forward "^%%IncludeProcSet \\(.*\\)\n" nil t)
X (let ((name (buffer-substring (match-beginning 1) (match-end 1)))
X (front (match-beginning 0))
X (back (match-end 0)))
X (if (null (procset-filename name))
X (error "ProcSet %s is not available" name))
X (kill-region front back)
X (insert-file (concat *font-directory* *procset-subdir*
X (procset-filename name)))
X )
X )
X )
X)
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X
X(defun member (item set) ;; INTERNAL FUNCTION, not for calling by
X ;; users.
X
X "Returns NIL if item is not in the list, or the cdr of the list starting
Xwith that item if it is found."
X
X (while (and set (not (equal (car set) item)))
X (setq set (cdr set)))
X
X set
X)
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X
X(defun list-procsets ()
X "Insert a list of all the available procsets."
X
X (if (file-exists-p *procset-info*)
X (let ((oldbuf (current-buffer))
X (buf (get-buffer-create "*proc-temp*"))
X name)
X (set-buffer buf)
X (erase-buffer)
X (insert-file *procset-info*)
X (goto-char (point-min))
X (while (re-search-forward "^\\(.*\\)\t.*$" nil t)
X (setq name (buffer-substring (match-beginning 1) (match-end 1)))
X (set-buffer oldbuf)
X (insert "c:" name "\n")
X (set-buffer buf))
X (set-buffer oldbuf)
X (kill-buffer buf)
X )
X )
X)
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X
X(defun list-fonts-aux (subdir pfx) ;; INTERNAL FUNCTION, not for
X ;; calling by users...
X
X "Generate a listing of fonts from SUBDIRECTORY with prefix PREFIX. Used
Xinternally by list-fonts."
X
X (let ((files (directory-files (concat *font-directory* subdir))))
X (while files
X (if (and (null (file-directory-p
X (concat *font-directory* subdir (car files))))
X (not (member (car files) *screen-files*)))
X (insert (concat pfx (car files) "\n")))
X (setq files (cdr files)))
X )
X)
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X
X(defun list-fonts (&optional fname)
X "Generate a line for each font file available in the fonts directory.
XUsed by the Mac end in stripping fonts before uploading. Now also lists
Xavailable ProcSets. If called with a parameter, saves the list to the
Xfile named in that parameter (not available interactively)."
X
X (interactive "")
X
X (let ((oldbuf (current-buffer))
X (buf (get-buffer-create "*font-list*")))
X (set-buffer buf)
X (erase-buffer)
X (insert "%%StripFonts Format 1.2\n");
X (insert "%%List generated on ")
X (insert (current-time-string))
X (insert "\n");
X
X ;;List the ProcSets which have been uploaded
X (insert "\n%%ProcSets available:\n");
X (list-procsets)
X
X ;;List the fonts which have been uploaded
X (insert "\n%%PostScript fonts available:\n");
X (list-fonts-aux *ps-subdir* "p:")
X (insert "\n%%TrueType fonts available:\n");
X (list-fonts-aux *tt-subdir* "t:")
X (insert "\n%%Other fonts available:\n");
X (list-fonts-aux *unknown-subdir* "u:")
X
X (goto-char (point-min))
X (display-buffer "*font-list*")
X (if fname (write-file fname))
X (set-buffer oldbuf)
X )
X)
X
X
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X
X(defun strip-aldus-error-handler ()
X "Remove the code from a PS document introduced by Aldus programs to
Xprint the postscript error on the page. Useful in environments where
Xthe default error handler is more useful, e.g. it sends mail back to the
Xperson submitting the job."
X
X (interactive "")
X
X (goto-char (point-min))
X (if (re-search-forward
X "^%\. Error handling code - don't do this if printing to Lino$" nil t)
X (let ((start (match-beginning 0))
X (end))
X (re-search-forward "^%\.$")
X (setq end (match-end 0))
X (kill-region start end)
X (insert "%% Aldus error handler removed from this spot.")))
X)
SHAR_EOF
$TOUCH -am 0614181791 stripfonts.el &&
chmod 0644 stripfonts.el ||
echo "restore of stripfonts.el failed"
set `wc -c stripfonts.el`;Wc_c=$1
if test "$Wc_c" != "13838"; then
echo original size 13838, current size $Wc_c
fi
exit 0