Post Scriptum language

// Example 18

glo = [ yline: 500 ];

procedure ReEncodeSmall( basefontname, newfontname, 
                newcodesandnames )
{
        basefontdict = findfont( basefontname );
        newfont = dict( maxlength( basefontdict ));

        for ( id:val in basefontdict ) {
                if ( id != 'FID' ) {
                        if ( id == 'Encoding' )
                                newfont.Encoding = copy( val, 
                                      array( length( val )));
                        else

                                // This is indirect dictionary 
                                // lookup: name of the field 
                                // used here is taken from 
                                // expression in brackets

                                newfont[ id ] = val;
                }
        }

        newfont.FontName = newfontname;

        for ( i=0 to idiv( length( newcodesandnames ), 2 )-1 ) {
                newfont.Encoding[ newcodesandnames[ 2*i ] ] = 
                        newcodesandnames[ 2*i + 1 ];
        }

        definefont( newfontname, newfont );
}

scandvec = [
  0300, 'Oacute',
  0311, 'Adieresis',
  0321, 'oacute',
  0322, 'Ograve',
  0323, 'Scaron',
  0324, 'ograve',
  0325, 'scaron',
  0330, 'Edieresis',
  0331, 'adieresis',
  0332, 'edieresis',
  0333, 'Odieresis',
  0334, 'odieresis',
  0340, 'Aacute',
  0342, 'Aring',
  0344, 'Zcaron',
  0347, 'Eacute',
  0360, 'aacute',
  0362, 'aring',
  0364, 'zcaron',
  0367, 'eacute'
];

procedure ss( str ) 
{
        moveto( 72, glo.yline );
        show( str );
        glo.yline -= 36;
}

ReEncodeSmall( 'Times-Roman', 'Times-Roman-Scand', scandvec );
setfont( scalefont( findfont( 'Times-Roman-Scand' ), 16 ));

glo.yline = 500;

ss( "Boktryckarkonsten \331r k\331llan till "
    "praktiskt taget all m\331nsklig odling." );
ss( "Den f\334rutan hade de oerh\334rda "
    "framstegen inom vetenskap" );
ss( "och teknik inte varit m\334jliga." );
ss( "\261VALTER FALK" );

setfont( scalefont( findfont( 'Times-Italic' ), 14 ));
glo.yline = 500 - 18;

ss ( "Printing is the source of practically "
     "all human evolution." );
ss( "Without it the tremendous progress in the "
    "fields of science and" );
ss( "technology would not have been possible." );

showpage();