Back to index

tetex-bin  3.0
Defines | Functions | Variables
finclude.c File Reference
#include "dvips.h"
#include <ctype.h>
#include "protos.h"

Go to the source code of this file.

Defines

#define ISXGIGIT   isxdigit

Functions

char * strtok ()
double atof ()
fontdesctype *ifontdef P5C (char *, name, char *, area, int, scsize, int, dssize, char *, scname)
void setfamily P1C (fontdesctype *, f)
char *getname P1C (char *, s)
void includechars P2C (fontdesctype *, f, char *, s)
void scan1fontcomment P1C (char *, p)
void scan_fontnames P2C (char *, str, char *, psfile)
void scanfontusage P2C (char *, p, char *, psfile)
void scanfontcomments P1C (char *, filename)
Boolean okascmd P1C (char *, ss)
void nameout P2C (char *, area, char *, name)
void fonttableout P1H (void)

Variables

struct header_listps_fonts_used
char * infont
fontdesctypecurfnt
fontdesctypefonthead
integer fontmem
fontdesctypefonthd [MAXFONTHD]
int nextfonthd
char * nextstring
char xdig [256]
real conv
integer pagecost
int actualdpi
double mag
Boolean includesfonts
char * figpath
int to_close
integer debug_flag
static int fc_state = 0
static int check_atend = 0

Define Documentation

#define ISXGIGIT   isxdigit

Definition at line 20 of file finclude.c.


Function Documentation

double atof ( )

Here is the caller graph for this function:

void setfamily P1C ( fontdesctype ,
f   
)

Definition at line 82 of file finclude.c.

{
   int i ;

   fontmem -= DICTITEMCOST;
   for (i=0; i<nextfonthd; i++)
      if (strcmp(f->name, fonthd[i]->name)==0
            && strcmp(f->area, fonthd[i]->area)==0) {
         f->nextsize = fonthd[i];
         fonthd[i] = f;
         return;
      }
   if (nextfonthd==MAXFONTHD)
      error("! Too many fonts in included psfiles") ;
   fontmem -= NAMECOST + strlen(f->name) + strlen(f->area) ;
   fonthd[nextfonthd++] = f ;
   f->nextsize = NULL ;
}

Here is the call graph for this function:

char* getname P1C ( char *  ,
s   
)

Definition at line 106 of file finclude.c.

{
   char *a, *p, sav;

   a = NULL;
   for (p=s; *p!=0; p++)
      if (*p=='/')
         a = p+1 ;
   if (a==NULL) *nextstring++ = 0 ;
   else {   sav = *a ;
      *a = 0 ;
      (void) newstring(s) ;
      *a = sav ;
      s = a ;
   }
   return newstring(s);
}

Here is the call graph for this function:

void scan1fontcomment P1C ( char *  ,
p   
)

Definition at line 175 of file finclude.c.

{
   char *q, *name, *area;
   char *scname;      /* location in buffer where we got scsize */
   integer scsize, dssize;
   fontdesctype *fptr;
   real DVIperBP;

   DVIperBP = actualdpi/(72.0*conv) * (mag/1000.0);
   p = strtok(p, " ");
   if (p==NULL) return;
   area = nextstring ;   /* tentatively in the string pool */
   name = getname(p);
   q = strtok((char *)0, " ");
   if (p==NULL || (scsize=(integer)(atof(q)*DVIperBP))==0) {
      fprintf(stderr, "%s\n",p);
      error("No scaled size for included font");
      nextstring = area ;   /* remove from string pool */
      return;
   }
   scname = q;
   q = strtok((char *)0, " ");
   if (p==NULL || (dssize=(integer)(atof(q)*DVIperBP))==0) {
      fprintf(stderr, "%s\n",p);
      error("No design size for included font");
      nextstring = area ;
      return;
   }
   q = strtok((char *)0, " ");
   fptr = matchfont(name, area, scsize, scname);
   if (!fptr) {
      fptr = ifontdef(name, area, scsize, dssize, newstring(scname));
      (void) preselectfont(fptr);
      setfamily(fptr);
   } else {
      nextstring = area;   /* remove from string pool */
      (void) preselectfont(fptr);
      if (fptr->scalename==NULL) {
         fptr->scalename=newstring(scname);
         setfamily(fptr);
      }
   }
   includesfonts = 1;
   fptr->psflag |= THISPAGE;
   includechars(fptr, q);
}

Here is the call graph for this function:

void scanfontcomments P1C ( char *  ,
filename   
)

Definition at line 397 of file finclude.c.

{
   char p[500];
   char *r;
   FILE *f;
   integer truecost = pagecost ;
   Boolean trueknown = 0 ;
   fontdesctype *oldcf = curfnt;

#ifdef DEBUG
      if (dd(D_FONTS))
         (void)fprintf(stderr,
                     "Checking for fonts in '%s'\n",filename);
#endif  /* DEBUG */

   if (*filename == '`') {
/*
 *   Allow scanning of ` commands.  Better return same results both times.
 */
      f = popen(filename+1, "r") ;
      to_close = USE_PCLOSE ;
   } else {
      f = search(figpath, filename, READ) ;
   }
   if (f) {
     SET_BINARY(fileno(f)) ;
     fc_state = 0;
     check_atend = 0;
     while (fgets(p,500,f) && p[0]=='%' &&
            (p[1]=='!' || p[1]=='%' || p[1]=='*')) {
       if (strncmp(p, "%*Font:", 7) == 0) {
        scan1fontcomment(p+7);
       } else if (strncmp(p, "%%VMusage:", 9) == 0) {
        truecost += scanvm(p+10) ;
        trueknown = 1 ;
       }
       scanfontusage(p,filename);
     }
     if (trueknown)
       pagecost = truecost ;

     if(check_atend) {
#ifdef DEBUG
       if (dd(D_FONTS))
         (void)fprintf(stderr,
                     "Checking for (atend) fonts in '%s'\n",filename);
#endif  /* DEBUG */

       fc_state = 0;
       
       fseek(f,-4096,2); /* seek to 4096 bytes before EOF. */
       fgets(p,500,f); /* throw away a partial line. */

       /* find %%Trailer */
       while((r=fgets(p,500,f)) && strncmp(p,"%%Trailer",9)) ;

       /* look for specs that were deferred to the trailer. */
       if(r != NULL) {
        while(fgets(p,500,f)) {
          if(p[0]=='%' && p[1]=='%') scanfontusage(p,filename);
        }
       }
#ifdef DEBUG
       else { /* r == NULL */
        if (dd(D_FONTS))
         (void)fprintf(stderr,
                     "Did not find %%%%Trailer in included file '%s'.\n",
                     filename);
       }
#endif  /* DEBUG */
     }
     close_file(f) ;
   }
   curfnt = oldcf;
}

Here is the call graph for this function:

Boolean okascmd P1C ( char *  ,
ss   
)

Definition at line 477 of file finclude.c.

{
   register int c = 0 ;
   register char *s = ss ;

   while (*s)
      if (*s<' ' || *s>126 || ++c==30)
         return(0) ;
   return(strcspn(ss,"()<>[]{}%/") == c) ;
}
void fonttableout P1H ( void  ) [read]

Definition at line 513 of file finclude.c.

{
   int i, k;
   fontdesctype *f;

   for (i=0; i<nextfonthd; i++) {
      for (f=fonthd[i]; f!=NULL; f=f->nextsize)
         if (f->psflag==EXISTS) break;
      if (f!=NULL) {
         nameout(f->area, f->name);
         k = 0;
         do {
            if (f->psflag==EXISTS) {
               cmdout(f->scalename);
               lfontout((int)f->psname);
               k++;
            }
            f = f->nextsize;
         } while (f!=NULL);
         numout((integer)k);
         cmdout("fstore");
      }
   }
}

Here is the call graph for this function:

void includechars P2C ( fontdesctype ,
f  ,
char *  ,
s   
)

Definition at line 132 of file finclude.c.

{
   int b, c, d ;
   int l = strlen(s) ;

   while (l > 0 && (s[l-1] == '\n' || s[l-1] == '\r'))
      s[--l] = 0 ;
   if (!ISXDIGIT(s[0]) || !ISXDIGIT(s[1]) || s[2]!=':'
         || strspn(s+3,"0123456789ABCDEFabcdef") < l-3) {
      fprintf(stderr, "%s\n", s) ;
      error("Bad syntax in included font usage table") ;
      return ;
   }
   c = (xdig[(int)(s[0])] << 4) + xdig[(int)(s[1])] ;
   s += 2 ;
   while (*++s) {
      d = xdig[(int)*s] ;
      for (b=8; b!=0; b>>=1) {
         if ((d&b)!=0) {
            pagecost ++ ;
            (void) prescanchar(&f->chardesc[c]) ;
         }
         if (++c==256) return ;
      }
   }
}

Here is the call graph for this function:

void scan_fontnames P2C ( char *  ,
str  ,
char *  ,
psfile   
)

Definition at line 250 of file finclude.c.

{
  char *p,*pe;
  struct resfont *re;
  int i;

  /* Turn all newlines, CRs, and tabs into spaces. */
  p = str;
  while(*p) {
    if(*p == '\r' || *p == '\n' || *p == '\t') *p = ' ';
    p++;
  }
  /* Remove trailing spaces. */
  p = str+strlen(str)-1;
  while(p > str && *p == ' ') {
    *p = '\0';
    p--;
  }

  p = str;
  while(*p == ' ') p++; /* skip leading whitespace */

  while(p && *p) {
     pe = strchr(p,' ');
     if(pe != NULL) *pe = '\0';

     i = add_name(p,&ps_fonts_used);

     if (1) {
#ifdef DEBUG
       if (dd(D_FONTS))
         (void)fprintf(stderr,
                     "Adding font '%s' from included postscript file '%s'.\n",
                     p,psfile);
#endif  /* DEBUG */

       re = findPSname(p);
       if(re != NULL) {
         if (re->sent != 2) {
            if (re->Fontfile) {
               add_header(re->Fontfile) ;
            } else if (re->downloadheader) {
       /* this code borrowed from residentfont() in resident.c */
             char *cp = re->downloadheader ;
             char *q ;
        
             infont = re->PSname ;
             while (1) {
               q = cp ;
               while (*cp && *cp != ' ')
                  cp++ ;
               if (*cp) {
                  *cp = 0 ;
                  add_header(q) ;
                  *cp++ = ' ' ;
               } else {
                  add_header(q) ;
                  break ;
               }
               infont = 0 ;
             }
            }
           infont = 0 ;
          }
          re->sent = 2 ;
        } else {
          char eb[1000];
          sprintf(eb,"Font %s used in file %s is not in the mapping file.",
                  p,psfile);
          error(eb);
        }
     }

     p = pe;
     if(p != NULL) {
       p++;
       while(*p == ' ') p++; /* skip leading whitespace */
     }
  }

  return;
}

Here is the call graph for this function:

void scanfontusage P2C ( char *  ,
p  ,
char *  ,
psfile   
)

Definition at line 345 of file finclude.c.

{
  if (strncmp(p, "%%DocumentFonts: ",17) == 0) {
    p += 17 ;
    while (*p && *p <= ' ')
       p++ ;
    if(!strncmp(p,"(atend)",7)) {
      check_atend = 1;
    } else {
      scan_fontnames(p,psfile);
      fc_state = 1;
    }
  } else if (strncmp(p, "%%DocumentNeededFonts: ",23)==0) {
    p += 23 ;
    while (*p && *p <= ' ')
       p++ ;
    if(!strncmp(p,"(atend)",7)) {
      check_atend = 1;
    } else {
      scan_fontnames(p,psfile);
      fc_state = 1;
    }
  } else if (fc_state == 1 && strncmp(p,"%%+",3) == 0) {
    scan_fontnames(p+3,psfile);
    fc_state = 1;
  } else if (strncmp(p, "%%DocumentNeededResources: ",27) == 0) {
    p += 27 ;
    while (*p && *p <= ' ')
       p++ ;
    if(!strncmp(p,"(atend)",7)) {
      check_atend = 1;
    } else {
      if(!strncmp(p,"font ",5)) scan_fontnames(p+5,psfile);
      fc_state = 2;
    }
  } else if (fc_state == 2 && strncmp(p,"%%+",3) == 0) {
    p += 3 ;
    while (*p && *p <= ' ')
       p++ ;
    if(!strncmp(p,"font ",5)) scan_fontnames(p+5,psfile);
    fc_state = 2;
  } else {
    fc_state = 0;
  }
  return;
}

Here is the call graph for this function:

void nameout P2C ( char *  ,
area  ,
char *  ,
name   
)

Definition at line 491 of file finclude.c.

{
   char buf[30] ;
   char *s ;

   if (*area==0 && okascmd(name)) {
      (void)sprintf(buf, "/%s", name) ;
      cmdout(name);
   } else {
      for (s=area; *s; s++)
         scout(*s) ;
      for (s=name; *s; s++)
         scout(*s) ;
      stringend();
      cmdout("cvn") ;
   }
}

Here is the call graph for this function:

fontdesctype* ifontdef P5C ( char *  ,
name  ,
char *  ,
area  ,
int  ,
scsize  ,
int  ,
dssize  ,
char *  ,
scname   
)

Definition at line 66 of file finclude.c.

{
   fontdesctype *fp;

   fp = newfontdesc((integer)0, scsize, dssize, name, area);
   fp->scalename = scname;
   fp->next = fonthead ;
   fonthead = fp ;
   return fp;
}
char* strtok ( )

Variable Documentation

Definition at line 103 of file dvips.c.

int check_atend = 0 [static]

Definition at line 342 of file finclude.c.

Definition at line 97 of file dvips.c.

Definition at line 54 of file dvips.c.

Definition at line 199 of file dvips.c.

int fc_state = 0 [static]

Definition at line 338 of file finclude.c.

char* figpath

Definition at line 138 of file dvips.c.

Definition at line 184 of file dvips.c.

Definition at line 53 of file dvips.c.

Definition at line 109 of file dvips.c.

Definition at line 183 of file dvips.c.

char* infont

Definition at line 125 of file dvips.c.

double mag

Definition at line 598 of file dvi2xx.h.

Definition at line 185 of file dvips.c.

char* nextstring

Definition at line 92 of file dvips.c.

Definition at line 180 of file dvips.c.

Definition at line 101 of file resident.c.

Definition at line 59 of file search.c.

char xdig[256]

Definition at line 186 of file dvips.c.