/*
 *      make_SR.c
 *
 * SR - Relative Character Size Instruction
 *
 * Sets the character width and height relative to P1 and P2 for labels.
 */
#include "defn.h"

make_SR()
{
    float   pwidth, pheight;

    if (test_token())
    {
	pwidth = getval();		/* Percent */
	if (test_token())
	    pheight = getval();		/* Percent */
        else {
	    fprintf(stderr,"ERROR: SR instruction with only one parameter not valid\n");
	    /* break; */
        } 
	if ((pwidth < 0.0) || (pheight < 0.0))
	{
	   if (pwidth < 0.0)  pwidth = - pwidth;
	   if (pheight < 0.0)  pheight = - pheight;
	   fprintf(stderr,"WARNING: SR instruction with negative parameters not implemented yet,\n");
	   fprintf(stderr,"         positive parameters are assumed.\n");
        } 
	if ((pwidth == 0.0) || (pheight == 0.0))
	{
	   pwidth = DEFWIDTH;
	   pheight = DEFHEIGHT;
	   fprintf(stderr,"WARNING: SR instruction with parameter equal zero not valid,\n");
	   fprintf(stderr,"         default parameter are assumed.\n");
        }
    }
    else
    {
	pwidth = DEFWIDTH;
	pheight = DEFHEIGHT;
    }
    char_width = (U2x - U1x) * XSCALE * pwidth / 100.0;
    char_height = (U2y - U1y) * YSCALE * pheight / 100.0;
    char_space = char_width * (1/.67 - 1);
    fprintf(outfile, "/%s %g %g %g DefFont\n",
		font, chWfact * char_width, chHfact * char_height, char_slant);
    rel_WIDTH = pwidth;
    rel_HEIGHT = pheight;
}
