Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Perl CGl Programming: No experience required.
(Publisher: Sybex, Inc.)
Author(s): Erik Strom
ISBN: 0782121578
Publication Date: 11/01/97

Bookmark It

Search this book:
 
Previous Table of Contents Next


For example, the following PostScript file will display the alphabet in the Palatino-Italic font:

   % Check for command line parameters:
   %   Name, FirstSize, Ratio, NumSizes, UseOutline.

   /FontName where { pop } { /FontName   (Palatino-Italic) def } ifelse
   /FirstSize where { pop } { /FirstSize 15 def } ifelse
   /Ratio where { pop } { /Ratio 1.6 def } ifelse
   /NumSizes where { pop } { /NumSizes 3 def } ifelse
   /UseOutline where { pop } { /UseOutline false def } ifelse

   /Strings FirstSize 20  gt
   { [
       (ABCDEFGHIJ) (KLMNOPQR) (STUVWXYZ)
       (abcdefghijklm) (nopqrstuvwxyz)
       (0123456789<=>) (:;?@  !"#$%&’)
       (\(\)*+,-./[\\]^_) (`{|}~)
   ] }
   { [
       (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
       (abcdefghijklmnopqrstuvwxyz)
       (0123456789<=>:;?@  !"#$%&’)
       (\(\)*+,-./  [\\]^_  `{|}~)
   ] }
   ifelse def

   /sshow
   { gsave UseOutline
       { { gsave ( ) dup 0 4 -1 roll put
       false charpath pathbbox 0 setlinewidth stroke grestore
       pop 8 add currentpoint exch pop moveto pop
         } forall
       }
       { 2 0 3 -1 roll ashow }
      ifelse grestore
    } def

   FontName findfont FirstSize scalefont setfont

   clippath pathbbox /top exch def pop pop pop newpath
   10 10 moveto
   NumSizes
    { gsave nulldevice (Q) false charpath pathbbox grestore
        exch pop exch sub exch pop 1.25 mul /height exch def
      Strings
       { currentpoint exch pop top height 3 mul sub gt
          { showpage 10 10 height sub moveto
          }
         if
         dup sshow
         UseOutline not
          { 0 height rmoveto gsave 0.01 rotate sshow grestore }
         if
         0 height rmoveto
       } forall
      Ratio dup scale
    } repeat
   showpage

Popped into a TIFF-format file, the PostScript code produces the graphical image illustrated in Figure 8.5.


Figure 8.5:  Text PostScript code produces this image.

The PostScript code probably looks a little intimidating, but don’t worry. The intention here is not to teach you PostScript, but to give you an idea of what it looks like and some of the things you might do with it.


TIP:  If you would like to learn more about the PostScript programming language, you’ll find a pretty good introduction at www.cs.indiana.edu/docproject/programming/postscript/postscript.html. In addition, there are plenty of good books on the subject.

Making a Graphical Access Counter

You can use Perl and Ghostscript to spruce up the Web site access counter you built in Skill 4. Instead of the number of “hits” on your site being displayed as part of an HTML heading, you can make it graphical.

The first thing you need, of course, is Ghostscript.

As of this writing, one of the best sources is the University of Wisconsin’s computer science department Web site. You’ll find all of the Ghostscript files beginning at http://www.cs.wisc.edu/~ghost/gsfaq.html. From there, you only need to pick and download the files that are appropriate for your operating system.

You UNIX Webmasters get to do the macho UNIX thing and download the Ghostscript C-language source files and compile them. Windows NT and 95 Webmasters have the same option, but you may also download the compiled executable files and simply install them.


TIP:  The Ghostscript executables, and voluminous other files, for Windows NT and 95 at http://www.cs.wisc.edu/~ghost/gsfaq.html are in gs503ini.zip and gs503w32.zip. (Ghostscript 5.03 is the latest version of the interpreter, as of this writing.) You’ll also need the full set of PostScript Type 1 fonts, which are in gs503fn1.zip. You may also download a PostScript viewer called GSView in gs503w32.zip. The viewer probably isn’t necessary unless you do a lot of work in PostScript, but it’s interesting.

Probably the only reason for you to get the C-language source code for Ghostscript on Windows NT and 95 is to include the capability for handling GIF-format graphics files. This is an interesting problem: The Ghostscript you will download from the University of Wisconsin’s computer science department was developed by Aladdin Enterprises. They don’t want any money from you; their license agreement simply states that you will not distribute their software for profit. So much for Aladdin Enterprises—and bless them.

The GIF graphical format, which is supported by virtually all Web browsers, is a subject of some controversy, however. CompuServe, the online service, and Unisys, a huge computer company, believe that they own the GIF format, based on some patents that were taken out in the mid-1980s and whose validity has not been completely established. Still, the two companies have enough of a claim on the GIF format to be able to demand payment from developers whose software is written after January 1, 1995 and does files in the GIF format. The folks at Aladdin, wisely erring on the side of avoiding all contact with lawyers, removed the GIF capability from Ghostscript.

But their earlier software is still available at the University of Wisconsin Web site and, if you are not afraid of lawsuits, you may want to download the old C source files and compile them.

Why No GIF in Ghostscript?

In the “Frequently Asked Questions” section of the Ghostscript Web pages at the University of Wisconsin, there is a section titled “Why Isn’t GIF Supported in Ghostscript?”

The answer, from Aladdin Enterprises’ L. Peter Deutsch, is instructive:

“Because of actions by CompuServe and Unisys related to a patent that claims to cover the data compression method used in GIF, anyone who distributes any new GIF software (even readers, but definitely software that creates GIF files) after January 1, 1995 may be subject to legal action if they do not get a license from Unisys, and/or unpredictable payment requirements if they do get such a license. I cannot run the risk of having this happen. If you wish to run this risk, you may extract the GIF software (gdevgif.c and a small part of devs.mak) from Aladdin Ghostscript 3.12, which was originally released in 1994.”


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.