[comp.sys.mac.programmer] patStretch ?

earleh@eleazar.dartmouth.edu (Earle R. Horton) (12/01/88)

I am writing a dot matrix printer driver so I can print graphics on my
Tandy printer from my Macintosh.  It saves application drawing
commands in a QuickDraw picture.  After the application has drawn a
page, my PrClosePage routine rescales the portRect of my printing port
to match the printer's Rect, which is 120 DPI on letter-size paper,
1/4 inch margins all around.  It then calls DrawPicture to draw the
expanded image, and sends the bits on to the printer.  I have font
scaling and fractional font widths enabled when the application draws
into my printing port, so text justification comes out right. The
device field of my printing port is set to zero, so that QuickDraw
will scale things as if drawing to the screen.

I am happy to report that I have thus printed several MicroSoft Word
documents, a HyperCard card, a Finder directory listing, and a few
screen dumps.  Results are just about WYSIWYG, if I have the right
fonts installed.  Scaling is a 50% increase (80 DPI in application's
portRect and 120 DPI in output portRect), so not all font families
have fonts which will scale properly.  I also have an "exact bits"
mode which I use when doing screen dumps or if I want dot-addressible
graphics in a drawing or paint program.

There is a "patStretch" field in the GrafPort data structure, which
Inside Macintosh assures me "is used during output to a printer to
expand patterns if necessary."  I need to know how to use this field
to control pattern scaling.  Right now, patterns are not scaled when
they come out on the printer, which means they are reduced 33% in
size, relative to other objects in a drawing.  If I could double the
size of output patterns, then they would be increased in size by 33%,
which might look better.  On another printer with higher resolution,
patterns might come out exactly to scale with the rest of the drawing
if scaled by the same amount as the picture.

On a related note, I call SetFractEnable(true) and
SetFScaleDisable(false) before the application starts drawing into my
printing port.  When my PrCloseDoc routine is called, I call these
routines to reset the default values for fractional fonts and font
scaling.  Is there a way I can find out what the previous state is,
short of reading the low memory globals directly?  Should I just
assume that if an application developer is savvy enough to want font
scaling and fractional font widths, he will set things up when he is
done printing?

I am soliciting all opinions on the patStretch thing.  Documented,
undocumented, even hearsay are welcome.

Earle R. Horton. 23 Fletcher Circle, Hanover, NH 03755
(603) 643-4109
Sorry, no fancy stuff, since this program limits my .signature to three

casseres@Apple.COM (David Casseres) (12/02/88)

In article <11256@dartvax.Dartmouth.EDU> earleh@eleazar.dartmouth.edu (Earle R. Horton) writes:
>... The
>device field of my printing port is set to zero, so that QuickDraw
>will scale things as if drawing to the screen.

Just a clarification: setting the device field to 0 doesn't affect scaling;
it just causes QuickDraw's text styling (bold, italic, underline, etc.) to
use screen parameters.

>There is a "patStretch" field in the GrafPort data structure, which
>Inside Macintosh assures me "is used during output to a printer to
>expand patterns if necessary."  I need to know how to use this field
>to control pattern scaling.  Right now, patterns are not scaled when
>they come out on the printer, which means they are reduced 33% in
>size, relative to other objects in a drawing.  If I could double the
>size of output patterns, then they would be increased in size by 33%,
>which might look better.  On another printer with higher resolution,
>patterns might come out exactly to scale with the rest of the drawing
>if scaled by the same amount as the picture.

The only values that should ever be used for the patStretch field are 0 and
2.  Zero is the default, leaving patterns unscaled, and 2 causes patterns
to be scaled up by a factor of 2.  Unfortunately no other scaling is avail-
able.

>On a related note, I call SetFractEnable(true) and
>SetFScaleDisable(false) before the application starts drawing into my
>printing port.  When my PrCloseDoc routine is called, I call these
>routines to reset the default values for fractional fonts and font
>scaling.  Is there a way I can find out what the previous state is,
>short of reading the low memory globals directly?

No.

>Should I just
>assume that if an application developer is savvy enough to want font
>scaling and fractional font widths, he will set things up when he is
>done printing?

No, too many applications are not that savvy.  You have to go look in low
memory to know the application's settings, then restore them when you're
done.

David Casseres