ftp.nice.ch/pub/next/unix/developer/plplot.3.0.s.tar.gz#/plplot/fonts/xtndfont.c

This is xtndfont.c in view mode; [Download] [Up]

#include <stdio.h>
#include <string.h>

#if defined(vax) || defined(vax3200)
#define SCHAR   char
#else
#define SCHAR   signed char
#endif

extern short int *hersh[];
extern short int *findex[];
extern short int *buffer[];

main()
{
   short j, k, ib, nindx, nchars, nleng, htab, zero;
   short *hrshlst;
   SCHAR ix, iy;
   long fpos;
   FILE *fontfile;
   char *malloc();

   hrshlst = (short *)malloc(4*176*sizeof(short));

   ib = 0;
   for(j=0; j<4; j++)
      for(k=0; k<176; k++)
         hrshlst[ib++] = *(hersh[j]+k);

   fontfile = fopen("plxtnd.font","w+");
   if(!fontfile) {
      printf("Error opening extended font file.\n");
      exit(1);
   }

   htab = 4*256+176;   /* # of fonts in upper byte # of chars in lower */
   fwrite((char *)&htab,sizeof(short),1,fontfile);
   fwrite((char *)hrshlst,sizeof(short),4*176,fontfile);

   nleng = 1;
   zero = 0;
   nindx = 0;
   fpos = ftell(fontfile);
   fwrite((char *)&nindx,sizeof(short),1,fontfile);
   for(j=0; j<30; j++) {
      for(k=0; k<100; k++) {
         ib = *(findex[j]+k);
         if(ib == 0) {
            fwrite((char *)&zero,sizeof(short),1,fontfile);
            nindx++;
         }
         else {
            fwrite((char *)&nleng,sizeof(short),1,fontfile);
            nindx++;
            for(;;) {
               ix = *(buffer[ib/100]+ib%100)/128 - 64;
               iy = *(buffer[ib/100]+ib%100)%128 - 64;
               ib++;
               if(ix == -64)
                  ix = 64;
               if(iy == -64)
                  iy = 64;
               nleng++;
               if(ix == 64 && iy == 64)
                  break;
            }
         }
      }
   }
   fseek(fontfile,fpos,0);
   fwrite((char *)&nindx,sizeof(short),1,fontfile);

   fseek(fontfile,0,2);
   fpos = ftell(fontfile);
   nleng = 1;
   nchars = 0;
   fwrite((char *)&nleng,sizeof(short),1,fontfile);
   for(j=0; j<30; j++) {
      for(k=0; k<100; k++) {
         ib = *(findex[j]+k);
         if(ib != 0) {
            for(;;) {
               ix = *(buffer[ib/100]+ib%100)/128 - 64;
               iy = *(buffer[ib/100]+ib%100)%128 - 64;
               ib++;
               if(ix == -64)
                  ix = 64;
               if(iy == -64)
                  iy = 64;
               fputc(ix,fontfile);
               fputc(iy,fontfile);
               nleng++;
               if(ix == 64 && iy == 64)
                  break;
            }
            nchars++;
         }
      }
   }
   nleng--;
   fseek(fontfile,fpos,0);
   fwrite((char *)&nleng,sizeof(short),1,fontfile);
   fclose(fontfile);
   printf("There are %d characters in font set.\n",nchars-1);
   exit(0);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.