src/shchar.c

00001 
00006 /*
00007  *  PROGRAM NAME:  sh
00008  *
00009  *  (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES
00010  *  CORPORATION 12/1/2001.  ALL RIGHTS RESERVED.
00011  *
00012  *  Please refer to the LICENSE file in the top directory
00013  *
00014  *      author: Mike Henderson mhender@watson.ibm.com
00015  */
00016 
00017 static char *id="@(#) $Id: shchar.c,v 1.2 2006/08/17 19:28:17 mhender Exp $";
00018 
00019 #include <shInternal.h>
00020 
00033 void shchar(int *ix,int *iy,float *z,char *chr,int *ired,int *igrn,int *iblu,int *iw)
00034  {
00035 
00036 /*        places a character string in the image */
00037 
00038 /*        Make a list, with ix,iy,iz and the string */
00039 /*        At the end of the postsript file, loop  */
00040 /*          over list, if iz is visible, place postscript commands to
00041             draw the string in the output file */
00042 
00043 /*        places a character in the sh_image */
00044 
00045   int xref=0;
00046   int yref=0;
00047   int ipwid=0;
00048   int iphgt=0;
00049   int width=0;
00050   int ibyte;
00051   int ichr;
00052   int ifnt;
00053   int idir;
00054   int xx,yy;
00055   float zz;
00056   int zero=0;
00057   int i,j;
00058   int jx,jy;
00059   int ib;
00060   int level;
00061 
00062   float conv;
00063 
00064 /*     conv converts from sp to pixels */
00065 
00066   conv=240./72.27/65536.;
00067   ifnt=sh_kfont[sh_cFont];
00068 
00069 /*  Blank is width of lower case m (?) */
00070 
00071   ichr=chr[0];
00072   if(chr[0]==' ')ichr='m';
00073 
00074   idir=sh_dir[ifnt]+4+ichr*16;
00075   sscanf(sh_image+idir,"%4.4d",&width);
00076   *iw=width*(sh_fmag[ifnt])*0.001*1.2*conv;
00077 
00078   if(chr[0]==' ')return;
00079 
00080   sscanf(sh_image+idir+ 4,"%4.4d",&xref);
00081   sscanf(sh_image+idir+ 6,"%4.4d",&yref);
00082   sscanf(sh_image+idir+ 8,"%4.4d",&ipwid);
00083   sscanf(sh_image+idir+10,"%4.4d",&iphgt);
00084   sscanf(sh_image+idir+12,"%4.4d",&ibyte);
00085   ibyte=ibyte+sh_dir[ifnt]-1;
00086 
00087   jx=(*ix)-xref+.5;
00088   jy=(*iy)+yref+.5;
00089 
00090 /*    put shadow in frame */
00091 
00092   if(shadow_idx!=0||shadow_idy!=0)
00093    {
00094     ib=ibyte;
00095     for(j=0;j<iphgt;j++)
00096      {
00097       for(i=0;i<ipwid;i++)
00098        {
00099         level=sh_image[ib];
00100         if(level!=0)
00101          {
00102           zz=*z-.01;
00103           xx=jx+i+shadow_idx;
00104           yy=jy-j+shadow_idy;
00105           shsetp(&xx,&yy,&zero,&zero,&zero,&zz);
00106          }
00107         ib++;
00108        }
00109      }
00110    }
00111 
00112 /*    put character in frame */
00113 
00114   ib=ibyte;
00115   for(j=0;j<iphgt;j++)
00116    {
00117     for(i=0;i<ipwid;i++)
00118      {
00119       level=sh_image[ib];
00120       if(level!=0)
00121        {
00122         zz=*z-.01;
00123         xx=jx+i;
00124         yy=jy-j;
00125         shsetp(&xx,&yy,ired,igrn,iblu,&zz);
00126        }
00127       ib++;
00128      }
00129    }
00130 
00131   return;
00132  }

Generated on Thu Aug 17 15:29:43 2006 for sh by  doxygen 1.4.6