Post Scriptum language

Post Scriptum website

Post Scriptum is a programming language for preparing PostScript documents and programs. The language is procedural, uses classical control structures (functions, loops, conditional statements) and commonly known data types (numbers, arrays, strings, dictionaries). Its syntax is simple, clear and easy to learn. All PostScript language built-in operators are directly accessible with classic function call syntax.

The Post Scriptum compiler translates programs written in Post Scriptum language directly to PostScript file, which can be than executed by PostScript interpreter (such as Ghostscript), printed, or used as procset, driver or library. Verbatim PostScript code can be placed in Post Scriptum program. Potentially all kinds of PostScript application or document can be prepared with Post Scriptum.

Hello World and other examples

Here is the Hello World program in Post Scriptum:

// The Hello World program
setfont( scalefont( findfont( 'Helvetica' ), 72 )); 
moveto( 72, 72 );
show( "Hello, world!" );
showpage();

And here is its equivalent in PostScript:

%!PS-PostScript
/Helvetica findfont 72 scalefont setfont
72 72 moveto
(Hello, world!) show
showpage

The tutorial section contains more complicated examples, based on sample code from PostScript language tutorial and cookbook (Blue Book from Adobe). Look below for sample - this is a definition of character building function in font dictionary.

/BuildChar
  { 0 begin
      /char exch def
      /fontdict exch def
      /charname fontdict /Encoding get char get def
      fontdict begin
        Metrics charname get 0
        BBox charname get aload pop
          
          setcachedevice
          
        CharacterDefs charname get exec
      end
    end
  } def

And here is the same function coded in Post Scriptum, much more clear and understandable.

procedure BuildChar_fun( fontdict, char ) 
{
     charname = fontdict.Encoding[ char ];
     bbox = fontdict.BBox[ charname ];
     setcachedevice( fontdict.Metrics[charname], 
		     0, bbox[0], bbox[1], 
		     bbox[2], bbox[3] );

     fontdict.CharacterDefs[ charname ]();
}

Distribution

The program is distributed in source form, under the terms of GNU license. It was developed on Linux, but should be relatively easy to port to any operating system. The distribution contains also the reference manual and example programs.

Anyone interested in trying the Post Scriptum is invited to download and try the program. The author will be thankful for any suggestion and criticism.