/* $Log: definefont.c,v $ * Revision 0.8 92/11/23 19:46:38 19:46:38 bt (Bo Thide') * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support * * Revision 0.7 92/11/13 02:41:22 02:41:22 bt (Bo Thide') * More bug fixes and improvements. Support for PaintJet XL * * Revision 0.6 92/11/10 21:47:38 21:47:38 bt (Bo Thide') * Bug fixes. Added -R option. Better font handling. * * Revision 0.5 92/11/09 16:25:25 16:25:25 bt (Bo Thide') * Rewrite of dospecial.c. Extended \special support * * Revision 0.4 92/11/08 02:45:40 02:45:40 bt (Bo Thide') * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's. * * Revision 0.3 92/08/24 12:43:18 12:43:18 bt (Bo Thide') * Fixed 8 bit (dc font) support. * * Revision 0.2 92/08/23 17:28:55 17:28:55 bt (Bo Thide') * Source cleaned up. Changed certain function calls. Removed globals. * * Revision 0.1 92/08/22 23:58:47 23:58:47 bt (Bo Thide') * First Release. * */ /* * This subroutine does the necessary things when a 'FNT_DEF' command is * being processed. */ #include #include #include "globals.h" #include "macros.h" static char rcsid[] = "$Header: definefont.c,v 0.8 92/11/23 19:46:38 bt Exp $"; void definefont(dvifile, f) FILE *dvifile; int f; { static int knownsize[] = {1,90,130,150,180,210,240,270,300,329,360, 394,432,473,518,568,622,681,746,818,896,981, 1075,1178,1290,1413,1548,1858,2035,2229,2442, 2675,10000}; int k; int a,l; /* Font definition parameters */ fontfmt *safefont; charfmt *u; int *known; int idealmag; double s; if(!inpostamble) { if(f >= MAXFONTS) valerror("Max number of allowed fonts is %3d\n", MAXFONTS); if(fontptr[f] != 0) valerror("Font number %d already defined\n", f); safefont = font; font = (fontfmt *)malloc(sizeof(*font)); fontptr[f] = font; font->checksum = getsquad(dvifile); font->scaled_size = getsquad(dvifile); font->design_size = getsquad(dvifile); a = (int)getubyte(dvifile); l = (int)getubyte(dvifile); if((nextnamesfree-names+a+l+2) > NAMESIZE) valerror("Capacity exceeded (name size=%d)\n",NAMESIZE); font->name = nextnamesfree - names; if(verbose) fprintf(stderr,"Font %d: ", f); for(k=0; kchr; for(k=0; k<=255; k++) { u->use_count = 0; u++; } font->space = font->design_size / 6; font->down = -3; if(verbose) printfont(); idealmag = round((double)font->scaled_size/(double)font->design_size*magnification*RESOLUTION*0.001); if((idealmag < 10) || (idealmag > 9999)) valerror("Font dpi size %d unrealistic\n", idealmag); known = knownsize; while(*known < idealmag) known++; if(((double) *known/idealmag) > ((double)idealmag/(*(known-1)))) known--; s = (double) *known/idealmag; if((s > 1.02) || (s < 0.98)) fprintf(stderr,"Warning: Size %d does not exist; substituting %d.\n", idealmag, *known); font->dir_size = *known; font = safefont; } }