[net.sources.mac] Shar archive for Mac -> UNIX -> LaserWriter

remym@tekig5.UUCP (Remy Malan) (07/31/86)

here it is :

extract with sh and not with csh

--- cut here --- cut here ---

echo 'extracting README'
cat <<'//== E*O*F README ==//' >README
This shar archive contains utilities to let Mac generated PostScript be
printed on a PostScript printer (e.g. LaserWriter) connected to a UNIX host.

These utilities are known to work on a VAX running 4.2BSD and on a Gould 9080
running 4.3BSD.  Printing has been tested on the VAX with an Apple LaserWriter
as the PostScript device.

I assume you know about the <cmd>-K and <cmd>-F keystrokes on the Mac that
cause the Mac's LaserWriter driver to generate PostScript.  I have used these
keystrokes on a Mac+ running System 3.1.1 and Finder 5.2 with the LaserWriter
driver installed.  (Basically, choose "Print..." from the FILE menu and then
hit <cmd>-F or <cmd>-K immediately after clicking on the OK button in the
dialog box.  You will see a message about a PostScript file being created.)

<cmd>-K produces LaserPrep + document.
<cmd>-F produces document only.

NOTE: As far as I can tell, the <cmd>-K only works with the new system and
      drivers (i.e System 3.1.1 or greater and Finder 5.2 or greater).
      I am also fairly sure that you should not mix the old and new versions
      of LaserPrep and LaserWriter Driver; the versions look different enough
      to cause problems.
      I have also heard that it is illegal to send text copies of LaserPrep
      to other users, so you must find a way to generate that file on your
      own.  Sorry.

You will need to produce the LaserPrep file and possibly modify it using the
enclosed modification file directions.  Store your modified LaserPrep file
on the UNIX host.  Read comments in "laser" as well (Needs customization)!

Enjoy!
A. Remy Malan    7/24/86

//== E*O*F README ==//
echo 'extracting Courier.only'
cat <<'//== E*O*F Courier.only ==//' >Courier.only
Everything coming out in Courier?

The reason that everything comes out in Courier is that the LaserPrep
PostScript document only maps Courier into a Mac compatible form.  That is
why none of the other fonts are used even though they are resident on the
LaserWriter.

To solve the problem:

A. Use "FontAppend", a utility I wrote to automate the solution.

B. Manual Solution.
   Edit the PostScript documents you want to print and insert code to map the
   fonts you want.

   1. Find the line "%%EndProlog" in the document.
   2. Immediately above that line add a line or lines of the form
	/|______<FONT> /<FONT> <FLAG> rf
   where
	<FONT> is the name of the font you want to use.
	<FLAG> is a boolean flag controlling mapping - use "T" or "F"
	       The mapping flag controls the Mac <option> and <shift> effect.
	       "T" means modifier keys for extra symbols work.
	       "F" means modifier keys are NOT mapped correctly.
	       As far as I can tell, only /|______Symbol uses "F".

   e.g.
	To use PLAIN Helvetica in a document.
	/|______Helvetica /Helvetica T rf

	To use BOLD Helvetica in a document
	/|______Helvetica-Bold /Helvetica-Bold T rf

	To use Symbol...
	/|______Symbol /Symbol F rf

   Note that Symbol DOES NOT assert the mapping flag!  Using "T" does not work!
   Note that there are SIX (6) underscores in the font names!

   I tried to do this in the LaserPrep file but it seemed to corrupt the
   environment for non Mac users. (My printer has hooked up to a UNIX VAX).
   I suggest you try this first in the PostScript files you are printing.


A. Remy Malan  7/31/86

P.S.  I found that a PostScript reference manual was very useful during
      my experimentation with the LaserWriter.

//== E*O*F Courier.only ==//
echo 'extracting Prep.mod.insructions'
cat <<'//== E*O*F Prep.mod.insructions ==//' >Prep.mod.insructions
Instead of downloading LaserPrep with every PostScript file you want to print,
you can download LaserPrep *once* and have it resident in the printer for use
with your Mac generated PostScript files.  The only problem with this approach
is that if the printer's power gets turned off LaserPrep is lost.  Another
potential problem is if you try to send LaserPrep more than once, the Laser-
Writer seems to get very confused.

What can you do to solve this problem?

You can modify LaserPrep so that it checks if it has already been downloaded to
the LaserWriter.  If it has been downloaded already, LaserPrep aborts.
Otherwise LaserPrep will install itself.

The modification:

add/replace these lines:

--- cut here --- cut here ---

%!Adobe-1.0
%BAW - The LaserWriter loses Laser Prep (appledict) when power is cycled so
%BAW - Laser Prep must be re-executed at that time.  Alternately, Laser Prep
%BAW - can be sent before every "Mac" document to make sure it is present in
%BAW - in the LaserWriter.  The addition of the following line will prevent
%BAW - Laser Prep from executing if it is already present in the LaserWriter,
%BAW - thus saving alot of time.

userdict /md known {stop} if

%BAW - the real Laser Prep starts here
0000000000	%ARM - Printer password.  Default is 0.
% ) CopyRight Apple Computer, Inc. 1984, 1985   All Rights Reserved.
%{appledict version #36.0

--- cut here --- cut here ---

P.S.  Please note the above copyright notice from Apple!
      Note also the version number. (36.0)
//== E*O*F Prep.mod.insructions ==//
echo 'extracting makefile'
cat <<'//== E*O*F makefile ==//' >makefile
#
# Makefile for FontAppend.c and Fonts.lex
#

FontAppend: FontAppend.c lex.yy.c
	cc FontAppend.c -o FontAppend -ll

lex.yy.c: Fonts.lex
	lex Fonts.lex

//== E*O*F makefile ==//
echo 'extracting FontAppend.c'
cat <<'//== E*O*F FontAppend.c ==//' >FontAppend.c
/* ------------------------------------------------------------ */
/* C program to provide support to lex.yy.c file produced by	*/
/* lex utility.							*/
/*								*/
/* Written by  A. Remy Malan on 7/3/86.				*/
/*	       Tektronix, Inc.					*/
/*	       P.O. Box 500  MS 47-660				*/
/*	       Beaverton, OR., 97077				*/
/*	       (503)-627-4184					*/
/*								*/
/* Copyright 1986  Tektronix Inc.  All rights reserved		*/
/*								*/
/* (You may use this file and its output provided you do not	*/
/*  try to sell either or offer either as an inducement to buy  */
/*  another service or product.  You may modify this file	*/
/*  provided you follow the above restrictions. )		*/
/* ------------------------------------------------------------ */

#include   "stdio.h"

int   pass,     Cour_B = 0, Cour_O = 0, Cour_BO = 0;
int   Helv = 0, Helv_B = 0, Helv_O = 0, Helv_BO = 0;
int   Time = 0, Time_B = 0, Time_I = 0, Time_BI = 0;
int   Symb = 0;

main()
{
   pass = 1;
   yylex();

   rewind(stdin);

   pass = 2;
   yylex();
}
   
#include   "lex.yy.c"

//== E*O*F FontAppend.c ==//
echo 'extracting Fonts.lex'
cat <<'//== E*O*F Fonts.lex ==//' >Fonts.lex
/* ------------------------------------------------------------ */
/* LEX file to map PostScript fonts into Mac style fonts.	*/
/* This file produces a lexical scanner that is called by the	*/
/* main routine in FontAppend.c.				*/
/*								*/
/* Written by  A. Remy Malan on 7/3/86.				*/
/*	       Tektronix, Inc.					*/
/*	       P.O. Box 500  MS 47-660				*/
/*	       Beaverton, OR., 97077				*/
/*	       (503)-627-4184					*/
/*								*/
/* Copyright 1986  Tektronix Inc.  All rights reserved		*/
/*								*/
/* (You may use this file and its output provided you do not	*/
/*  try to sell either or offer either as an inducement to buy  */
/*  another service or product.  You may modify this file	*/
/*  provided you follow the above restrictions. )		*/
/* ------------------------------------------------------------ */

%%

"%%EndProlog"	{ if (pass == 2)  {
		     add_fonts();
		     ECHO;
		  }
		};

"/|______Courier-BoldOblique"	{ if (pass == 1)
				     Cour_BO++;
				  else
				     ECHO;
				};

"/|______Courier-Bold"		{ if (pass == 1)
				     Cour_B++;
				  else
				     ECHO;
				};

"/|______Courier-Oblique"	{ if (pass == 1)
				     Cour_O++;
				  else
				     ECHO;
				};

"/|______Helvetica-BoldOblique"	{ if (pass == 1)
				     Helv_BO++;
				  else
				     ECHO;
				};

"/|______Helvetica-Bold"	{ if (pass == 1)
				     Helv_B++;
				  else
				     ECHO;
				};

"/|______Helvetica-Oblique"	{ if (pass == 1)
				     Helv_O++;
				  else
				     ECHO;
				};

"/|______Helvetica"		{ if (pass ==1)
				     Helv++;
				  else
				     ECHO;
				};

"/|______Times-BoldItalic"	{ if (pass ==1)
				     Time_BI++;
				  else
				     ECHO;
				};

"/|______Times-Bold"		{ if (pass ==1)
				     Time_B++;
				  else
				     ECHO;
				};

"/|______Times-Italic"		{ if (pass ==1)
				     Time_I++;
				  else
				     ECHO;
				};

"/|______Times-Roman"		{ if (pass ==1)
				     Time++;
				  else
				     ECHO;
				};

"dss"	|
"/|______Symbol"		{ if (pass ==1)
				     Symb++;
				  else
				     ECHO;
				};

\n	|
.		{ if (pass == 2)  ECHO; };


%%

add_fonts()
{
   if (Cour_B)  print_font("Courier-Bold");
   if (Cour_O)  print_font("Courier-Oblique");
   if (Cour_BO) print_font("Courier-BoldOblique");

   if (Helv)    print_font("Helvetica");
   if (Helv_B)  print_font("Helvetica-Bold");
   if (Helv_O)  print_font("Helvetica-Oblique");
   if (Helv_BO) print_font("Helvetica-BoldOblique");

   if (Time)    print_font("Times-Roman");
   if (Time_B)  print_font("Times-Bold");
   if (Time_I)  print_font("Times-Italic");
   if (Time_BI) print_font("Times-BoldItalic");

   if (Symb) printf("/|______Symbol /Symbol F rf\n");
}


print_font(font)
char  *font;
{
   printf("/|______%s /%s T rf\n", font, font);
}

//== E*O*F Fonts.lex ==//
echo 'extracting laser'
cat <<'//== E*O*F laser ==//' >laser
#!/bin/csh
#
# Written by A. Remy Malan on 7/7/86.
#
# useage : laser <file1> <file2> ... <filen>
# Takes each file specified and ensures that all fonts used get mapped
# properly.  Also sends each file to the LaserWriter.
#
# You must modify this shell so that the correct printer commands are
# issued on your system.  Below I have used "lpz" as a place holder for
# the machine specific commands.
#
# tmp$$ creates a scratch file with the name "tmp<shell-process-ID>".


# Send modified LaserPrep file to LaserWriter to ensure that the
# printer has the Mac definitions in it.

# e.g. lpz LaserPrep.v36.mod

foreach i ($argv)
   FontAppend < $i > tmp$$
#  send tmp$$ to LaserWriter - e.g. lpz tmp$$
   rm tmp$$
end

//== E*O*F laser ==//