[racket-dev] Plot testing and feedback

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Aug 13 08:58:10 EDT 2011

At Fri, 12 Aug 2011 21:56:57 -0500, Robby Findler wrote:
> On Fri, Aug 12, 2011 at 9:41 PM, Neil Toronto <neil.toronto at gmail.com> wrote:
> > Can I get a racket/gui expert's help on Jay's machine's output? There are
> > two issues:
> >
> > 1. I have it render text with an 8 point font. On Jay's Mac, it's too small
> > to be 8 point. Either there's some font scaling or it's erroneously choosing
> > an 8 *pixel* font. How can we tell?
> I have trouble with font sizes across platforms, too. I think it is
> easiest to just special case the default font size (but do the below
> first).

The Mac's drawing layer equates drawing units and font point sizes,
while the drawing layers for Windows and Unix try to adapt the to the
screen resolution for the conversion of point-sizes to drawing-unit.

For drawing pictures, it usually works better for me to use an
N-"pixel" font instead of an N-point font (where "pixel" really means
"drawing unit").

> > 2. The Mac's get-char-width is returning something apparently too big -
> > especially for the tiny font size - which makes all of Jay's plots scrunch
> > up to make room for the Y axis labels. Is this a bug?
> I think that level of the system is pretty widely used. You might see
> if you can sit in front of his machine and play around to see if you
> can make a small example and maybe that'll clarify things.

I've never found `get-char-width' to be particularly useful, because
the average character width sometimes includes Unicode characters and
sometimes doesn't.

It looks like your code is using 8 points and `get-char-width' in an
attempt to pick a good drawing scale for the target device. I think you
flip those around: pick a width and height in drawing units that looks
about right on your screen, and pick a font in drawing-unit "pixels"
instead of points. A good screen scale is a good default bitmap scale,
the 80% default scaling for PS/PDF output will then make the output in
PS/PDF have a reasonable default size.

Posted on the dev mailing list.