Clipping Text to a Box


Try it.

%!

% operator box: xcoord ycoord box -
% Creates one inch box at xcoord, ycoord
/box {
   newpath
   moveto
   72 0 rlineto
   0 72 rlineto
   -72 0 rlineto
   closepath
} def

/Times-Roman findfont 30 scalefont setfont

gsave                      % Save the old clip path
  72 72 box                % Set up our box
  gsave                    % Don't allow box to be lost after stroke
    stroke
  grestore                 % Restore the box path
  clip                     % Clip to the box

  60 60 moveto
  (This is Times-Roman clipped to a box) show
  70 90 moveto
  (This is Times-Roman clipped to a box) show
  50 120 moveto
  (This is Times-Roman clipped to a box) show

grestore                   % Get the clip path back

showpage


[Main Page ] [ Examples Index ]


pjw 12/21/96