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


Groups > comp.lang.postscript > #1070

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>
Date 2012-11-24 18:21 +0100
Message-ID <87sj7ynchm.fsf@Compaq.site.inet> (permalink)

Show all headers | View raw


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

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next 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