This is stndfont.c in view mode; [Download] [Up]
#include <stdio.h> #include <string.h> extern short int *hersh[]; extern short int *findex[]; extern short int *buffer[]; #if defined(vax) || defined(vax3200) #define SCHAR char #else #define SCHAR signed char #endif int compare(si1, si2) char *si1, *si2; { return( *(short *)si1 == *(short *)si2 ? 0 : (*(short *)si1 > *(short *)si2 ? 1 : -1)); } int main() { short i, j, k, ib, nstd, nchars, nleng, htab, nindx, zero; short *hrshlst, *hrshidx; SCHAR ix, iy; long fpos; FILE *fontfile; char *malloc(); void qsort(); long ftell(); hrshlst = (short *)malloc(176*sizeof(short)); hrshidx = (short *)malloc(176*sizeof(short)); ib = 0; for(k=0; k<176; k++) hrshlst[ib++] = *(hersh[0]+k); /* Sort list */ qsort((char *)hrshlst,ib,sizeof(short),compare); /* Remove duplicates */ k = 0; j = 0; do { if(hrshlst[k] == hrshlst[j]) j++; else hrshlst[++k] = hrshlst[j]; } while(j < ib); nstd = k+1; /* Now reindex the fonts */ for(k=0; k<176; k++) for(i=0; i<nstd; i++) if(*(hersh[0]+k) == hrshlst[i]) { hrshidx[k] = i+1; break; } fontfile = fopen("plstnd.font","w+"); if(!fontfile) { printf("Error opening standard font file.\n"); exit(1); } htab = 1*256+176; /* # of fonts in upper byte # of chars in lower */ fwrite((char *)&htab,sizeof(short),1,fontfile); fwrite((char *)hrshidx,sizeof(short),176,fontfile); zero = 0; nindx = 0; nleng = 1; fpos = ftell(fontfile); fwrite((char *)&nindx,sizeof(short),1,fontfile); for(j=0; j<nstd; j++) { ib = *(findex[(hrshlst[j]-1)/100]+(hrshlst[j]-1)%100); 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); nchars = 0; nleng = 1; fseek(fontfile,0,2); /* Go to end of file */ fpos = ftell(fontfile); /* Save current position */ fwrite((char *)&nleng,sizeof(short),1,fontfile); for(j=0; j<nstd; j++) { ib = *(findex[(hrshlst[j]-1)/100]+(hrshlst[j]-1)%100); 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 standard 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.