Post Scriptum language

// Example 8

procedure fractionshow( numerator, denominator ) 
{
        regularfont = currentfont();
        fractionfont = makefont( currentfont(), [0.65,0,0,0.6,0,0] );

        gsave();
        newpath();
        moveto(0, 0);

        charpath( "1", true );
        // Notice: 'true' is global PostScript variable, 
        // not an operator

        flattenpath();
        pb = [pathbbox()];   // The trick we already know
        height = pb[3];
        grestore();

        rmoveto( 0, 0.4*height );
        setfont( fractionfont );
        show( numerator );

        rmoveto( 0, -0.4*height );
        setfont( regularfont );
        show( "\244" );          

        setfont( fractionfont );
        show( denominator );
        setfont( regularfont );
}

setfont( scalefont( findfont( 'Times-Roman' ), 300 ));
moveto( 100, 72 );
fractionshow( "7", "8" );

setfont( scalefont( findfont( 'Times-Roman' ), 18 ));
moveto( 72, 550 );
show( "Slowly stir in 5" );
fractionshow( "1", "2" );
show( " lbs. of chocolate and then blend on high." );

setfont( scalefont( findfont( 'Times-Roman' ), 40 ));
moveto( 420, 650 );
fractionshow( "13", "22" );
moveto( 100, 450 );
fractionshow( "3", "4" );


showpage();