home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / printer / dvi2pcl.lha / openpkfile.c < prev    next >
C/C++ Source or Header  |  1993-02-18  |  3KB  |  93 lines

  1. /* $Log:    openpkfile.c,v $
  2.  * Revision 0.8  92/11/23  19:46:50  19:46:50  bt (Bo Thide')
  3.  * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
  4.  * 
  5.  * Revision 0.7  92/11/13  02:41:35  02:41:35  bt (Bo Thide')
  6.  * More bug fixes and improvements. Support for PaintJet XL
  7.  * 
  8.  * Revision 0.6  92/11/10  21:47:51  21:47:51  bt (Bo Thide')
  9.  * Bug fixes. Added -R option. Better font handling.
  10.  * 
  11.  * Revision 0.5  92/11/09  16:25:38  16:25:38  bt (Bo Thide')
  12.  * Rewrite of dospecial.c. Extended \special support
  13.  * 
  14.  * Revision 0.4  92/11/08  02:45:54  02:45:54  bt (Bo Thide')
  15.  * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
  16.  * 
  17.  * Revision 0.3  92/08/24  12:45:45  12:45:45  bt (Bo Thide')
  18.  * Fixed 8 bit (dc font) support.
  19.  * 
  20.  * Revision 0.2  92/08/23  17:28:58  17:28:58  bt (Bo Thide')
  21.  * Source cleaned up.  Changed certain function calls.  Removed globals.
  22.  * 
  23.  * Revision 0.1  92/08/22  23:58:48  23:58:48  bt (Bo Thide')
  24.  * First Release.
  25.  *  */
  26.  
  27. #include <stdio.h>
  28. #include <string.h>
  29. #include "globals.h"
  30. #include "paths.h"
  31.  
  32. static char rcsid[] = "$Header: openpkfile.c,v 0.8 92/11/23 19:46:50 bt Exp $";
  33.  
  34. FILE *openpkfile()
  35.     FILE    *fileptr;
  36.     char    *fptr, *nptr, *pptr;
  37.     char    *pt_chrs = "0123456789", *pt_ptr;
  38.     int    pt_value;
  39.  
  40.     nptr = &names[font->name];
  41.     fptr = pkname;
  42.     pptr = fontpath;
  43.  
  44.     if(*nptr)
  45.         while(*nptr)
  46.             *fptr++ = *nptr++;
  47.     else
  48.         while(*pptr)
  49.             *fptr++ = *pptr++;
  50.     nptr++;
  51.  
  52.     /* Find the pt size from the font name string */
  53.     pt_ptr = strpbrk(nptr, pt_chrs);
  54.     sscanf(pt_ptr, "%d", &pt_value);
  55.  
  56.     /* Look for the pk fonts in pk300/10pt/cmr10.300pk etc.*/
  57.     /*sprintf(fptr,"/%dpt/%s.%dpk", pt_value, nptr, font->dir_size);*/
  58.     sprintf(fptr,"/%d/%s.%dpk",font->dir_size, nptr, font->dir_size);
  59.  
  60.     /* Try to open pk font file */
  61.     if((fileptr = fopen(pkname,"r")) != NULL)
  62.       return fileptr;
  63.  
  64.     /* Look for the pk fonts in pk300/cmr10.300pk etc.*/
  65.     sprintf(fptr,"/%s.%dpk", nptr, font->dir_size);
  66.     if((fileptr = fopen(pkname,"r")) != NULL)
  67.       return fileptr;
  68.  
  69.     fprintf(stderr,"Cannot find pk font file %s\n",pkname);
  70.  
  71.     /* Try to substitute at base resolution */
  72.     font->dir_size = pt_value = RESOLUTION;
  73.  
  74.     sprintf(fptr, "/%dpt/%s.%dpk", pt_value,nptr, font->dir_size);
  75.     if((fileptr = fopen(pkname,"r")) != NULL){
  76.         fprintf(stderr,"Substituting %s at %d points\n", nptr,pt_value);
  77.         return fileptr;
  78.     }
  79.  
  80.     sprintf(fptr, "/%s.%dpk",nptr,font->dir_size);
  81.     if((fileptr = fopen(pkname,"r")) != NULL){
  82.         fprintf(stderr,"Substituting %s at %d points\n", nptr,pt_value);
  83.         return fileptr;
  84.     }
  85.  
  86.     fprintf(stderr,"Substituting cmr10 at ten points . . .\n");
  87.     if ((fileptr = fopen(defaultpk,"r")) != NULL)
  88.         return 0;
  89.     fprintf(stderr, "Killed in openpkfile()\n");
  90.     exit(-1);
  91. }
  92.