Map Labels Not Clipped to Map Boundary

QUESTION: I'm setting up a map projection and I am labeling the latitude and longitude grid lines with Map_Grid. All works well on my display, but when I send the commands to the PostScript device, some of the map labels are located outside my map boundary. It is as though they are not being clipped to the boundary. Do you know what is going on with this? Here is the kind of output I am getting.

Grid labels are not clipping to the map projection.
Grid labels are not clipping to the map projection, when displayed in PostScript.

ANSWER: Yes, as of IDL 8.1 there is still a bug in IDL that only allows clipping of map labels if the font you are using to label the map projection is a Hershey font (!P.Font = -1). When you go into your PostScript device, you are certainly switching to either a hardcopy device font (!P.Font = 0) or a true-type font (!P.Font = 1). This has the effect of turning clipping off, no matter what value you are using for the CLIP_TEXT keyword to Map_Grid.

Here is a short program that illustrates the problem.

   map =  Map_Proj_Init( 106, DATUM = 8, $
                         CENTER_LATITUDE = 71, $
                         CENTER_LONGITUDE = 125, $
                         LIMIT = [ 50, 0, 90, 360 ] )
   uv_box = [ -3420000.0d, -4218785.8d, 3420000.0d, 941214.23d ]
   position =  [ .1,  .1,  .8, .9 ]
   cgPlot, uv_box[ [ 0, 2 ] ], uv_box[ [ 1, 3 ] ], $
   cgPlotS, uv_box[ [ 0, 0, 2, 2, 0 ] ], uv_box[ [ 1, 3, 3, 1, 1 ] ] 

I have run this program with !P.Font set to -1, 0, and 1 (Hershey font, default hardware font, and true-type Helvetica font, respectively). The results are shown in the figure below.

Clipped with !P.Font=-1. Not clipped with !P.Font=0. Not clipped with !P.Font=1.
The labels are clipped correctly with !P.Font=-1 (Hershey fonts), but not otherwise.

This and other problems with Map_Grid have been corrected in the program cgMap_Grid, which is one of about a dozen or so map projection routines available for the Coyote Graphics Library.

Version of IDL used to prepare this article: IDL 8.1.

Web Coyote's Guide to IDL Programming