Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1083

Re: How to make bounding box depending on input text

From Cecil Westerhof <Cecil@decebal.nl>
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> <k8sr93$qu5$1@dont-email.me>
Date 2012-11-25 22:29 +0100
Message-ID <87vcctl6c2.fsf@Compaq.site.inet> (permalink)

Show all headers | View raw


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

Back to comp.lang.postscript | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

How to make bounding box depending on input text Cecil Westerhof <Cecil@decebal.nl> - 2012-10-26 12:30 +0200
  Re: How to make bounding box depending on input text bugbear <bugbear@trim_papermule.co.uk_trim> - 2012-10-26 17:00 +0100
    Re: How to make bounding box depending on input text John Deubert <john@acumentraining.com> - 2012-10-31 10:05 -0700
  Re: How to make bounding box depending on input text Don Lancaster <don@tinaja.com> - 2012-11-02 14:25 -0700
  Re: How to make bounding box depending on input text luser- -droog <mijoryx@yahoo.com> - 2012-11-03 02:50 -0700
  Re: How to make bounding box depending on input text Cecil Westerhof <Cecil@decebal.nl> - 2012-11-24 18:21 +0100
    Re: How to make bounding box depending on input text "luser.droog" <luser.droog@gmail.com> - 2012-11-25 04:16 -0600
      Re: How to make bounding box depending on input text Cecil Westerhof <Cecil@decebal.nl> - 2012-11-25 22:29 +0100

csiph-web