I developed a function to make a simple checkbox in postscript, but still it seems to not work. There is no problem to generate the rectangle, but it seems to throw an exception during the writing of the lines (making the classical X of the checkbox).
/nocurrentpoint in --nocurrentpoint--
Here's my code.
/doMarkedCheckBox {
0.1 setlinewidth
currentpoint
/yIniChk exch def
/xIniChk exch def
xIniChk
yIniChk
DimChars
DimChars
rectstroke
xIniChk DimChars add yIniChk DimChars add lineto
0 DimChars 0 sub moveto
yIniChk DimChars add xIniChk lineto
stroke
} bind def
Can someone explain how to do it correctly? Thanks in advance.
That is exactly the problem - after the rectstroke
call you close the path and is left with no starting point.
You can just move there again, putting the values on the stack and issuing moveto
- there seems to be at least an error on the code to generate the other part of the check as well - and, since you have the squaresize in DimChars
already, it may be easier to use rlineto
in these issues.
All in all, if you replace your instructions after rectstroke
by this sequence you should be good:
...
xInitChk YInitChk moveto
DimChars DimChars rlineto
stroke
XInitChk YInitChk DimChars add moveto
DimChars DimChars neg rlineto
stroke
} bind def