Fanning Software Consulting

Erroneous Pixel Resolution Leads to Text Size Errors

PROBLEM: The following report is from Jean-Paul Davis. As far as I know, there is no current solution to this problem, but I thought it was important enough to alert the community to the problem. I will update this page as we learn more about the problem and its potential solution.

I have found that IDL obtains window resolution that is grossly in error on certain platforms. For example, the statement

   dimensions = GET_SCREEN_SIZE(RESOLUTION=resolution) 

gives resolution on my screen of 0.025 cm/pixel in both the x and y directions under Windows XP, which is correct. Running IDL under Linux inside a VMWare virtual machine window on this same computer, however, gives resolution of 0.015258216 cm/pixel in x and 0.019455511 cm/pixel in y, which is clearly wrong for my screen. The actual numbers returned depend on the size of the virtual machine window. The numbers returned on Mac are also wrong, possibly related to the problem in this thread.

As a result, when text objects are first drawn, and subsequently redrawn, if they have RECOMPUTE_DIMENSIONS=2, the characters are the wrong size and the wrong aspect ratio.

Pixel resolution properties are read-only, so IDL cannot be “tricked.” The only way I see around the issue is to set RECOMPUTE_DIMENSIONS=0 and “correct” the CHAR_DIMENSIONS of all text objects. This requires updating CHAR_DIMENSIONS every time your data coordinates change.

In my application, I use the text size to adjust the viewplane rectangle so that there is appropriate space for the title and tick labels between the edges of the draw window and the axes. Unfortunately, the text size returned by either the IDLgrWindow::GETTEXTDIMENSIONS method or the XRANGE, YRANGE properties of text objects seems to give the size the text would have if CHAR_DIMENSIONS were set to zero (and hence text were sized according to what IDL thinks the pixel resolution is). Setting CHAR_DIMENSIONS (with RECOMPUTE_DIMENSIONS=0) and redrawing changes the text on the screen, but not the values returned by GETTEXTDIMENSIONS or X/YRANGE.

Has anyone seen IDL behave differently than this, or know of a workaround to get object text to display at the correct size and aspect ratio when IDL obtains the wrong pixel resolution, or at least get the correct dimensions?

If you have any additional information about this problem, please send me e-mail and I will make sure this page is updated.

Web Coyote's Guide to IDL Programming