Subject: laserwriter8hacks1.2.txt Date: Fri, 01 Sep 1995 18:15:50 -0400 From: Don Markuson Enclosed is version 1.2 of LaserWriter 8.x Hacks & Patches text document, describing various LaserWriter 8.x driver hacks for those unafraid of ResEdit. It updates the previous version 1.1 already in the archives. New tidbits at 1.2: how to transpose the N-up page order to go down rather than across, and an answer to a common question about how to add new page sizes to the page setup dialog; plus assorted other clarifications. Apologies for neglecting to submit this sooner. ..Don Markuson d.markuson@ieee.org - - - Patches YOU can make to LaserWriter 8.x. DMM Rev. 1.2 03-Jan-95 [Changes from previous version are tagged with changebars at left margin.] 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 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 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: 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 | because it's very close to the "Destination" box. Another strategy would | be to move Item 30 off-screen (e.g., to 118 657 133 890; 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 (to 124 4 141 175). Item 21, the outline surrounding the "Paper Source" area of the dialog must have its height shrunk (by around 21 pixels) in order to allow mouse clicks to reach | the N-up pull-down. Change its Rect to 66 3 120 294. Feel free to experiment with other possibilites.) 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). (Open this resource using the ResEdit's | Hex Editor.) The 3 longwords are: | 1. orientation of N-up layout on physical sheet (value is multiplied | by -90 degrees of rotation; the following are useful ones): | 0 = portrait, 1 = 270-degree landscape, -1 = 90-degree landscape 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 you prefer that 90-degree Landscape rotation be used instead of -90 | (270)-degree rotation, change all the Landscape values of 0000 0001 above | to FFFF FFFF (for -1).) 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 IN 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. | WARNING! QuarkXpress 3.3 (and perhaps one or two other applications) | apparently don't like this field being altered from "Edit Text", so a | "safer" alternative might be to leave it as "Edit Text" and move it off- | screen by setting its Top and Left values to 999. If you do this, then | you should definitely implement the following suggestion as well: 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 | | |9) TRANSPOSE N-UP PAGE ORDER FROM ACROSS TO DOWN | | The way LaserWriter 8.x is constructed, N-up page images are ordered across | rows rather than down columns. To reverse this, permanently or by making | it configurable in the Page Setup Options dialog, there are three resources | of interest: | | PS -8184 contains LW 8's N-up dictionary, which must be altered to | effect the transposed page ordering. | DITL -8189 is the Page Setup Options dialog, in which you can change the | text of the Invert Image button. | STRI -8188 contains the segment of PS code included in jobs that request | the Invert Image option. | | Open PS -8184 by double-clicking on the PS resource icon then double-click | on PS -8184. Pull down "Find ASCII" from the Find menu. Find ASCII | "/nupshowpage". (Leave the Change To field empty since there's a lot to | change.) "/nupshowpage" is the routine which handles processing the page | order, and should look like: | | /nupshowpage{ | gR | mT concat | framenup{pagemarg 2 div nups div dup mT idtransform abs neg exch abs | neg exch paperw paperh rS}if | /pgx pgx 1 add dup nx eq{ | pop 0 store | paperw 1 nx sub mul | /pgy pgy 1 add dup ny eq{ | gS realshowpage gR | pop 0 store | paperh 1 ny sub mul | }{ | store paperh | }ifelse | }{ | store paperw 0 | }ifelse :T | mT $m invertmatrix concat startpage | }bd | | If all you want to do is force the transposted ordering, change the few | lines between the ones beginning "framenup{" and "mt $m invertmatrix" to | instead look like the following (effectively swapping 'y' for 'x' and 'h' | for 'w', and adding a final 'exch': | | /pgy pgy 1 add dup ny eq{ | pop 0 store | paperh 1 ny sub mul | /pgx pgx 1 add dup nx eq{ | gS realshowpage gR | pop 0 store | paperw 1 nx sub mul | }{ | store paperw | }ifelse | }{ | store paperh 0 | }ifelse exch :T | | If you want to be able to control the transposition order, change this | routine thusly: | | /nupxpose false def %DMM [Or true if you want down-first as default] | /nupshowpage{ | gR | mT concat | framenup{pagemarg 2 div nups div dup mT idtransform abs neg exch abs | neg exch paperw paperh rS}if | nupxpose{ %DMM | /pgy pgy 1 add dup ny eq{ | pop 0 store | paperh 1 ny sub mul | /pgx pgx 1 add dup nx eq{ | gS realshowpage gR | pop 0 store | paperw 1 nx sub mul | }{ | store paperw | }ifelse | }{ | store paperh 0 | }ifelse | exch}{ %DMM | /pgx pgx 1 add dup nx eq{ | pop 0 store | paperw 1 nx sub mul | /pgy pgy 1 add dup ny eq{ | gS realshowpage gR | pop 0 store | paperh 1 ny sub mul | }{ | store paperh | }ifelse | }{ | store paperw 0 | }ifelse %DMM | }ifelse :T | mT $m invertmatrix concat startpage | }bd | | Now, to provide the control hook, modify DITL -8189 Item 13. Open the DITL | resources by double-clicking on their icon, then double-click on DITL | -8189. We'll replace the meaning of the "Invert Image" control which most | folks seldom use. Double-click on this control (item #13) to bring up | an edit dialog for that control. Change the text from "Invert Image" to | "Transpose N-up Order (On=Down)" [or On=Across if you set "/nupxpose true | def above instead of false]. Also change the number in the Right field | from "248" to "407" to increase the width of the control so all of this | text appears. (You can also adjust the size of the control by closing the | control's edit dialog and dragging the little black sizing control on the | lower right corner of the selected dialog item itself.) | | Finally, open the STRI resources by double-clicking on their icon, then | double-click on STRI -8188 to open it using the Hex Editor. This resource | is a list of Pascal strings where the string offsets are stored in a table | at the beginning of the resource. (Each string is preceded by its length | in the body of the resource.) Pull down "Find ASCII" from the Find menu. | Find ASCII "/origtrans". (Leave the Change To field empty since there's a | lot to change.) | | "/origtrans" is the beginning of the string that's sent when the (former) | Invert Image control is checked. Replace this existing string: | | /origtrans currenttransfer def | [{1 exch sub}/exec load dup | currenttransfer exch] cvx bind settransfer | gS np clippath 1 setgray fill gR /$i T def | /pattransf{1 exch sub}def | | with one that simply updates /nupxpose (and obliterate the rest of the | string so its overall length is unchanged): | | /nupxpose T def %DMM%%%%%%%%%% | %%%%%%%%%%%%%%%%%%%%%%%%%%% | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | %%%%%%%%%%%%%%%%%%%%%%%%% | | [Note that if you've decided to default to down rather than across, set | /nupxpose to "F" instead of "T" above.] Obliterating the rest of the | string by using PostScript comment characters (%) avoids having to update | all the string offsets at the beginning of this resource. (The next string | in the resource begins with byte 12 hex followed by "%%IncludeFont:", and | should remain at the same offset as it was originally. You might note this | prior to making the change above to simplify obliteration.) To save your changes in ResEdit, simply quit ResEdit, answering "Yes" to the inevitable question about whether you really want to save your changes. | | |Here are some additional hacks that DON'T require ResEditing the LW 8.x driver |directly: | | |10) ADD A NEW "PAPER SIZE" TO THE PAGE SETUP DIALOG | | This can be entirely handled by modifying the PostScript Printer | Description (PPD) file that you set up LaserWriter 8.x to use. (To find | out which printer description file you're using, Open the Chooser, | select the LW 8.x driver and your printer, then click the "Setup" button. | The box that pops up should indicate which PPD is currently selected. You | use "Select PPD..." to select another.) Printer Description files are | simply text files that normally live in the "Printer Descriptions" folder | within Extensions under your System Folder. | | You can use any text editor like TeachText, Alpha, BBedit, etc., to view | or edit these Printer Description files. (MAKE A BACKUP COPY FIRST!) | | To add a new paper size, you need to update four sections of the PPD which | define paper and page parameters for the various paper sizes supported on | the printer: *PageSize, *PageRegion, *ImageableArea, and *PaperDimension. | | The LW driver picks these up, but it tries to be pretty clever. It looks | at the PaperDimension values and shows only those that are unique | (selecting as the name it uses in its pull-down list the last unique one it | encounters). (The "..Small" variations use the same *PaperDimension as | what they're based on but a different *ImageableArea which is used whenever | the "Larger Print Area" checkbox in the Page Setup Options dialog is | deselected.) | | To add something like a 4x6 card, do the following (this example uses the | LaserWriter II NT PPD file as the base for this example): | | 1. Duplicate the existing "Letter/US Letter" entry for each of these 4 | parameters, renaming them as "4x6/4x6 Card". (The value to the right | of the `/' is how it'll appear in the LW dialog pull-down list.) | | 2. Modify the *ImageableArea of 4x6Card to read: | | *ImageableArea 4x6/4x6 Card "36 36 468 327 " | | [these parameters are: llx lly urx ury] | (Here, I've assumed you would tape the 4x6 card to a letter-sized piece | of paper 1/2" (36 pt) from its lower left edge, allowing the printer to | access its full area.) | | 3. Modify the *PaperDimension of 4x6Card to be close to, but not exactly | match existing Letter-based entries. In LaserWriterII NT's PPD, there's | Letter (612x792), Monarch Envelope (611x792), and Commercial Envelope | (610x792). I chose 613x792 for 4x6Card so it's unique yet is close | enough to 612 such that the absolute value is less than 4, which is a | PostScript Level 2 printer's lookup tolerance for selecting a paper | source. (I believe you can also use fractional values for uniqueness, | but haven't tested it): | | *PaperDimension 4x6/4x6 Card "613 792 " | | 4. Save the new PPD under a different name. | | 5. Go to Chooser, rechoose the LW 8.x driver, click Setup button and | select the newly edited PPD file. | | When you next open the Page Setup dialog in LaserWriter 8.x and choose | the appropriate Paper Size from the pull-down, the cute graphic at the left | should represent a scale image of the paper and where on the paper the | imageable area will fall. You can also click once on this picture to see a | numeric representation of the paper size and imageable area parameters (the | latter are shown as margins, however), in inches. Click again for the same | in centimeters. Click again to return to the graphical view. | | If you're having problems, John Rawnsley (see acknowledgements below) | told me that by creating a PLRT resource with ID 1 which contains a single | byte value of 01, the LW 8.x will pop up an alert if it has trouble | parsing the PPD file. Changing this value to 00 (or deleting the resource) | restores the original behavior of no alert). 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. | - Martin Jourdan who corrected me about some aspects of N-up in the Print | Dialog. | - Brenda Whitehead who noted the problem QuarkExpress had with the patch to | disallow multiple copies, and proposed the alternative idea. - Mike McDuffie, who incorporated some of these into a ResCompare patcher. | - Neil Mickelson, who also incorporated some of these hacks into another | ResCompare patcher called "LaserWriter 8.1 Patch". URL: | ftp://ftp.uu.net/archive/systems/mac/info-mac/prn/laserwriter-81-patch-15.hqx - 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). URL: | ftp://ftp.uu.net/archive/systems/mac/info-mac/prn/printer-defaults-132.hqx 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 | Peritus Software Services, Inc. | 2400 Computer Drive | Westboro, MA 01581 | <--Preferred |