🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #3637

Re: limitcheck in flattenpath

#3637
From: Rich Berlin
Date: Mon, 12 Nov 1990 21:39
38 lines
1750 bytes
I've experienced the same problem.  Basically, there's a limit to the
number of segments that the path can contain, and charpath eats LOTS of
them.  See the footnote on charpath, Red Book page 89.  It says, in
part, "if possible, it is best to deal with only one character's path
at a time."

Based on this, I suggest the following workaround.  (But first I
should ask something: the code you've written calculates the bounding
box of the string.  Are you really centering in both dimensions?  If
not, I think the stringwidth operator should give you what you want,
much more cheaply.)

/max where {
    pop
}{
    /max {2 copy lt {exch pop} {pop} ifelse} bind def
} ifelse

/hiwi {
    0 0 3 -1 roll
    { % forall--loop over all characters in string.
	gsave
	    % Put the char into a string
	    1 string dup 0 4 -1 roll put

	    % Get the height and width of the single char
	    newpath 0 0 moveto
	    true charpath flattenpath pathbbox 4 2 roll pop pop

            % Now cumulate the result.  The following line
            % assumes a horizontal writing direction.  If the writing
            % direction is vertical, interchange `add' and `max'.
            exch 4 -1 roll add 3 1 roll max
	grestore
    } forall
} bind def

-- Rich
Technical Details
Message-ID: <RBERLIN.90Nov12133942@birdland.sun.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!sun-barr!newstop!exodus!rberlin
References: <1642@umriscc.isc.umr.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!sun-barr!newstop!exodus!rberlin
From: rberlin@birdland.sun.com (Rich Berlin)
Newsgroups: comp.lang.postscript
Subject: Re: limitcheck in flattenpath
Message-ID: <RBERLIN.90Nov12133942@birdland.sun.com>
Date: 12 Nov 90 21:39:42 GMT
References: <1642@umriscc.isc.umr.edu>
Sender: news@exodus.Eng.Sun.COM
Organization: Sun Microsystems
Lines: 38
In-reply-to: jmd@franklin.ee.umr.edu's message of 12 Nov 90 18:32:54 GMT