Select a font into PrinterCanvas after changing mapping mode to MM_ANISOTROPIC

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Select a font into PrinterCanvas after changing mapping mode to MM_ANISOTROPIC

Yar Hwee Boon
Hi all

When I try to run the code below in a workspace (it'll probably print
a page, unless you have some sort of print preview available, such as
the HP DeskJet 970). The text printed out is a few times bigger than
what a 12 pt Arial should look like on paper (depending on your/my
printer to screen resolution). Obviously the problem doesn't occur if
MM_TEXT is used. Is what I am doing right? I noticed that
Canvas>>font: actually contains sets the font to use the printer
canvas resolution (in the line "font resolution: self resolution.").
This seems to assume that MM_TEXT has to be used?

======
c := PrinterCanvas choose.
c mapMode: (Win32Constants at: #MM_ANISOTROPIC).
c windowExtent: Canvas desktopResolution.
c viewportExtent: c resolution.

c startDoc; startPage.
c erase.
f := Font name: 'Arial'.
f pointSize: 12.
c font: f.
c text: 'Some text here' at: 10@10.
c endPage; endDoc.
=====

Thanks

HweeBoon


Reply | Threaded
Open this post in threaded view
|

Re: Select a font into PrinterCanvas after changing mapping mode to MM_ANISOTROPIC

Bill Schwab-2
> When I try to run the code below in a workspace (it'll probably print
> a page, unless you have some sort of print preview available, such as
> the HP DeskJet 970). The text printed out is a few times bigger than
> what a 12 pt Arial should look like on paper (depending on your/my
> printer to screen resolution). Obviously the problem doesn't occur if
> MM_TEXT is used. Is what I am doing right? I noticed that
> Canvas>>font: actually contains sets the font to use the printer
> canvas resolution (in the line "font resolution: self resolution.").
> This seems to assume that MM_TEXT has to be used?

I doubt that it is necessary (but see below [*]), though I have always found
it preferable to do my own scaling and draw in MM_TEXT.  I keep everything
in inches (thanks to Smalltalk, they can be a mix of integers and floats),
and scale and truncate "just in time".  I never got far enough with mapping
modes to test the theory, but I suspect that you would quickly hit limits on
coordinates when running on 9x.

[*] Dolphin had some long-standing problems with Font methods that accepted
point sizes.  AFAIK, those problems are now resolved (the correct resolution
is used to convert between pixels and points, which was not the case in the
early days).  However, you might have run into a side effect of one of those
fixes.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]