disappearing text?

Andrew Myers andru at electron.lcs.mit.edu
Wed May 8 07:46:10 AEST 1991


In article <1991May7.193349.16623 at neon.Stanford.EDU> loan at neon.Stanford.EDU (James P. Loan) writes:
>In article <1171 at gistdev.gist.com> dan at gistdev.gist.com (Dan Schreiber) writes:
>>	I'm having a very strange problem with printing out text strings
>>to a graphics window.  The problem is that part of a text string is 
>>missing, or sometimes the whole string, after drawing the window.  It happens
>>rarely enough to be non-reproducible, but often enough to be concerned about
>>it.
>
>Excuse the me-tooism, but I thought I should mention that I have been
>having *exactly* the same problem, also on a PI (3.3.1). This should

One thing to remember about imaging character strings is that character
strings are subject to "gross clipping". If the transformed location of
the start of the string is outside the current viewport, the entire string
will be clipped! This happens because the character string has point size
as far as the transformation engines are concerned.

To avoid this problem, you can use "fine clipping" via the scrmask() call.
That is, set your viewport to be larger than the current window, and
use scrmask() to do the actual clipping. Here is an example:

    getsize(&sx,&sy);
    viewport(-MARGIN, sx - 1 + MARGIN, -MARGIN, sy - 1 + MARGIN);
    scrmask(0, sx - 1, 0, sy - 1);
    ortho2(-0.5 - MARGIN, sx - 0.5 + MARGIN, -0.5 - MARGIN, sy - 0.5 + MARGIN);


                      __ screenmask, window borders
                     /
       -------------/-------
       |           /       |
 ---   |   -------------   |  __ viewport
  |    |   |           |   | /          
  |    |   |           |   |/          
  sy   |   |           |   |
  |    |   |           |   |
  |    |   |           |<->| MARGIN
 ---   |   -------------   |      
       |      MARGIN       |
       ---------------------
       
	   |---- sx ---|

Where you can adjust MARGIN to allow character strings to start as far
outside the current viewport as you like. A value of 64 is usually
satisfactory.

Note that viewport() always resets the current screenmask, so you have
to call scrmask() afterwards. Note also that viewport() and scrmask()
take pixel indices, whereas ortho2() supplies world coordinates for the
edges of the viewport(). Hence the MARGINs in the ortho2 call. This
allows points to be transformed into the entire viewport area, but only
made visible if they fall within the screenmask.

Andrew



More information about the Comp.sys.sgi mailing list