Пример #1
0
halfword
pkdouble()
{
   register halfword i ;
   i = pkbyte() ;
   i = i * 256 + pkbyte() ;
   return(i) ;
}
Пример #2
0
static integer
pkpair(void)
{
  register integer i ;
  
  i = pkbyte() ;
  i = i * 256 + pkbyte() ;
  return (i);
}
Пример #3
0
static integer
pktrio()
{
   register integer i ;

   i = pkbyte() ;
   i = i * 256 + pkbyte() ;
   i = i * 256 + pkbyte() ;
   return(i) ;
}
Пример #4
0
static integer pkduo(void)
{
    register integer i;

    i = pkbyte();
    if (i > 127)
        i -= 256;
    i = i * 256 + pkbyte();
    return (i);
}
Пример #5
0
integer
pktrio(void)
{
   register integer i;

   i = pkbyte();
   i = i * 256 + pkbyte();
   i = i * 256 + pkbyte();
   return(i);
}
Пример #6
0
static shalfword getnyb(void)
{
    halfword temp;
    if (bitweight == 0) {
        bitweight = 16;
        inputbyte = pkbyte();
        temp = inputbyte >> 4;
    } else {
Пример #7
0
static shalfword
pksbyte(void)
{
   register shalfword i ;

   i = pkbyte() ;
   return i > 127 ? i -256 : i ;
}
Пример #8
0
/*
 *   fliload opens each font library, then reads in its
 *   directory for later use.
 *   fli_cache is initialized.
 */
void
fliload()
{
   int i ;
   halfword version1, version2;
   Boolean needext;
   char fontname[50]; 
   char name[50] ;
   char *fli;
   unsigned long dpi;
   halfword len, numsizes, numfonts;
   halfword numflib = 0 ;
   struct fli_lib *lib=NULL, *next_lib=NULL;
   struct fli_size *size;
   struct fli_entry *entry;

   /* initialise fli cache */
   for (i=0; i<FLICSIZE; i++) {
      fli_cache[i] = (struct fli_centry *)
                      mymalloc((integer)sizeof(struct fli_centry)); 
      fli_cache[i]->lib = (struct fli_lib *)NULL;
      fli_cache[i]->fp = (FILE *)NULL;
   }

   fli = fliname;

   while (*fli) {
      /* get next font library name from fliname */
      needext=1;
      for (i=0; *fli && *fli!=PATHSEP; i++)
         if ( (name[i] = *fli++) == '.')
            needext=0;
      name[i] = '\0';
      if (*fli)
         fli++;  /* skip PATHSEP */
      if (*name) { 
         /* got fli name, now search for it */
         if (needext)
            strcat(name,".fli");

         if ( (pkfile=search(flipath,name,READBIN)) != (FILE *)NULL ) {
            /* for each font library */
            for (i=0; i<4; i++) {
              fontname[i] = pkbyte();  /* read header */
            }
            version1 = pkbyte();
            version2 = pkbyte();
            if (strncmp(fontname,"FLIB",4)!=0 || version1 != 2 || version2 != 0)
               badpk("incorrect font library format");

            (void) pkdouble();       /* ignore directory length */
            numsizes = pkdouble();   /* number of sizes */
            numfonts = pkdouble();   /* number of fonts */
            len = pkdouble();        /* length of comment */
            for (i=0; i<len; i++)
               (void)pkbyte();       /* skip comment */
#ifdef DEBUG
   if (dd(D_FONTS))
      (void)fprintf(stderr,"Font library %s has %d font size%s, %d font%s\n",
         name, numsizes , numsizes !=1 ? "s" : "", 
         numfonts, numfonts!=1 ? "s" : "");
#endif /* DEBUG */

            next_lib =  (struct fli_lib *)
                      mymalloc((integer)sizeof(struct fli_lib)); 
            if (firstlib == (struct fli_lib *)NULL)
               firstlib = next_lib;
            else
               lib->next = next_lib;
            lib = next_lib;
            size = (struct fli_size *)
                        mymalloc((integer)numsizes * sizeof(struct fli_size)); 
            entry = (struct fli_entry *)
                        mymalloc((integer)numfonts * sizeof(struct fli_entry)); 
            lib->name = newstring(name);
            lib->sizes = numsizes;
            lib->size = size;
            lib->next = (struct fli_lib *)NULL;

            for ( ;numsizes>0; numsizes--, size++) { 
               /* for each font size in this library */
               (void)pkdouble();      /* length of size entry - ignore */
               numfonts = pkdouble(); /* number of fonts */
               dpi = pkquad();        /* DPI (fixed point 16.16) */

#ifdef DEBUG
   if (dd(D_FONTS))
      (void)fprintf(stderr,"Font library %s size %.5gdpi has %d font%s\n", 
                  name, dpi/65536.0, numfonts, numfonts!=1 ? "s" : "");
#endif /* DEBUG */
               size->size    = dpi ;
               size->entries = numfonts ;
               size->entry   = entry ;
                  for ( ;numfonts > 0; numfonts--, entry++) {
                     /* read each entry */
                     (void)pkquad();            /* ignore length of font */
                     entry->offset = pkquad();  /* offset to font */
                     len = pkbyte();            /* length of name */
                     for (i=0; i<len; i++)
                        fontname[i] = pkbyte();
                     fontname[len] = '\0';
                     entry->name = newstring(fontname);
                  } /* end for numfonts>0 */
            }  /* end for numsizes>0 */
            if (numflib < FLICSIZE) { /* leave first few open */
               fli_cache[numflib]->lib = lib;
               fli_cache[numflib]->fp = pkfile;
            }
            else
               (void)fclose(pkfile);
            numflib++;
         }  /* end if opened library */
      } /* end if (*name) */
   }
}