/*
 *       make_SI.c
 *
 * SI - Absolute Character Size
 *
 * Sets character width and height in millimeters for the Laser Printer.
 */
#include "defn.h"

make_SI()
{
    if (test_token())
    {
	char_width = getval() * 10 * RESOLUTION * XSCALE_ABS;	  /*  mm  */
	if (test_token())
	    char_height = getval() * 10 * RESOLUTION * YSCALE_ABS;  /* mm */
        else {
	    fprintf(stderr,
		"ERROR: SI instruction with only one parameter not valid\n");
	    /* break; */
        } 
	if ((char_width < 0.0) || (char_height < 0.0))
	{
	  if (char_width < 0.0)  char_width = - char_width;
	  if (char_height < 0.0)  char_height = - char_height;
	  fprintf(stderr,"WARNING: SI instruction with negative parameters not implemented yet,\n");
	  fprintf(stderr,"         positive parameters are assumed.\n");
        } 
	if ((char_width == 0.0) || (char_height == 0.0))
	{
	  if (strcmp(PaperSize, "A4") == 0)
	  {
	    char_width = 1.87 * RESOLUTION * XSCALE_ABS;
	    char_height = 2.69 * RESOLUTION * YSCALE_ABS;
          }
          else     /*  A3  */
	  {
	    char_width = 2.85 * RESOLUTION * XSCALE_ABS;
	    char_height = 3.75 * RESOLUTION * YSCALE_ABS;
          }

	  fprintf(stderr,"WARNING: SI instruction with parameter equal zero not valid,\n");
	  fprintf(stderr,"         default parameter are assumed.\n");
        }
    }
    else
    {
	if ((ch = getc(stream)) == ';')
	{
	  if (strcmp(PaperSize, "A4") == 0)
	  {
	    char_width = 1.87 * RESOLUTION * XSCALE_ABS;
	    char_height = 2.69 * RESOLUTION * YSCALE_ABS;
          }
          else
	  {
	    char_width = 2.85 * RESOLUTION * XSCALE_ABS;
	    char_height = 3.75 * RESOLUTION * YSCALE_ABS;
          }
	}
    }
    char_space = char_width * (1/.67 - 1);
    fprintf(outfile, "/%s %g %g %g DefFont\n",
	font, chWfact * char_width, chHfact * char_height, char_slant);
}
