Path: utzoo!attcan!uunet!ogicse!decwrl!adobe!heaven!glenn From: glenn@heaven.woodside.ca.us (Glenn Reid) Newsgroups: comp.lang.postscript Subject: Re: limitcheck in flattenpath Message-ID: <320@heaven.woodside.ca.us> Date: 13 Nov 90 00:01:37 GMT References: <1642@umriscc.isc.umr.edu> Reply-To: glenn@heaven.woodside.ca.us (Glenn Reid) Organization: RightBrain Software, Woodside, CA Lines: 39 In article <1642@umriscc.isc.umr.edu> jmd@ee.umr.edu (Jim Dumser) writes: >I've been trying to hand code some figures in postscript, but I keep getting >limitcheck errors in flattenpath when trying to center text. It doesn't >happen for all strings; only for longer strings. Basically, my routine to >center text calls 'hiwi': > >/hiwi {gsave newpath 0 0 moveto true charpath flattenpath pathbbox 4 2 roll >pop pop grestore} def Your code is fine; you're just hitting an implementation limit (the number of path elements allowed in the current path). The only workaround is to have fewer elements in the path. There are a couple of ways to do this. One is to use "forall" to do "flattenpath pathbbox" on each element of the string and then to accumulate the bounding box for the whole string. A bit of work, fairly messy, but it should work for arbitrarily long strings. There are two other possibilities, assuming you're just centering text and can tolerate slight errors in the bounding boxes (there are probably slight errors anyway). One is to omit the "flattenpath" altogether. This will mean that some of the control points on the bezier curves get included in the bounding box, but it should still center things quite reasonably. The other possibility is to increase the flatness parameter before you call flattenpath, like this: /hiwi { %def gsave newpath 0 0 moveto false charpath % you should use "false" 5 setflat flattenpath pathbbox % note "5 setflat" 4 2 roll pop pop % otherwise the same grestore } bind def % Glenn -- Glenn Reid RightBrain Software glenn@heaven.woodside.ca.us PostScript/NeXT developers ..{adobe,next}!heaven!glenn 415-851-1785