From: jgm@cs.brown.edu (Jonathan Monsarrat)
Subject: Re: Wanted s/w Simple Postscript Typesetting for Slides ...??
Organization: Brown University Department of Computer Science
Date: Mon, 16 Nov 1992 00:05:15 GMT


If you really want to make slides the quick and easy way, use a
drawing program.

However, if you are mildly comfortable (or more) with PostScript,
the below files may be of interest to you.

Below are some PostScript utilities for making:
   - forms
   - slides
   - posters

"Rect.ps" is a PostScript library of routines. All the other files
are examples of how to use Rect.ps. To view/print the examples,
you must prepend Rect.ps to them first. They are written entirely
in PostScript, so they should work on any PostScript device.

-Jon

P.S. RectFillBox doesn't work. If you add new functions, please share them!

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  Rect.ps housemate.ps form.ps sideways.ps arrow.ps
# Wrapped by jgm@vegas on Sun Nov 15 18:58:46 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Rect.ps' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Rect.ps'\"
else
echo shar: Extracting \"'Rect.ps'\" \(10542 characters\)
sed "s/^X//" >'Rect.ps' <<'END_OF_FILE'
X%!  Rect.ps   A lot of routines to make simple text printing in rectangles
X%% Send questions to Jonathan Monsarrat, jgm@cs.brown.edu
X%% Documentation? You must be kidding! Look at the example files.
X%% If you nag me, I might write some later.
X/inch {72 mul} bind def
X/uninch {72 div} bind def
X/inmoveto {inch exch inch exch moveto} bind def
X/intranslate {inch exch inch exch translate} bind def
X
X% TextDivide sets the current font to the given type, basing the font size
X% on the number of vertical lines of text wanted.
X% USAGE:    fontname lines TextDivide -
X/TextDivide
X{
X  rectHeight exch div /rectfontHeight exch def     % Calculate the font size
X  findfont rectfontHeight scalefont setfont        % Set the font
X} bind def
X
X% TextSet sets the current font to the given absolute type
X% USAGE:    fontname size TextDivide -
X/TextSet
X{
X  /rectfontHeight exch def                         % Store the font size
X  findfont rectfontHeight scalefont setfont        % Set the font
X} bind def
X
X% Moves the current Y position for text to the top of the Rect
X/TextPageTop
X{
X  /textYPos rectHeight def                 % Initialize current Y pos
X  0 textYPos moveto
X} bind def
X
X% Drops the current Y position variable down one line
X% USAGE:  TextDrop  -
X/TextDrop {
X     /textYPos textYPos rectfontHeight sub def
X     0 textYPos moveto
X} bind def
X
X% TextCenter takes string, prints string centered at current Y pos.
X% USAGE:    (text)  TextCenter  -
X/TextCenter {
X    MoveCenter show
X} bind def
X
X% MoveCenter takes string, and centers current mark where string
X% would be printed if it were to be centered. Leaves string on stack.
X% USAGE:  (text) MoveCenter (text)
X/MoveCenter {
X     TextDrop
X     dup stringwidth pop rectWidth exch sub 2 div
X     textYPos moveto
X} bind def
X
X% TextShadeShow prints some text as shaded at the current position
X% USAGE: endgray startgray (text) TextShadeShow
X% NEEDS TO BE OPTOMIZED
X/TextShadeShow
X{
X /shadestring exch def
X /startgray exch def
X /endgray exch def
X
X TextDrop
X 0 1 shadestring length 1 sub
X {
X    currentpoint /y exch def /x exch def
X    shadestring exch 1 getinterval /foo exch def
X    gsave
X         foo true charpath clip
X	 -0.3 rectfontHeight mul 1.44 rectfontHeight
X         {
X               dup x exch y add moveto
X               0 1.44 rlineto
X               foo stringwidth pop 0 rlineto
X               0 -1.44 rlineto
X               closepath
X               .3 rectfontHeight mul add 1.3 rectfontHeight mul div
X               endgray startgray sub mul startgray add setgray fill %original
X         } for
X    grestore
X    gsave
X      rectfontHeight 72 gt { 2 } { 1 } ifelse setlinewidth
X      foo true charpath 0 setgray stroke% showpage
X    grestore
X    foo stringwidth pop 0 rmoveto
X } for
X} bind def
X
X% TextOShow prints some text as an outline.
X% Will not work in a simulator like GhostScript for Adobe locked fonts
X% USAGE:  string TextOShow  -
X/TextOShow
X{
X  true charpath stroke
X} bind def
X
X% TextFillOShow prints some text with an outline in the given grayscale.
X% Will not work in a simulator like GhostScript for Adobe locked fonts
X% USAGE:  string grayscale TextOShow  -
X/TextFillOShow
X{
X     TextDrop      % The "current Y position" should really be one line lower.
X     /background exch def        % Set the current gray level
X     /ch ( ) def
X     0 textYPos moveto
X     {
X           ch exch 0 exch put    % Convert ASCII number to a one char string
X           gsave
X                background setgray ch show currentpoint
X           grestore ch TextOShow moveto
X     } forall
X} bind def
X
X% Prints some text, leaving the currentpoint after the word
X/TextShow
X{
X  show
X} bind def
X
X% Puts a Box on the text line, the same size as the current font
X/TextBox
X{
X     gsave
X     rectfontHeight  0 rlineto
X     0 rectfontHeight rlineto
X     -1 rectfontHeight mul 0 rlineto
X     0 -1 rectfontHeight mul rlineto
X     closepath stroke
X     grestore rectfontHeight 0 rmoveto ( ) show
X} bind def
X
X%%%%%%%%%%   string  TextMetalShow  -   %%%%%%%%%%%%%%
X%%% Prints a metal-looking string at the current position just like "show"
X%% It expects the string to be printed to be on the stack as well as
X%% the height of the font currently being used. WARNING! In practice
X%% the actual height of the letters is not the official size of the
X%% font. For example, in my demo below I use 100pt type but have a height
X%% of only 60pt.
X/TextMetalShow
X{
X  6 dict begin
X    /height rectfontHeight .7 mul def
X    dup length 1 sub 0 1 3 -1 roll
X    {
X      1 index exch 1 getinterval
X      dup stringwidth pop /width exch def
X      Pattern
X      stringwidth pop 0 rmoveto
X    } for
X    pop
X  end
X} bind def
X
X%%%%%%%%%%%%%%%%%%%%%  char Pattern - %%%%%%%%%%%%%%%%%%%%%%%%%%%%
X%%% Displays a single character as metal
X%%% It's important to break the string up into individual letters because
X%%% often when I do a "charpath" on a whole word, there isn't enough
X%%% memory or something and the program dies. One letter at a time is safe.
X/Pattern
X{
X  gsave
X       currentpoint translate
X       dup true charpath clip
X  /delta 0.02 inch def  % How fine should the grayscales be?
X  /bot 0 def /top height 0.4375 mul def
X  bot delta top
X  {
X    dup bot sub top bot sub div 55 mul 55 exch sub sin setgray
X    newpath 0 exch moveto
X    width 0 rlineto
X    0 delta rlineto
X    width neg 0 rlineto
X    closepath fill
X  } for
X
X  /bot top def /top height 0.5625 mul def
X  bot delta top
X  {
X    dup bot sub top bot sub div setgray
X    0 exch moveto
X    width 0 rlineto
X    0 delta rlineto
X    width neg 0 rlineto
X    closepath fill
X  } for
X 
X  /bot top def /top height def
X  bot delta top
X  {
X    dup bot sub top bot sub div 78 mul cos setgray
X    0 exch moveto
X    width 0 rlineto
X    0 delta rlineto
X    width neg 0 rlineto
X    closepath fill
X  } for
X    0 0 moveto
X    dup
X    true charpath
X       gsave
X            1 setgray
X            3 setlinewidth
X            stroke
X       grestore
X       stroke
X  grestore
X} bind def
X
X% Print a string, and then leave a line for writing, just like on a form.
X% The line should go to the given fraction of the width of the Rect.
X% USAGE:   fraction string FormShowTo   -
X/FormShowTo
X{
X     show ( ) show FormTabLine
X} bind def
X
X% Print a line to the specified fraction of the width of the Rect, and
X% put the current position there for further text printing.
X% USAGE:  fraction FormTabLine   -
X/FormTabLine
X{
X     rectWidth mul dup          % Get the absolute X position to line to
X     (   ) stringwidth pop sub  % subtract 3 spaces for a margin
X     textYPos lineto stroke
X     textYPos moveto            % Move to the actual tab position
X} bind def
X
X% Put the current X position on the current line, at the given fraction of
X% the Rect width for more text printing.
X% USAGE:  fraction FormTabLine   -
X/FormTab
X{
X     rectWidth mul dup          % Get the absolute X position to line to
X     textYPos moveto            % Move to the tab position
X} bind def
X
X% Print a string, and then leave a line for writing, just like on a form.
X% The line should go to the right margin and a new line should be started.
X/FormShow
X{
X     1 exch FormShowTo TextDrop
X} bind def
X
X% Box takes a size argument in inches and makes a box with the current point
X% as the lower left hand corner. Destroys the current point.
X/RectBox
X{
X     0         0          moveto
X     rectWidth 0          lineto
X     rectWidth rectHeight lineto
X     0         rectHeight lineto
X     closepath
X} bind def
X
X% RectScale scales up the rectangle, at the same time increasing the
X% important rectHeight, rectWidth, and rect. It puts the currentpoint
X% in the lower left corner.
X/RectScale
X{
X  currentdict /rectfontHeight known {
X     dup /rectfontHeight exch rectfontHeight mul def
X  } if
X  2 copy
X  /rectHeight exch rectHeight mul def
X  /rectWidth exch rectWidth mul def
X  0 0 moveto
X  scale
X} bind def
X
X% RectDo sets up a rectangular box environment, and executes a block
X% of commands in it. The graphics state is saved and restored afterwards.
X% USAGE:    { commands } Width Height X Y RectDo  -
X%     (X,Y) is the coordinate of the lower left hand corner, in inches.
X%     Width and Height are those of the Rectangle, in inches.
X/RectDo
X{
X     currentdict /rectStack known not {
X          /rectStack [] def
X     } if
X     gsave
X          intranslate
X          /rectHeight exch inch def
X          /rectWidth exch inch def
X          /rectStack [ rectStack {} forall
X                  rectHeight rectWidth ] def
X        % RectBox     % uncomment this line to see where your rects are
X	  exec
X     grestore
X     /rectStack [ rectStack {} forall
X                  rectWidth exch def rectHeight exch def ] def
X} bind def
X
X% Takes width and height parameters, and makes a right-pointing arrow
X% centered on the current point.
X% USAGE:   width height Arrow
X/RectArrow
X{
X     /recth exch def /rectw exch def
X     /Squee 0.6 def    % Length of tail. From 0.0 to 1.1
X     /Squaw 0.3 def    % Width of tip. From 0.0 to 0.5
X      rectw -0.5 mul recth 0.5 Squaw sub mul rmoveto
X      rectw Squee mul        0 rlineto
X          0 recth Squaw mul rlineto
X                rectw 1 Squee sub mul        recth -0.5 mul rlineto
X                rectw 1 Squee sub mul -1 mul recth -0.5 mul rlineto
X          0 recth Squaw mul rlineto
X      rectw Squee mul -1 mul 0 rlineto
X      closepath fill
X} bind def
X
X% Makes a left arrow in this Rect
X/RectLeftArrow
X{
X     rectWidth 2 div rectHeight 2 div moveto
X     -1 rectWidth mul rectHeight RectArrow
X} bind def
X
X% Makes a right arrow in this Rect
X/RectRightArrow
X{
X     rectWidth 2 div rectHeight 2 div moveto
X     rectWidth rectHeight RectArrow
X} bind def
X
X% Makes an up arrow in this Rect
X/RectUpArrow
X{
X     rectWidth 2 div rectHeight 2 div moveto
X     90 rotate
X     rectHeight rectWidth RectArrow
X} bind def
X
X% Makes a down arrow in this Rect
X/RectDownArrow
X{
X     rectWidth 2 div rectHeight 2 div moveto
X     -90 rotate
X     rectHeight rectWidth RectArrow
X} bind def
X
X% Fills the rectangle with Rects, executing the given command for each one.
X%  {routine} width height RectFill
X/RectFill
X{
X     0 1 index rectHeight uninch {    % routine x y yval
X        0 3 index rectWidth uninch (ergo\n) print pstack
X          {  % routine x y yval xval
X          5 copy exch    % routine x y yval xval routine x y xval yval
X          (start\n) print pstack (end\n) print
X          RectDo pop     % routine x y yval
X	} for
X        pop
X     } for
X  pop pop pop
X} bind def
X
X% Fills the rectangle box.
X% of the given size
X%   size  RectFillBox  -
X/RectFillBox
X{
X    0 setgray RectBox stroke
X} bind def
X
END_OF_FILE
if test 10542 -ne `wc -c <'Rect.ps'`; then
    echo shar: \"'Rect.ps'\" unpacked with wrong size!
fi
# end of 'Rect.ps'
fi
if test -f 'housemate.ps' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'housemate.ps'\"
else
echo shar: Extracting \"'housemate.ps'\" \(2626 characters\)
sed "s/^X//" >'housemate.ps' <<'END_OF_FILE'
X%! PostScript Hack to be appended to Rect.ps
X
X%{
X%  { RectFillBox } .1 .1 RectFill
X%} 8.5 11 0 0 RectDo
X
X/TM 10.5 inch def
X/BM .5 inch def
X/LM .5 inch def
X/RM 8 inch def
X
X/box
X{0 0 moveto 0 10 lineto 10 10 lineto 10 0 lineto closepath fill} def
X%% Shade takes 6arguments, string, x position, y position, fontsize
X%% starting gray, and ending gray.  It makes a gradual shading (from
X%% starting gray to ending gray) inside the letters defined by string,
X%% and then draws in the outlines of the letters.
X/inch {72 mul} def
X
Xgsave
X
X0 10 830
X  { /mm exch def gsave
X    415 mm sub abs 415 div /num exch def
X    mm 20 mod 0 ne { -1 num mul /num exch def} if
X    .5 num 2 div sub /gray1 exch def
X    .5 num 2 div add /gray2 exch def
X    0 20 620
X      { pop gray1 setgray box 10 0 translate
X            gray2 setgray box 10 0 translate
X      } for
X    grestore 0 10 translate
X  } for
X
Xgrestore
X
X1 setgray
XLM TM moveto RM TM lineto RM BM lineto LM BM lineto closepath fill
X0 setgray
XLM TM moveto RM TM lineto RM BM lineto LM BM lineto closepath stroke
X
X/newline
X{currentpoint 13 sub exch pop LM exch moveto} def
X
X/check
X{currentpoint pop RM gt {newline} if} def
X
X/finis?
X{currentpoint exch pop BM lt} def
X
X/fillpage
X{/strg exch def
X  { {pop pop check} strg kshow
X    finis? {exit} if
X  } loop
X} def
X
X/NewCenturySchlbk-Roman findfont 10 scalefont setfont
X
X/TM 10.3 inch def
X/BM .7 inch def
X/LM .5 inch def
X/RM 7.9 inch def
X
XLM TM moveto
X.8 setgray
X(Apartment hunting?  ) fillpage
X
X0 setgray
X
X90 rotate 0 -8.5 inch translate        % Makes a 11x8.5 page out of 8.5x11
X
X{
X     /Times-Italic 70 TextSet TextPageTop
X     (Nice $166 Apartment) TextCenter
X} 10 1 .5 6.7 RectDo
X
X{
X     /Times-Bold 20 TextDivide TextPageTop
X     /Times-Italic 25 TextSet TextPageTop
X     (Looking for a housemate!) TextCenter
X     (There's an opening at 119 Pitman street for a new housemate.) TextCenter
X     (Come check it out! It is a 2 minute walk to the supermarket,) TextCenter
X     (10 min to Brown. Includes electricity,) TextCenter
X     ( does not include gas & heat.) TextCenter
X
X     (The apartment is NOT shabby. We have a clean kitchen) TextCenter
X     (and bathroom. There are seven rooms: four bedrooms,) TextCenter
X     (a kitchen, a bathroom, and a living room.) TextCenter
X
X     (No smokers, please. Pets are allowed.) TextCenter
X     (There is free private parking, and we have our own laundry.) TextCenter
X     (Either male or female OK.) TextCenter
X
X     TextDrop
X     (Please send email to Mike at ST101366@BROWNVM.brown.edu) MoveCenter TextOShow
X     (or phone Mike at 621-7367) MoveCenter TextOShow
X
X} 10 5.5 0.5 0.5 RectDo
X
Xshowpage
END_OF_FILE
if test 2626 -ne `wc -c <'housemate.ps'`; then
    echo shar: \"'housemate.ps'\" unpacked with wrong size!
fi
# end of 'housemate.ps'
fi
if test -f 'form.ps' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'form.ps'\"
else
echo shar: Extracting \"'form.ps'\" \(3348 characters\)
sed "s/^X//" >'form.ps' <<'END_OF_FILE'
X%!  form.ps   An example form using the Rect.ps library
X%%   You must prepend the file Rect.ps for this example
X
X% Puts the logo of this organization in the current Rectangle
X/Logo
X{
X     1 setlinewidth 0 setgray
X     RectBox stroke
X     /Times-Roman 5 TextDivide TextPageTop
X          TextDrop
X          (your) TextCenter
X          (logo) TextCenter
X          (here) TextCenter
X} bind def
X
X% Prints the title of this form
X/Title
X{
X     .3 1 scale
X     /Times-Roman 1 TextDivide TextPageTop
X     (Press Shop Receipt) .6 TextFillOShow
X} bind def
X
X% Prints the address of this organization
X/Address
X{
X     /Times-Bold 14 TextSet TextPageTop
X     (Alpha Chi Chapter) TextCenter
X
X     /Times-Roman 18 TextSet
X     (Alpha Phi Omega) TextCenter
X
X     /Helvetica 10 TextSet
X     (NATIONAL SERVICE FRATERNITY) TextCenter
X
X     /Helvetica 8 TextSet
X     (MASSACHUSETTS INSTITUTE OF TECHNOLOGY) TextCenter
X     (84 MASSACHUSETTS AVENUE, ROOM W20-415) TextCenter
X     (CAMBRIDGE, MASSACHUSETTS 02139) TextCenter
X     (TELEPHONE (617) 253-3788) TextCenter
X} bind def
X
X% Print the body of this form
X/Body {
X      /Times-Roman 14 TextDivide TextPageTop TextDrop
X      0.7 (Name of Printer )       FormShowTo (Date ) FormShow
X      0.7 (Contact Person: Name )  FormShowTo (Phone number ) FormShow
X      (Organization )              FormShow
X      (Job )                       FormShow
X      (Cardstock/Ink )             FormShow
X      0.5 (# Impressions )         FormShowTo TextDrop
X
X      (Extras:) TextShow
X      0.3 FormTab 0.4 FormTabLine (Numbering) TextShow
X           0.6 FormTab .7 FormTabLine (Split-Color) TextShow TextDrop
X
X      0.3 FormTab 0.4 FormTabLine (Multiple Colors) TextShow
X           0.6 FormTab .7 FormTabLine (Other) TextShow TextDrop
X
X      0.75 (Press Use Fees ) FormShowTo ($) FormShow
X      0.75 (Late Fees ) FormShowTo ($) FormShow
X      0.75 (Card Stock Fees ) FormShowTo ($) FormShow
X
X      /Times-Roman 12 TextDivide
X      0.6 FormTab 1 (TOTAL $) FormShowTo  % a TextDrop here is wrong font size
X
X      /Times-Roman 18 TextDivide
X(Exact CASH or CHECK payment must be received before jobs can leave the shop.)
X      TextCenter
X(Failure to comply can result in fines or suspension of printing privileges.) 
X      TextCenter
X} bind def
X
X% Puts in the "Official Use Only" Rect
X/Official
X{
X     RectBox stroke
X     /Symbol 4 TextDivide TextPageTop
X     TextDrop 0.4 FormTab (AFW ) TextShow
X     /Helvetica 4 TextDivide
X     (use only:) TextShow TextDrop
X     0.05 FormTab TextBox (CASH ) TextShow TextBox
X          0.95 (CHECK) FormShowTo TextDrop
X     0.05 FormTab 0.5 (name) FormShowTo 0.7 (initials) FormShowTo
X          0.95 (date) FormShowTo
X} bind def
X
X/Form
X{
X     RectBox stroke
X     { Logo }
X           1    1    3.25 4.0  RectDo
X     { Title }
X           3.5    1.5  4.6  4.2  RectDo
X     { Address }
X           2.75 1.1  0.5  3.9  RectDo
X     { Body }
X           7.5  2.5  0.5  1.4  RectDo
X     { Official }
X           7.5  0.9  0.5  0.5  RectDo
X     {
X           /Helvetica-Oblique 1 TextDivide TextPageTop
X           (white copy - Alpha Phi Omega) TextCenter
X     } 3.75 0.2  0.5  0.3  RectDo
X
X     {
X           /Helvetica-Oblique 1 TextDivide TextPageTop
X           (pink copy - customer) TextCenter
X     } 3.75 0.2  4.25  0.3  RectDo
X} bind def
X
X{ Form }
X   8.5 5.4 0 0 RectDo
X{ Form }
X   8.5 5.4 0 5.5 RectDo
Xshowpage
END_OF_FILE
if test 3348 -ne `wc -c <'form.ps'`; then
    echo shar: \"'form.ps'\" unpacked with wrong size!
fi
# end of 'form.ps'
fi
if test -f 'sideways.ps' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sideways.ps'\"
else
echo shar: Extracting \"'sideways.ps'\" \(381 characters\)
sed "s/^X//" >'sideways.ps' <<'END_OF_FILE'
X%! Example of a simple sideways sign
X%%   You must prepend the file Rect.ps for this example
X/Times-Bold findfont 140 scalefont setfont
X/inch {72 mul} def
X90 rotate 0 -8.5 inch translate        % Makes a 11x8.5 page out of 8.5x11
X
X
X{
X     /Times-Bold 4 TextDivide TextPageTop
X     (New York) TextCenter
X     (or) TextCenter
X     (BUST) TextCenter
X} 10 7.5 0.5 0.5 RectDo
X
Xshowpage
END_OF_FILE
if test 381 -ne `wc -c <'sideways.ps'`; then
    echo shar: \"'sideways.ps'\" unpacked with wrong size!
fi
# end of 'sideways.ps'
fi
if test -f 'arrow.ps' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'arrow.ps'\"
else
echo shar: Extracting \"'arrow.ps'\" \(621 characters\)
sed "s/^X//" >'arrow.ps' <<'END_OF_FILE'
X%!  Example of a simple arrow sign
X%%   You must prepend the file Rect.ps for this example
X90 rotate 0 -8.5 inch translate        % Makes a 11x8.5 page out of 8.5x11
X
X{
X   % RectLeftArrow        % uncomment this line for a  left  pointing arrow
X    RectRightArrow        % uncomment this line for a  right pointing arrow
X   % RectUpArrow          % uncomment this line for an up    pointing arrow
X   % RectDownArrow        % uncomment this line for a  down  pointing arrow
X} 9.5 4.5 1 0.5 RectDo
X
X{
X/Times-Roman 2 TextDivide TextPageTop
X(The BIG EVENT) TextCenter
X(Is this way!) TextCenter
X} 10 2 0.5 5.5 RectDo
Xshowpage
END_OF_FILE
if test 621 -ne `wc -c <'arrow.ps'`; then
    echo shar: \"'arrow.ps'\" unpacked with wrong size!
fi
# end of 'arrow.ps'
fi
echo shar: End of shell archive.
exit 0

Newsgroups: comp.lang.postscript