To: macgifts@mac.archive.umich.edu
Subject: [*] LaserWriter 8.x Hacks & Patches, version 1.1
Date: Tue, 07 Dec 93 11:40:16 EST
From: Don Markuson <dmm@tiger1.CV.COM>


Enclosed is a brief report on hacks and patches folks can make to the
LaserWriter 8.x driver to tailor it better to their needs or environment.
It covers how to:

  - Make the SETUP button in the Chooser always active
  - Disable the AppleTalk requirement (use to only generate PS files)
  - Select N-up choices from the Print Dialog
  - Modify N-up choices for additional/other layouts
  - Disable N-up page borders
  - Modify which fonts are included in PS files
  - Disallow printing of multiple copies
  - Avoid unnecessary use of the Symbol font for certain symbols

..Don Markuson
  dmm@tiger1.cv.com

--------------Cut Here-------------

Patches YOU can make to LaserWriter 8.x.               DMM  Rev. 1.1  07-Dec-93

Supplementing Ric Ford's 28-Jun-93 MacWeek MacInTouch column on patches to the
LaserWriter 8 driver, here's some more info based on my own experimentation
with thanks to Ric and his sources.  All require using ResEdit or equivalent,
however some have been incorporated into a new freeware tool called "Printer
Defaults" by John Rawnsley, which is intended to replace the aging MyPageSetup.
Look for rev 1.1.1 or later at standard archive sites.


ALWAYS MAKE A BACKUP COPY OF THE DRIVER BEFORE MONKEYING WITH IT USING RESEDIT!


1)  MAKE SETUP BUTTON IN CHOOSER ALWAYS ACTIVE

    To make the Setup button in the Chooser always active (i.e., so it works
    even when AppleTalk is disabled or you have no PostScript printers on the
    network):

    In ResEdit, open the nrct resources by double-clicking on their icon, then
    double-click on nrct -4096.  Change the second rectangle from 0,0,0,0 to
    match the first rectangle (112,178,132,255 in US versions of LW 8).  Then
    change the first rectangle to 9999,9999,9999,9999.  (If you change the
    first to 0,0,0,0, you'll get a strange-looking circle in some weird place
    in the Chooser window because this button is outlined.)

    You've now enabled the Setup button that's always active and disabled the
    one that stays grayed out until a configurable printer shows up in your
    network.


2)  DISABLE APPLETALK REQUIREMENT

    To patch driver not to require AppleTalk (e.g., so you can use it in PS
    file generation mode when not on a network):

    Open the PACK resources by double-clicking, then double-click on the PACK
    -4096 resource to open it (using the Hex Editor).  Change the byte at
    offset 000C from "ED" to "6D".  This works best in combination with the
    nrct patch discussed above to activate the Setup button in the Chooser at
    all times.

    Fortunately, there's no longer a need to patch the driver to always
    generate a PS file, since the choice to generate PS files in the Print
    dialog is now "sticky".

    Once you've saved this change and exited ResEdit, you need to "flush the
    Chooser's cache" for this change to be noticed:  remove all LaserWriter 8
    variants from the Extensions and/or System Folder (e.g. move them onto the
    desktop), open the Chooser, close the Chooser, and finally put your LW 8
    variants back.

    !! WARNING !!  A LaserWriter driver crippled in this manner will no longer
    !! WARNING !!  see printers on an AppleTalk network (LocalTalk -or-
    !! WARNING !!  EtherTalk).  This patch is intended only for those who have
    !! WARNING !!  no such network and want to just generate PS files.  If
    !! WARNING !!  you're a portable Mac user and move between a networked and
    !! WARNING !!  non-networked environment, keep two copies of the LW driver,
    !! WARNING !!  one patched to avoid AppleTalk and the other regular.


3)  SELECT N-UP FROM PRINT DIALOG

    To allow N-up choices directly within the Print Dialog (in addition to
    Page Setup):

    The DITL -8191 resource includes an N-up pull-down menu way off the right
    side of the dialog.  To pull it in, open the DITL resources by double-
    clicking on their icon, then JUST SELECT (click once) on DITL -8191.
    Pull down "Open Using Template..." from ResEdit's Resource menu, and use
    the "DITL" template (which should be the default choice).  Scroll to the
    bottom of the list to item 31, which should look something like:

    31) *****
        Display rect: 46   600   63   770
        Item type:    $07
        Item info:    <some binary bytes>

    Change the display rect to something inside the visible dialog area; I
    used:

        Display rect: 46   110   63   280

    Do NOT click on the "Set" button to the right of this entry; simply close
    the window to make the change.

    This places the N-up pull-down just below "Pages:" in the Print dialog.
    The N-up setting for the document can be changed using either this
    control or the one in Page Setup; once you change it, that setting
    is retained and will be the default for the next time Page Setup or Print
    are used.

    (I've been told the above placement for this control isn't the best choice
    if you've got a printer which supports PostScript FAX, since a FAX radio
    button appears in this area of the Print dialog.  Another strategy would
    be to move Item 30 off-screen (it seems to be simply a status field which
    reiterates the N-up setting when greater than 1), and then move the N-up
    pull down control into the lower left area of the dialog where this field
    used to be.  Item 21, the outline surrounding the "Paper Source" area of
    the dialog must have its height shrunk in order to allow mouse clicks to
    reach the N-up pull-down.  Feel free to experiment.)


4)  MODIFY N-UP CHOICES

    To modify the N-up dialog to alter or add other organizations you might
    desire instead of the 1-, 2-, and 4-up organizations provided:

    Up to 8 choices, or N-up menu items, are allowed (including 1-up, which
    should not be modified).  Open the MENU resources by double-clicking on
    their icon, then double-click on MENU -8185.  Clicking to select a menu
    item allows you to change the text of that entry.  You can also alter
    its text style using the Style menu which appears when MENU items are
    opened.  I don't recommend changing any other attributes.  To add another
    choice to the list, select "Create New Resource" from ResEdit's Resource
    menu.

    The corresponding specification for each N-up layout is in the NPLY -8192
    resource.  This resource consists of x-1 groups of 3 longwords (12 bytes),
    where x is the number of N-up choices (subtracting one because 1-up is not
    represented in this resource).  The 3 longwords are:

        1.  0 = portrait, 1 = landscape orientation of layout on paper
        2.  the number of columns in the layout
        3.  the number of rows in the layout

    and each one corresponds to its positional location in the MENU resource
    (excepting 1-up, of course).  The original MENU -8185 and corresponding
    NPLY -8192 are: 

        MENU choice         Landscape   # columns    # rows
        -----------         ---------   ---------   ---------
           1-up             (not represented in NPLY)
           2-up             0000 0001   0000 0002   0000 0001
           4-up             0000 0000   0000 0002   0000 0002

    Others you could add:

           6-up             0000 0001   0000 0003   0000 0002
           8-up             0000 0001   0000 0004   0000 0002
           9-up             0000 0000   0000 0003   0000 0003
          16-up             0000 0000   0000 0004   0000 0004
        1000-up (!)         0000 0001   0000 0028   0000 0019

    If everything is done properly, the visual effect of N-up in the Page
    Setup dialog should work correctly for the choices you've added or changed.


5)  DISABLE N-UP BORDERS

    Starting at LaserWriter version 8.1.1, it's particularly easy:  Open the
    PRFS resources by double-clicking on their icon, then double-click on PRFS
    -8192.  You should be presented with a nice template of yes/no choices.
    Change the one labelled "Don't frame n-up pages" from 0 to 1.  (I'm not
    altogether clear on what the other options do.)

    For earlier revs of LaserWriter 8.x, open the PS resources by double-
    clicking, then double-click on the PS -8184 resource to open it (using the
    Hex Editor).  Change the byte at offset 04EB from 0D (carriage-return) to
    25 ('%' PS comment character).  [In LW 8.1.1, the offset is 051C, but above
    method is much nicer.]


6)  MODIFY WHICH FONTS ARE INCLUDED IS PS FILES

    The resource which contains the list of Excludable Fonts is STR# -8174,
    and MENU -8180 is where the "All But Standard 13" text is kept.  Let's say
    you wanted to make this "All But Standard 35", excluding the LaserWriter
    Plus set of fonts.  Here's what to do:

    Open MENU items by double-clicking on their icon, then double-click on MENU
    -8180 to open it (you may have to scroll to see it).  Select the "All But
    Standard 13" item and change the "13" to "35" in the Text box on the right.

    It turns out the pull-down control for this selection is only wide enough
    to accommodate "All But Standard 13" and can't handle the slightly wider
    "35".  To correct this, double-click your way to open the CNTL -8180
    resource.  Increase its width slightly by changing the rightmost number
    from 257 to 265.

    Similarly, double-click your way to open STR# -8174.  To add new entries,
    scoot to the bottom and click on the "14) *****" text; an outline should
    appear.  Pull down "Insert New Field(s)" from the Resource menu (or type
    it shortcut, Command-K).  Do this 22 times (35 - 13) to insert enough blank
    entries, then fill them in with the following LaserWriter Plus font names:

       AvantGarde-Book
       AvantGarde-BookOblique
       AvantGarde-Demi
       AvantGarde-DemiOblique
       Bookman-Light
       Bookman-LightItalic
       Bookman-Demi
       Bookman-DemiItalic
       Helvetica-Narrow
       Helvetica-Narrow-Oblique
       Helvetica-Narrow-Bold
       Helvetica-Narrow-BoldOblique
       NewCenturySchlbk-Roman
       NewCenturySchlbk-Italic
       NewCenturySchlbk-Bold
       NewCenturySchlbk-BoldItalic
       Palatino-Roman
       Palatino-Italic
       Palatino-Bold
       Palatino-BoldItalic
       ZapfChancery-MediumItalic
       ZapfDingbats

    An alternative to this method is to use Hugo Ayala's handy shareware
    Trimmer control panel, which continues to work with LaserWriter 8.x as it
    has with LaserWriter 7.x.  This tool lists your installed fonts and easily
    lets you select which ones are to be included.  (Its checkbox to Include
    LaserWriter Header has no meaning with LW 8.x.)


7)  DISALLOW PRINTING MULTIPLE COPIES

    Here's what to do to prevent users from (easily) printing multiple copies
    using LW8.  (Users can, of course, print their document more than once, and
    if they're going to do this, it's *much* more efficient on network band-
    width and printer availability to allow them to specify multiple copies in
    the LW driver):

    Open the DITL resources by double-clicking on their icon, then double-click
    on DITL -8191.  Double-click on the boxed field where the number of copies
    would be entered (item #10, it should appear with a "1" in it).  Change its
    type from "Edit Text" to "Static Text" using the pull down menu that should
    appear.

    This turns out to be all that's needed.  However to make it a bit harder
    for a bright user to defeat, make the following minor mod as well, so even
    if they figure how to specify >1 copy, the PostScript code will ignore it:

    Open the STRI resources by double-clicking on their icon, then double-click
    on STRI -8188 to open it using the Hex Editor.  Pull down "Find ASCII" from
    the Find menu.  Find ASCII "/copies ^d def copies setcopies"
                    Change To: "^d pop/copies 1 def 1 setcopies"


8)  AVOID UNNECESSARY USE OF Symbol FONT

    LaserWriter drivers since the early days have relied upon the Symbol font
    for printing the following symbols from the upper half of Apple's standard
    roman font encoding:
                                LW7    LW8   Unnecessarily
        Encoding  Character     Sub?   Sub?   Substituted
        --------  ------------  ----   ----  -------------
           A1     degree          *      *         *
           A8     registered      *                *     
           A9     copyright       *                *
           AA     trademark       *                *
           AD     notequal        *      *
           B0     infinity        *      *
           B1     plusminus       *      *         *
           B2     lessequal       *      *
           B3     greaterequal    *      *
           B5     mu              *      *         *
           B6     partialdiff     *      *
           B7     Sigma           *      *
           B8     Pi              *      *
           B9     pi              *      *
           BA     integral        *      *
           BD     Omega           *      *
           C2     logicalnot      *                *
           C3     radical         *      *
           C5     approxequal     *      *
           C6     Delta           *      *
           D6     divide          *                *
           D7     lozenge         *      *
           E0     applelogo       *      *

    [LaserWriter 7.x used LW7 Sub? list for resident (ROM-based) fonts and
    LW8 Sub? list for downloaded fonts (PostScript or TrueType).]

    Because of this substitution, these symbols will not print with attributes
    like bold or italics (even if they appear that way on-screen).  If you've
    got a relatively recent printer (certainly any PS Level 2 printer), then
    you can alter the LaserWriter driver to not switch to the Symbol font for
    the unnecessarily substituted symbols above.

    In LaserWriter 8.x, the mapping table is in resource encM -8192; open it
    by double-clicking your way into it.  It is a table of byte values indexed
    by Mac character encoding values starting at hex A0, so the first byte in
    the table corresponds to character encoding A0.  If the corresponding byte
    in the table is non-zero, it represents that character's substitute
    encoding in the Symbol font.  Change the bytes at the following offsets to
    00 in order to prevent unnecessary substitutions:

       Offset  From   To
       ------  ---- ----
        0001   B0 --> 00
        0011   B1 --> 00
        0015   6D --> 00
        0036   B8 --> 00
    

To save your changes in ResEdit, simply quit ResEdit, answering "Yes" to the
inevitable question about whether you really want to save your changes.


Patches still being sought:

  - Allow PostScript file generation to be backgrounded.  It is presently
    crippled to work only in foreground for consistency with the EPS-with-
    Preview modes which can't be backgrounded because of the Preview.


Grateful acknowledgements go to the following folks for their inputs:

  - Dennis Chesters, who prompted me to investigate the Symbol font funniness.
  - John Kalucki, who sent me some interesting N-up hacks that are too
    specialized to include here.
  - Edgar Knapp, who suggested a suitable warning accompany hack #2.
  - Mike McDuffie, who incorporated some of these into a ResCompare patcher.
  - John Rawnsley, who brought the LW 8.1.1 PRFS resource to my attention, and
    took it upon himself to update the aging and sometimes cranky MyPageSetup
    tool with his recent freeware "Printer Defaults", which as a bonus also
    allows you to incorporate some of the above hacks (or remove them).

And special thanks go to:

  - Richard Blanchard, who helped design and build LaserWriter 8, for sneaking
    many of the hooks needed for these patches into LW 8 knowing there are
    folks out there like you and me who might want to exploit them!

  - Ric Ford, who courageously publicizes and investigates Mac problems, then
    vents our collective frustrations to Apple in a way that's both helpful
    and entertaining.  I never miss his MacInTouch column in MacLeak!


Happy hacking!

..Don Markuson
  Computervision Corp.
  201 Burlington Road
  Bedford, MA  01730
  <dmm@tiger1.cv.com> or
  <d.markuson@ieee.org>