Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.datemas.de!feeder.erje.net!eu.feeder.erje.net!feed.xsnews.nl!border-2.ams.xsnews.nl!feeder.xennanews.com!nf40.xennanews.com!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.postscript Subject: Re: How to make bounding box depending on input text Organization: Decebal Computing References: <87vcdxy187.fsf@Compaq.site> X-Homepage: http://www.decebal.nl/ Date: Sat, 24 Nov 2012 18:21:09 +0100 Message-ID: <87sj7ynchm.fsf@Compaq.site.inet> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:JcuNN3kuL1cEnH/s4eH6i8WIDWk= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@xennanews.com Lines: 67 NNTP-Posting-Host: 84.53.123.169 (84.53.123.169) NNTP-Posting-Date: Sat, 24 Nov 2012 18:29:25 +0100 Xref: csiph.com comp.lang.postscript:1070 Op vrijdag 26 okt 2012 12:30 CEST schreef Cecil Westerhof: > At the moment I use Image Magick to generate pictures for quotes. For > example: > https://www.facebook.com/photo.php?fbid=391593267579727 > > This is fairly easy. But I was thinking about doing it with > postscript. But then I have define the size of the output and this is > depending on the input. Is there a way to solve this? I have been experimenting a little. Below the code I have. A lot has to be changed. For example instead of hard-coded the number of lines should be calculated, the text should come from an input file, an error should be generated when the text is to wide, the font-size should between certain values be dependent on the widest line, the colours and parameters should be selectable, I should use a better font, … But I have something that works and I can build on. The output is posted to: https://www.facebook.com/photo.php?fbid=447483758622570 %!PS-Adobe-3.0 %%Creator: Cecil Westerhof %%Title: Sample Text Effects %%LanguageLevel: 3 /backgroundColour {0 0 1} def /fontsize 16 def /pageWidth 404 def /textColour {1 1 0} def /x fontsize 2 mul def /y 0 def /lineHeight fontsize 5 add def /pageHeight lineHeight 8 1.5 add mul def /Bookman findfont fontsize scalefont setfont << /PageSize [pageWidth pageHeight] >> setpagedevice backgroundColour setrgbcolor 0 0 pageWidth pageHeight rectfill textColour setrgbcolor (Four people are sitting in a lifeboat.) (Two at the front and two at the back.) (In the front there is a leak.) (The two in the front) (are frantically throwing water overboard.) (One in the back says to the other:) ( What a luck) ( that the leak is not at our side.) 8 { /y y fontsize 5 add add def x y moveto show } repeat showpage -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof