Path: utzoo!utgpu!news-server.csri.toronto.edu!me!sun Newsgroups: comp.lang.postscript From: sun@me.utoronto.ca (Andy Sun Anu-guest) Subject: Re: Determine string-length in program Message-ID: <91Jan29.212308est.21688@me.utoronto.ca> Organization: U of Toronto, Dept. of Mechanical Engineering References: <1991Jan24.090812.64950@pttrnl.nl> <1991Jan29.045347.2535@actrix.gen.nz> Date: 30 Jan 91 02:23:26 GMT Bruce.Hoult@bbs.actrix.gen.nz writes: >J.P. Buys writes: >>My problem is that I don't know how I can determine the length >>of a string so that I can break the line in multiple strings >>that fit within the borders of the printer label (including >>word-wrap etc.) I think the blue book (cook book) on PostScript has an example of doing a crude line wrapper. What it does is looking for spaces and break the string into one word at a time using "search" (every search will give rise to (word) ( ) (the rest of string)). The length of the word is computed (using stringwidth) and add to current line length. If the line length does not exceed the limit, it will keep going; otherwise, start a newline and reset the linelength couter. The final output is left-justified only (it's easy to make it right-justified too, I don't know of a simple way to do left-right- justification...) and it doesn't do word-wrap. Andy