home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / printer / dvi2pcl.lha / cachefonts.c < prev    next >
C/C++ Source or Header  |  1992-11-25  |  4KB  |  105 lines

  1. /* $Log:    cachefonts.c,v $
  2.  * Revision 0.8  92/11/23  19:46:37  19:46:37  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:21  02:41:21  bt (Bo Thide')
  6.  * More bug fixes and improvements. Support for PaintJet XL
  7.  * 
  8.  * Revision 0.6  92/11/10  21:47:37  21:47:37  bt (Bo Thide')
  9.  * Bug fixes. Added -R option. Better font handling.
  10.  * 
  11.  * Revision 0.5  92/11/09  16:25:24  16:25:24  bt (Bo Thide')
  12.  * Rewrite of dospecial.c. Extended \special support
  13.  * 
  14.  * Revision 0.4  92/11/08  02:45:39  02:45:39  bt (Bo Thide')
  15.  * Changed to portable bit manipulations. Replaced strrstr for non-POSIX
  16.  * compliant C. Fixed numerous bugs. Added support for more \special's.
  17.  * 
  18.  * Revision 0.3  92/08/24  12:45:32  12:45:32  bt (Bo Thide')
  19.  * Fixed 8 bit (dc font) support.
  20.  * 
  21.  * Revision 0.2  92/08/23  17:28:54  17:28:54  bt (Bo Thide')
  22.  * Source cleaned up.  Changed certain function calls.  Removed globals.
  23.  * 
  24.  * Revision 0.1  92/08/22  23:58:47  23:58:47  bt (Bo Thide')
  25.  * First Release.
  26.  *  */
  27.  
  28. /*
  29.  * This is the procedure with caching font responsibility. On entrance to
  30.  * this procedure, all the font usage information will have been loaded into
  31.  * 'use_count' entries for each font. 'cachefonts' first checks which of the
  32.  * fonts, used in the .dvi file, are permanently downloaded by calling
  33.  * 'permfonts' which in turn returns the number of permanent downloaded fonts.
  34.  * The remaining fonts are ordered in 'fontlist' in respect to their usage by
  35.  * calling 'sortfonts' which in turn returns the number of remaining fonts
  36.  * used in the document. These fonts will be downloaded in order of their
  37.  * usage, those most heavily used comes first and with just the characters
  38.  * used from these fonts. The downloading process continues so long the
  39.  * printer's memory will allow more and the actual number of downloaded fonts
  40.  * doesn't exceed MAXDOWN. If there are fonts which can't be download
  41.  * anymore, their character's pixel patterns together with a small font and
  42.  * character overhead are stored dynamically in memory. 
  43.  */
  44.  
  45. #include <stdio.h>
  46. #include "globals.h"
  47. #include "pcl.h"
  48.  
  49. static char rcsid[] = "$Header: cachefonts.c,v 0.8 92/11/23 19:46:37 bt Exp $";
  50.  
  51. void cachefonts(bitfile, resfile, maxdown, device)
  52. FILE    *bitfile;
  53. FILE    *resfile;
  54. short    maxdown;
  55. short    device;
  56. {
  57.     int    f;
  58.     int    n;
  59.     int    actfontsdown;
  60.     int    permfontsdown;
  61.     int    fontnum;
  62.     int    fontlist[MAXFONTS];
  63.  
  64.     /* Find all permanent downloaded fonts for dvifile in progress */
  65.     actfontsdown = permfontsdown = permfonts(resfile);
  66.  
  67.     /* Sort additional fonts in respect to their usage */
  68.     fontnum = sortfonts(fontlist);
  69.  
  70.     /* Decide for downloading or storage of fonts and chars and do it */
  71.     for(n = 0 ; n < fontnum ; n++) {
  72.         f = fontlist[n];
  73.         font = fontptr[f];
  74.         cbase = font->chr;
  75.         loadpkfile();
  76.         makepkdir();
  77.         convtfm = (double)font->scaled_size/(double)FIX ;
  78.         convpxl = (double)font->design_size/65536.0*
  79.           (double)font->dir_size/(double)SCALE;
  80.  
  81. #ifdef DEBUG
  82. fprintf(stderr,"cachefonts: font->scaled_size = %d\n", font->scaled_size);
  83. fprintf(stderr,"cachefonts: font->design_size = %d\n", font->design_size);
  84. fprintf(stderr,"cachefonts: font->dir_size = %d\n", font->dir_size);
  85. fprintf(stderr,"cachefonts: convtfm = %g, convpxl = %g\n", convtfm, convpxl);
  86. #endif /* DEBUG */
  87.  
  88.  
  89.         if(actfontsdown >= maxdown ||
  90.           (printer.mem-printermem_used) < MINPRINTERMEM)
  91.             storefont(bitfile, f);
  92.         else {
  93.             printermem_used += downloadfont(bitfile,
  94.               permfontsdown, device);
  95.             actfontsdown++;
  96.         }
  97.  
  98.     }
  99.  
  100.     if(landscape)
  101.         (void)fputs(PCL4_LANDSCAPE,bitfile);
  102.     if(manualfeed)
  103.         (void)fputs(PCL4_MANUAL_FEED,bitfile);
  104. }
  105.