Path: csiph.com!usenet.pasdenom.info!aioe.org!rt.uk.eu.org!feed.xsnews.nl!border-1.ams.xsnews.nl!feeder.xennanews.com!nf41.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> <87sj7ynchm.fsf@Compaq.site.inet> X-Homepage: http://www.decebal.nl/ Date: Sun, 25 Nov 2012 22:29:17 +0100 Message-ID: <87vcctl6c2.fsf@Compaq.site.inet> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:62mg9QWRzT6sMtGBI3bc7MdzkNQ= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@xennanews.com Lines: 119 NNTP-Posting-Host: 84.53.123.169 (84.53.123.169) NNTP-Posting-Date: Sun, 25 Nov 2012 22:44:25 +0100 Xref: csiph.com comp.lang.postscript:1083 Op zondag 25 nov 2012 11:16 CET schreef luser droog: > Palatino is the greatest font there is, IMHO. Looks like it is not installed on my system. :-( > I hope you don't mind a few comments... Of-course not. In principal I like them. :-D >> %!PS-Adobe-3.0 > > The '3.0' part means you're asserting that the file conforms to the Document > Structuring Conventions. But you still need %%Pages and %%Page and perhaps > a few others. You can use '%!PS' or simply '%!' to identify the file as > Postscript without making any claims to DSC conformance. If you plan to run > the file through ps2eps, it'll add all the necessary comments for > you. Just copied from other files. I will delve into it. >> %%Creator: Cecil Westerhof > Creator is the software that generated the DSC comments. You are > the %%Author. OK. >> /pageWidth 404 def > > You can get the page width for the current device with > clippath pathbbox ... I am making it for FaceBook, so I have to set it to 404 pixels. >> /lineHeight fontsize 5 add def > > This is commonly called 'lead' for the strips of lead (Pb) used to add space > for letterpress typography. I am a programmer, not a graphical person, but willing to learn. ;-) I'll take this into account also. >> << /PageSize [pageWidth pageHeight] >> setpagedevice > > Oh. Nevermind about the 'clippath' stuff above. :) It is still good to know when I do need it. :-D >> 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 > > Wrap your text lines in an array [(line1)(line2)(line3)]. Then you can get > the count with 'length' and iterate through it with 'forall'. Also, > you're I already am working with count (after putting the strings on the stack). My next step was to go to work with an array. First of all I then could go through it twice. First to check the width of the strings and then the printing. Secondly I want to work with input from a file. But let first learn to walk before I start running. By the way, string width is linear to the font size? So when the longest string is to long (or short) I can change the font size without checking again. > increasing the y value, when it would appear to make more sense to decrease > it (moving /down/ the page). One shortcut that avoids redefining y, > is That is because I was popping things of the stack. I already changed that by putting them reversed on the stack. At the moment I am working with an array the problem is gone. > { > gsave show grestore > 0 lineHeight neg rmoveto > } > > The grestore resets the currentpoint back to where it was when the > corresponding gsave was called. Then you don't have to touch the x > coordinate at all to move down a line. Nice touch. I'll incorporate it. > HTH. Good stuff, keep it coming! It does. Thanks for the help and also for the compliment. Both do not hurt. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof