
APPLE IIGS SYTLEWRITER PRINTER DRIVER v1.0 	--		TECHNICAL DESCRIPTION (ERS)

Written by Ben Koning (ben@apple.com x45806 408/738-1763)

November 1991



INTRODUCTION

This is a printer driver for the Apple "StyleWriter" ink jet printer.  It is a
feature-reduced printer driver, written in a very short time in order to get a
driver out to the public as soon as possible.  It is based on a similarly
feature-reduced HP DeskJet PLUS driver.  The philosophy is to be short on bells
and whistles and to be long on zero-embarrassment usability.



DEVIATIONS FROM OTHER DUMB-DEVICE PRINTER DRIVERS

Communications is handled internally inside the driver, due to the special
way in which the 57.6K baud software-handshaking serial interface operates.
The SCC channel A/B selection is inferred from the current printer-port driver
settings: the PMGetPortName call is used; and a case-insensitive check is made for
the first few characters of the "Printer" or "Modem" filenames returned by the
PMGetPortName call.

Pages are recorded as pictures, rendered, and printed, one at a time; they are not
saved en masse for the entire document.  All copies of the current page are printed
at PrClosePage time, like the LaserWriter driver.

Picture data for the pages is spooled to disk if necessary, like the version 4.0
or later ImageWriter and ImageWriter LQ drivers.  If the user booted over the
network, then the spool file is located in the correct {username} directory;
otherwise, it is located in */System/Drivers.  The file name is TMP.xxxx, where
"xxxx" is a 4-digit random hexadecimal number.  The file is deleted when finished.

This driver contains all of the features of previous dumb-printer drivers, with
the following important exceptions:

	* No color, and arbitrary grayscale support.  Standard black and standard
	  white must exist in standard color palette locations; otherwise, color
	  to black/white mapping will be incorrect.
		
	* No landscape mode.
	
	* No draft ("text only") mode.
	
	* No reduction ("66% reduction", "33% reduction", etc) modes.
	
	* The PrPixelMap call does not support printing of a subset of a pixelmap.
	  Only the LocInfo structure is considered; the source rect is ignored.
	
	* There is no notion of separate Page Setup and Print Job dialogs; they
	  are the same but don't look the same.  Saves much code/complexity.

All paper types mentioned in the Macintosh StyleWriter Driver ERS (by Suki Lee)
are supported.

Error handling, as described in the Macintosh StyleWriter ERS is supported by
means of alert dialogs for all of the same conditions.



SCALING STRATEGY

The driver scales the recorded page definition picture to 4.5x (360 dpi) or to
2.25x (180 dpi).  Bitmaps are thus scaled; very rough patterns may exhibit some
artifacts but usually look ok.  Graphic objects other than text are rendered
correctly, since they are mathematically defined.  Text strings are scaled to 5x,
however, to avoid Font Manager burden and to avoid total loss of visual fidelity.
In order cause the 5x text strings to fit in the 4.5x space, and to deal with
horizontal font scaling error, line layout is performed.



HORIZONTAL LINE LAYOUT FOR TEXT

Horizontal line layout is implemented.  The intercharacter spacing of text strings
is manipulated so that a given string played back during the page picture rendering
process is drawn with 90% of its original width.  This is done by calculating small
temporary negative values for SpaceExtra and CharExtra for each individual string.

Line layout thus solves the problems of slight horizontal font scaling error (causing
overlap, especially in text with face modifications (ie, bold, italic, etc)) and
the difference in device resolutions.

Setting wDev bit 14 disables line layout. This bit is always cleared by default
and can only be set by an application.



VERTICAL ANTI-CLIPPING FOR TEXT

The notBIC transfer mode is used to draw text strings if the text transfer mode is
set to modeCopy (default).  This makes text transfer behave in an OR-like fashion
so that descenders are not clipped due to the scaled font being taller than the
exact multiple of the original (application-requested) font height.  This will
cause a problem for applications that rely on using the bounding box around text
to erase its surroundings.  The notBIC transfer mode is substituted if the
application's requested transfer mode is the default modeCopy; if it is anything
else it is left alone.

Setting wDev bit 13 disables the OR-ing text drawing mode behavior described above.
This bit is always cleared by default and can only be set by an application.



640 MODE PIXELMAP ANTI-BLURRING

For pixelmaps in 640 mode, CopyPixels would normally cause loss of black and white
detail while scaling up in order to keep dithered 2-bit color pixel pairs intact.
Instead, StdPixels is patched out and the pixelmap is prescaled by the driver,
which then calls StdPixels to do the actual transfer at 1:1 scaling.  This only
done if 640 mode and only if high quality is selected.

Setting wDev bit 12 disables special 640-mode pixelmap handling.  This bit is
always cleard by default and can only be set by an application.



PAGE-AS-JOB HANDLING

If a PrOpenDoc call happens immediately (within 5 seconds, based on TickCount) after
a PrCloseDoc call, then certain initialization tasks, such as the sending of
immediate printer reset and the resetting of the page counter, are not performed.
This is for those programs that choose to treat each page as an entirely separate
document.

This is necessary because the StyleWriter's reset command sequence interrupts the
printer from whatever it was previously doing, and so multiple-page documents could
not be printed reliably otherwise.  One of the other benefits of this technique are
that the page counter in the status box works correctly with page-as-job applications.

Setting wDev bit 15 disables the status message box displayed on top of the
screen; this bit is always cleared by default and can only be set by an
application.



SPEED

The following measures are taken to enhance speed performance, in order of
implementation:

	* Trivial source pixel large-area whitespace elimination razor.
	* Lookup table driven source to print pixel conversion with auto grayscale.
	* QuickDraw text clip/draw code not executed if outside of band buffer.
	* Multibank (>64K) band rendering buffer, if memory allows.
	* Razor within compressor for repeating source pixel bytes.
	* More efficient overall compressor code.
	* Repeat-scanline opcode used for non-vertical-condense case.
	* Draw-blank-scanline opcode used when possible.
	* InstallWithStats font manager code not executed if outside of band buffer.
	* Full black-case/white-case opcodes instead of using the repeat opcode.


