gsave … grestore

By macenable

One way to keep that string from affecting the path of the line is to save the graphics state with a gsave command before showing the string, and then restore it with grestore before continuing the line:

%!PS
0 0 moveto 306 396 lineto
% CURRENT POINT IS 306 396
gsave
/Helvetica 10 selectfont
(the effect of showing this string is isolated) show
% CURRENT POINT IS AT END OF STRING (306+ 396) 
grestore
% CURRENT POINT IS AGAIN 306 396
612 792 lineto
stroke
showpage % END OF PROGRAM

gsavegrestore

Get it? The current point (within the graphics state) at the end of the first line is saved to be used by the start of the second line.

Leave a Reply