Back to index

tetex-bin  3.0
Classes | Functions | Variables
scanfont.c File Reference
#include <string.h>
#include "t1stdio.h"
#include "util.h"
#include "token.h"
#include "fontfcn.h"
#include "blues.h"
#include "../t1lib/t1misc.h"

Go to the source code of this file.

Classes

struct  EncodingTable

Functions

int T1Getc (F_FILE *)
int T1Ungetc (int, F_FILE *)
int SearchDictName (psdict *dictP, psobj *keyP)
void T1io_setblocklen (long len)
void objFormatInteger (psobj *objP, int value)
void objFormatReal (psobj *objP, float value)
void objFormatBoolean (psobj *objP, boolean value)
void objFormatEncoding (psobj *objP, int length, psobj *valueP)
void objFormatArray (psobj *objP, int length, psobj *valueP)
void objFormatString (psobj *objP, int length, char *valueP)
void objFormatName (psobj *objP, int length, char *valueP)
void objFormatFile (psobj *objP, FILE *valueP)
static psobjMakeEncodingArrayP (EncodingTable *encodingTable)
boolean Init_BuiltInEncoding ()
static int getNextValue (int valueType)
static int getInt ()
static int getEncoding (psobj *arrayP)
static int getArray (psobj *arrayP)
static int getNbytes (int N)
static int getLiteralName (psobj *nameObjP)
static int BuildSubrs (psfont *FontP)
static int BuildCharStrings (psfont *FontP)
static int BuildFontInfo (psfont *fontP)
static int BuildPrivate (psfont *fontP)
static int GetType1Blues (psfont *fontP)
psobjGetType1CharString (psfont *fontP, unsigned char code)
static int FindDictValue (psdict *dictP)
int scan_font (psfont *FontP)

Variables

static int rc
static boolean InPrivateDict
static boolean WantFontInfo
static boolean TwoSubrs
static psobj inputFile
static psobj filterFile
static psobjinputP
char not_def [] = ".notdef"
static EncodingTable StdEnc []
psobjStdEncArrayP = NULL

Class Documentation

struct EncodingTable

Definition at line 76 of file scanfont.c.

Class Members
int index
char * name

Function Documentation

static int BuildCharStrings ( psfont FontP) [static]

Definition at line 636 of file scanfont.c.

{
   int N;   /* number of values in CharStrings */
   int i;   /* loop thru  Subrs */
   int J;   /* length of Subrs entry */
   psdict  *dictP;
 
   /* next token should be a positive int */
   N = getInt();
   if (rc) {
     /* check if file had TwoSubrs, hi resolution stuff is in file*/
     if (TwoSubrs) {
       do {
         scan_token(inputP);
         if (tokenType <= TOKEN_NONE) {
           if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
           return(SCAN_ERROR);
         }
       } while (tokenType != TOKEN_INTEGER);
       N = tokenValue.integer;
     }
     else return(rc);  /* if next token was not an Int */
   }
   if (N<=0) return(SCAN_ERROR);
   /* save number of entries in the dictionary */
 
   dictP = (psdict *)vm_alloc((N+1)*sizeof(psdict));
   if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
   FontP->CharStringsP = dictP;
   dictP[0].key.len = N;
   /* get N values for CharStrings */
   for (i=1;i<=N;i++) {
     /* look for next literal name  */
     rc = getLiteralName(&(dictP[i].key));
     /* If rc=SCAN_END, the end of file has been reached. This means
       there were less than N charstrings. This is perfectly valid. */
     if (rc) return(rc);
     /* get 1 integer */
     J = getInt();
     if (rc) return(rc);  /* if next token was not an Int */
     if (J<0) return (SCAN_ERROR);
     dictP[i].value.len = J;
     /* get the next token, it should be RD or -|, either is ok */
     rc = getNextValue(TOKEN_NAME);
     if ( rc != SCAN_OK ) return(rc);
     rc = getNbytes(J);
     if (rc == SCAN_OK) {
       dictP[i].value.data.valueP = tokenStartP;
       if ( !(vm_alloc(J)) ) return(SCAN_OUT_OF_MEMORY);
     }
     else {
       return(rc);
     }
     
   }
   return(SCAN_OK);
 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int BuildFontInfo ( psfont fontP) [static]

Definition at line 701 of file scanfont.c.

{
  psdict *dictP;
  
  /* allocate the private dictionary */
  dictP = (psdict *)vm_alloc(20*sizeof(psdict));
  if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
 
  fontP->fontInfoP = dictP;
  fontP->fontInfoP[0].key.len = 17;  /* number of actual entries */
  objFormatName(&(dictP[FONTNAME].key),8,"FontName");
  objFormatName(&(dictP[FONTNAME].value),0,NULL);
  objFormatName(&(dictP[PAINTTYPE].key),9,"PaintType");
  objFormatInteger(&(dictP[PAINTTYPE].value),0);
  objFormatName(&(dictP[FONTTYPENUM].key),8,"FontType");
  objFormatInteger(&(dictP[FONTTYPENUM].value),0);
  objFormatName(&(dictP[FONTMATRIX].key),10,"FontMatrix");
  objFormatArray(&(dictP[FONTMATRIX].value),0,NULL);
  objFormatName(&(dictP[FONTBBOX].key),8,"FontBBox");
  objFormatArray(&(dictP[FONTBBOX].value),0,NULL);
  objFormatName(&(dictP[ENCODING].key),8,"Encoding");
  objFormatEncoding(&(dictP[ENCODING].value),0,NULL);
  objFormatName(&(dictP[UNIQUEID].key),8,"UniqueID");
  objFormatInteger(&(dictP[UNIQUEID].value),0);
  objFormatName(&(dictP[STROKEWIDTH].key),11,"StrokeWidth");
  objFormatReal(&(dictP[STROKEWIDTH].value),0.0);
  objFormatName(&(dictP[VERSION].key),7,"version");
  objFormatString(&(dictP[VERSION].value),0,NULL);
  objFormatName(&(dictP[NOTICE].key),6,"Notice");
  objFormatString(&(dictP[NOTICE].value),0,NULL);
  objFormatName(&(dictP[FULLNAME].key),8,"FullName");
  objFormatString(&(dictP[FULLNAME].value),0,NULL);
  objFormatName(&(dictP[FAMILYNAME].key),10,"FamilyName");
  objFormatString(&(dictP[FAMILYNAME].value),0,NULL);
  objFormatName(&(dictP[WEIGHT].key),6,"Weight");
  objFormatString(&(dictP[WEIGHT].value),0,NULL);
  objFormatName(&(dictP[ITALICANGLE].key),11,"ItalicAngle");
  objFormatReal(&(dictP[ITALICANGLE].value),0.0);
  objFormatName(&(dictP[ISFIXEDPITCH].key),12,"isFixedPitch");
  objFormatBoolean(&(dictP[ISFIXEDPITCH].value),FALSE);
  objFormatName(&(dictP[UNDERLINEPOSITION].key),17,"UnderlinePosition");
  objFormatReal(&(dictP[UNDERLINEPOSITION].value),0.0);
  objFormatName(&(dictP[UNDERLINETHICKNESS].key),18,"UnderlineThickness");
  objFormatReal(&(dictP[UNDERLINETHICKNESS].value),0.0);
  return(SCAN_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int BuildPrivate ( psfont fontP) [static]

Definition at line 755 of file scanfont.c.

{
  psdict *Private;
 
  /* allocate the private dictionary */
  Private = (psdict *)vm_alloc(20*sizeof(psdict));
 
  if (!(Private)) return(SCAN_OUT_OF_MEMORY);
 
  fontP->Private = Private;
  fontP->Private[0].key.len = 16;  /* number of actual entries */
 
  objFormatName(&(Private[BLUEVALUES].key),10,"BlueValues");
  objFormatArray(&(Private[BLUEVALUES].value),0,NULL);
  objFormatName(&(Private[OTHERBLUES].key),10,"OtherBlues");
  objFormatArray(&(Private[OTHERBLUES].value),0,NULL);
  objFormatName(&(Private[FAMILYBLUES].key),11,"FamilyBlues");
  objFormatArray(&(Private[FAMILYBLUES].value),0,NULL);
  objFormatName(&(Private[FAMILYOTHERBLUES].key),16,"FamilyOtherBlues");
  objFormatArray(&(Private[FAMILYOTHERBLUES].value),0,NULL);
  objFormatName(&(Private[BLUESCALE].key),9,"BlueScale");
  objFormatReal(&(Private[BLUESCALE].value),DEFAULTBLUESCALE);
  objFormatName(&(Private[BLUESHIFT].key),9,"BlueShift");
  objFormatInteger(&(Private[BLUESHIFT].value),DEFAULTBLUESHIFT);
  objFormatName(&(Private[BLUEFUZZ].key),8,"BlueFuzz");
  objFormatInteger(&(Private[BLUEFUZZ].value),DEFAULTBLUEFUZZ);
  objFormatName(&(Private[STDHW].key),5,"StdHW");
  objFormatArray(&(Private[STDHW].value),0,NULL);
  objFormatName(&(Private[STDVW].key),5,"StdVW");
  objFormatArray(&(Private[STDVW].value),0,NULL);
  objFormatName(&(Private[STEMSNAPH].key),9,"StemSnapH");
  objFormatArray(&(Private[STEMSNAPH].value),0,NULL);
  objFormatName(&(Private[STEMSNAPV].key),9,"StemSnapV");
  objFormatArray(&(Private[STEMSNAPV].value),0,NULL);
  objFormatName(&(Private[FORCEBOLD].key),9,"ForceBold");
  objFormatBoolean(&(Private[FORCEBOLD].value),DEFAULTFORCEBOLD);
  objFormatName(&(Private[LANGUAGEGROUP].key),13,"LanguageGroup");
  objFormatInteger(&(Private[LANGUAGEGROUP].value),DEFAULTLANGUAGEGROUP);
  objFormatName(&(Private[LENIV].key),5,"lenIV"); 
  objFormatInteger(&(Private[LENIV].value),DEFAULTLENIV);
  objFormatName(&(Private[RNDSTEMUP].key),9,"RndStemUp");
  objFormatBoolean(&(Private[RNDSTEMUP].value),DEFAULTRNDSTEMUP);
  objFormatName(&(Private[EXPANSIONFACTOR].key),9,"ExpansionFactor");
  objFormatReal(&(Private[EXPANSIONFACTOR].value),
                          DEFAULTEXPANSIONFACTOR);
  return(SCAN_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int BuildSubrs ( psfont FontP) [static]

Definition at line 535 of file scanfont.c.

{
   int N;   /* number of values in Subrs */
   int I;   /* index into Subrs */
   int i;   /* loop thru  Subrs */
   int J;   /* length of Subrs entry */
   psobj *arrayP;
 
   /* next token should be a positive int */
   /* note: rc is set by getInt. */
   N = getInt();
   if (rc) return(rc);
   if (N < 0 ) return(SCAN_ERROR);
   /* if we already have a Subrs, then skip the second one */
   /* The second one is for hiresolution devices.          */
   if (FontP->Subrs.data.arrayP != NULL) {
     TwoSubrs = TRUE;
     /* process all the Subrs, but do not update anything */
     /* can not just skip them because of the binary data */
     for (i=0;i<N;i++) {
       /* look for "dup" or "ND" or "|-" or (noaccess) "def". If one of
         the latter three token appears, we are done even if still i < N-1.
         in this case, there arenīt as much subroutines as fields in the
         array which is allowed (Fix thanks to Derek B. Noonburg) */
       do {
        rc = getNextValue(TOKEN_NAME);
        if ( rc != SCAN_OK ) return(rc);
        if (!strncmp(tokenStartP, "ND", 2) ||
            !strncmp(tokenStartP, "|-", 2) ||
            !strncmp(tokenStartP, "def", 3)) {
          return SCAN_OK;
        }
       } while (strncmp(tokenStartP, "dup", 3));
       if (rc) return(rc);
       /* get 2 integers */
       I = getInt();
       if (rc) return(rc);
       J = getInt();
       if (rc) return(rc);
       if ( (I < 0) || (J < 0 ) ) return (SCAN_ERROR);
       /* get the next token, it should be RD or -|, either is ok */
       rc = getNextValue(TOKEN_NAME);
       if ( rc != SCAN_OK ) return(rc);
       rc = getNbytes(J);
       if (rc) return(rc);
     }
     return(SCAN_OK);
   }
 
   arrayP = (psobj *)vm_alloc(N*sizeof(psobj));
   if (!(arrayP) ) return(SCAN_OUT_OF_MEMORY);
   /* explicitly resetting the array is not necessary since the pointer
      as well as the subroutines both are located in VM and we can
      assume that only define subroutines are referenced. */
   FontP->Subrs.len = N;
   FontP->Subrs.data.arrayP =  arrayP;
   /* get N values for Subrs */
   for (i=0;i<N;i++) {
     /* look for "dup" or "ND" or "|-" or (noaccess) "def". If one of
       the latter three token appears, we are done even if still i < N-1.
       in this case, there arenīt as much subroutines as fields in the
       array which is allowed (Fix thanks to Derek B. Noonburg) */
     do {
       rc = getNextValue(TOKEN_NAME);
       if ( rc != SCAN_OK ) return(rc);
       if (!strncmp(tokenStartP, "ND", 2) ||
          !strncmp(tokenStartP, "|-", 2) ||
          !strncmp(tokenStartP, "def", 3)) {
        return SCAN_OK;
       }
     } while (strncmp(tokenStartP, "dup", 3));
     /* get 2 integers */
     I = getInt();       /* index into array of Subroutines */
     if (rc) return(rc); 
     J = getInt();       /* number of binary bytes that follow */
     if (rc) return(rc);
     if ( (I < 0) || (J < 0 ) ) return (SCAN_ERROR);
     arrayP[I].len = J;
     /* get the next token, it should be RD or -|, either is ok */
     rc = getNextValue(TOKEN_NAME);
     if ( rc != SCAN_OK ) return(rc);
     rc = getNbytes(J);
     if (rc == SCAN_OK) {
       arrayP[I].data.valueP = tokenStartP;
       if ( !(vm_alloc(J)) ) return(SCAN_OUT_OF_MEMORY);
     }
     else return(rc);
   }
   return(SCAN_OK);
 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int FindDictValue ( psdict dictP) [static]

Definition at line 1131 of file scanfont.c.

{
   psobj LitName;
   int   N;
   int   V;
 
   /* we have just scanned a token and it is a literal name */
   /* need to check if that name is in Private dictionary */
   objFormatName(&LitName,tokenLength,tokenStartP);
   /* is it in the dictP */
   N = SearchDictName(dictP,&LitName);
   /* if found */
   if ( N > 0 ) {
     /* what type */
     switch (dictP[N].value.type) {
       case OBJ_ENCODING:
         V = getEncoding(&(dictP[N].value));
         if ( V != SCAN_OK ) return(V);
         break;
       case OBJ_ARRAY:
         V = getArray(&(dictP[N].value));
         if ( V != SCAN_OK ) return(V);
         break;
       case OBJ_INTEGER:
         /* next value in integer */
         dictP[N].value.data.integer = getInt();
         if (rc) return(rc);  /* if next token was not an Int */
         break;
       case OBJ_REAL:
         /* next value must be real or int, store as a real */
         scan_token(inputP);
         if (tokenType == TOKEN_REAL) {
           dictP[N].value.data.real = tokenValue.real;
         }
         else
           if (tokenType == TOKEN_INTEGER) {
             dictP[N].value.data.real = tokenValue.integer;
           }
         else return(SCAN_ERROR);
         break;
       case OBJ_NAME:
         V = getNextValue(TOKEN_LITERAL_NAME);
         if ( V != SCAN_OK ) return(V);
         if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
         objFormatName(&(dictP[N].value),tokenLength,tokenStartP);
         break;
       case OBJ_STRING:
         V = getNextValue(TOKEN_STRING);
         if ( V != SCAN_OK ) return(V);
         if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
         objFormatString(&(dictP[N].value),tokenLength,tokenStartP);
         break;
       case OBJ_BOOLEAN:
         scan_token(inputP);
         if (tokenType != TOKEN_NAME) {
           return(SCAN_ERROR);
         }
         if (0 == strncmp(tokenStartP,"true",4) ) {
           dictP[N].value.data.boolean =TRUE;
         }
         else
           if (0 == strncmp(tokenStartP,"false",5) ) {
             dictP[N].value.data.boolean =FALSE;
           }
           else return(SCAN_ERROR);
         break;
 
       default:
         return(SCAN_ERROR);
         break;
     }
   }
   /* Name is not in dictionary.  That is ok. */
   return(SCAN_OK);
 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int getArray ( psobj arrayP) [static]

Definition at line 424 of file scanfont.c.

{
  int N;   /* count the items in the array */
  psobj *objP;
  
 
  scan_token(inputP);
  if ( (tokenType != TOKEN_LEFT_BRACE) &&
       (tokenType != TOKEN_LEFT_BRACKET) ) {
    return(SCAN_ERROR);
  }
  /* format the array in memory, save pointer to the beginning */
  arrayP->data.valueP = tokenStartP;
  /* loop, picking up next object, until right BRACE or BRACKET */
  N = 0;
  do {
    scan_token(inputP);
    if ( (tokenType == TOKEN_RIGHT_BRACE) ||
         (tokenType == TOKEN_RIGHT_BRACKET) ) {
      /* save then number of items in the array */
      arrayP->len = N;
      return(SCAN_OK);
    }
     /* allocate the space for the object */
    objP = (psobj *)vm_alloc(sizeof(psobj));
    if (!(objP)) return(SCAN_OUT_OF_MEMORY);
 
    /* array is an array of numbers, (real or integer)  */
    if (tokenType == TOKEN_REAL) {
      objFormatReal(objP, tokenValue.real);
    }
    else
      if (tokenType == TOKEN_INTEGER) {
        objFormatInteger(objP, tokenValue.integer);
      }
      else return(SCAN_ERROR);
    N++;
  }  while ( 1>0 );
  /* NOTREACHED*/
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int getEncoding ( psobj arrayP) [static]

Definition at line 310 of file scanfont.c.

{

  scan_token(inputP);
  if ((tokenType == TOKEN_NAME) &&
      ((tokenLength==16) && (!strncmp(tokenStartP,"StandardEncoding",16))) 
      )
    {
      /* Adobe Standard Encoding */

      if (tokenLength == 16)
         arrayP->data.valueP = (char *) StdEncArrayP;
      else
       return(SCAN_ERROR);
      

      arrayP->len = 256;
      return(SCAN_OK);
  }
  else if ( (tokenType == TOKEN_LEFT_BRACE) ||
       (tokenType == TOKEN_LEFT_BRACKET) )
  {
      /* Array of literal names */

      psobj *objP;
      int i;

      objP = (psobj *)vm_alloc(256*(sizeof(psobj)));
      if (!(objP)) return(SCAN_OUT_OF_MEMORY);

      arrayP->data.valueP = (char *) objP;
      arrayP->len = 256;

      for (i=0; i<256; i++, objP++)
      {
         scan_token(inputP);
         
         if (tokenType != TOKEN_LITERAL_NAME)
             return(SCAN_ERROR);

         if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
         objFormatName(objP,tokenLength,tokenStartP);
      }

      scan_token(inputP);
      if ( (tokenType == TOKEN_RIGHT_BRACE) ||
         (tokenType == TOKEN_RIGHT_BRACKET) )
         return(SCAN_OK);
  }
  else
  {
      /* Must be sequences of ``dup <index> <charactername> put" */

      psobj *objP;
      int i;

      objP = (psobj *)vm_alloc(256*(sizeof(psobj)));
      if (!(objP)) return(SCAN_OUT_OF_MEMORY);

      arrayP->data.valueP = (char *) objP;
      arrayP->len = 256;

      for (i=0; i<256; i++)
         objFormatName(objP + i, 7, not_def);

      while (TRUE)
      {
         scan_token(inputP);

         switch (tokenType)
         {
         case TOKEN_NAME:
             if (tokenLength == 3)
             {
                if (strncmp(tokenStartP,"dup",3) == 0)
                {
                    /* get <index> */
                    scan_token(inputP);
                    if (tokenType != TOKEN_INTEGER ||
                       tokenValue.integer < 0 ||
                       tokenValue.integer > 255)
                       return (SCAN_ERROR);
                    i = tokenValue.integer;

                    /* get <characer_name> */
                    scan_token(inputP);
                    if (tokenType != TOKEN_LITERAL_NAME)
                       return(SCAN_ERROR);

                    if (!(vm_alloc(tokenLength)) )
                       return(SCAN_OUT_OF_MEMORY);
                    objFormatName(objP + i,tokenLength,tokenStartP);

                    /* get "put" */
                    scan_token(inputP);
                    if (tokenType != TOKEN_NAME)
                       return(SCAN_ERROR);
                }
                else if (strncmp(tokenStartP,"def",3) == 0)
                    return (SCAN_OK);
             }
             break;
         case TOKEN_EOF:
         case TOKEN_NONE:
         case TOKEN_INVALID:
             return (SCAN_ERROR);
         }
      }
  }

  return (SCAN_ERROR);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int getInt ( void  ) [static]

Definition at line 293 of file scanfont.c.

{
  scan_token(inputP);
  if (tokenType != TOKEN_INTEGER) {
    rc = SCAN_ERROR;
    return(0);
  }
  else {
    return( tokenValue.integer);
  }
 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int getLiteralName ( psobj nameObjP) [static]

Definition at line 506 of file scanfont.c.

{
  do {
    scan_token(inputP);
    if (tokenType <= TOKEN_NONE) {
      if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
      return(SCAN_ERROR);
    }
    if (tokenType == TOKEN_NAME) {
      if (0 == strncmp(tokenStartP,"end",3) ) {
        return(SCAN_END);
      }
    }
  } while  (tokenType != TOKEN_LITERAL_NAME) ;
  nameObjP->len = tokenLength;
  /* allocate all the names in the CharStrings Structure */
  if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
  nameObjP->data.valueP =  tokenStartP;
  /* found */
  return(SCAN_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int getNbytes ( int  N) [static]

Definition at line 485 of file scanfont.c.

{
  int I;
 
  if (N > vm_free_bytes()) {
    if (!vm_init()) return(SCAN_OUT_OF_MEMORY);
  }
  tokenStartP = vm_next_byte();
  I = fread(tokenStartP,1,N,inputP->data.fileP);
  if ( I != N )     return(SCAN_FILE_EOF);
  return(SCAN_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int getNextValue ( int  valueType) [static]

Definition at line 280 of file scanfont.c.

{
  scan_token(inputP);
  if (tokenType != valueType) {
    return(SCAN_ERROR);
  }
  return(SCAN_OK);
 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int GetType1Blues ( psfont fontP) [static]

Definition at line 814 of file scanfont.c.

{
  psdict *PrivateDictP;   /* the Private dict relating to hints */
  struct blues_struct *blues;  /* ptr for the blues struct we will allocate */
  int i;
  psobj *HintEntryP;
 
 
 
  /* get the Private dictionary pointer */
  PrivateDictP = fontP->Private;
 
  /* allocate the memory for the blues structure */
  blues = (struct blues_struct *) vm_alloc(sizeof(struct blues_struct));
 
  if (!blues)  return(SCAN_OUT_OF_MEMORY);
 
  /* Make fontP's blues ptr point to this newly allocated structure. */
  fontP->BluesP = blues;
 
  /* fill in the BlueValues array */
  HintEntryP = &(PrivateDictP[BLUEVALUES].value);
  /* check to see if the entry exists and if it's an array */
  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
      blues->numBlueValues = 0;
  else {
      /* get the number of values in the array */
      if (HintEntryP->len > NUMBLUEVALUES) {
          blues->numBlueValues = NUMBLUEVALUES;
      } else
          blues->numBlueValues = HintEntryP->len;
      for (i = 0; i<= blues->numBlueValues-1; ++i) {
          if (objPIsInteger(&HintEntryP->data.arrayP[i]))
              blues->BlueValues[i] =
                  HintEntryP->data.arrayP[i].data.integer;
          else if (objPIsReal(&HintEntryP->data.arrayP[i]))
              blues->BlueValues[i] =
                  HintEntryP->data.arrayP[i].data.real;
          else
              blues->BlueValues[i] = 0;
      }
  }
 
  /* fill in the OtherBlues array */
  HintEntryP =  &(PrivateDictP[OTHERBLUES].value);
  /* check to see if the entry exists and if it's an array */
  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
      blues->numOtherBlues = 0;
  else {
      /* get the number of values in the array */
      if (HintEntryP->len > NUMOTHERBLUES) {
          blues->numOtherBlues = NUMOTHERBLUES;
      } else
          blues->numOtherBlues = HintEntryP->len;
      for (i = 0; i<= blues->numOtherBlues-1; ++i) {
          if (objPIsInteger(&HintEntryP->data.arrayP[i]))
              blues->OtherBlues[i] =
                  HintEntryP->data.arrayP[i].data.integer;
          else if (objPIsReal(&HintEntryP->data.arrayP[i]))
              blues->OtherBlues[i] =
                  HintEntryP->data.arrayP[i].data.real;
          else
              blues->OtherBlues[i] = 0;
      }
  }
 
  /* fill in the FamilyBlues array */
  HintEntryP =  &(PrivateDictP[FAMILYBLUES].value);
  /* check to see if the entry exists and if it's an array */
  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
      blues->numFamilyBlues = 0;
  else {
      /* get the number of values in the array */
      if (HintEntryP->len > NUMFAMILYBLUES) {
          blues->numFamilyBlues = NUMFAMILYBLUES;
      } else
          blues->numFamilyBlues = HintEntryP->len;
      for (i = 0; i<= blues->numFamilyBlues-1; ++i) {
          if (objPIsInteger(&HintEntryP->data.arrayP[i]))
              blues->FamilyBlues[i] =
                  HintEntryP->data.arrayP[i].data.integer;
          else if (objPIsReal(&HintEntryP->data.arrayP[i]))
              blues->FamilyBlues[i] =
                  HintEntryP->data.arrayP[i].data.real;
          else
              blues->FamilyBlues[i] = 0;
      }
  }
 
  /* fill in the FamilyOtherBlues array */
  HintEntryP =  &(PrivateDictP[FAMILYOTHERBLUES].value);
  /* check to see if the entry exists and if it's an array */
  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
      blues->numFamilyOtherBlues = 0;
  else {
      /* get the number of values in the array */
      if (HintEntryP->len > NUMFAMILYOTHERBLUES) {
          blues->numFamilyOtherBlues = NUMFAMILYOTHERBLUES;
      } else
          blues->numFamilyOtherBlues = HintEntryP->len;
      for (i = 0; i<= blues->numFamilyOtherBlues-1; ++i) {
          if (objPIsInteger(&HintEntryP->data.arrayP[i]))
              blues->FamilyOtherBlues[i] =
                  HintEntryP->data.arrayP[i].data.integer;
          else if (objPIsReal(&HintEntryP->data.arrayP[i]))
              blues->FamilyOtherBlues[i] =
                  HintEntryP->data.arrayP[i].data.real;
          else
              blues->FamilyOtherBlues[i] = 0;
      }
  }
 
  /* fill in the StemSnapH array */
  HintEntryP =  &(PrivateDictP[STEMSNAPH].value);
  /* check to see if the entry exists and if it's an array */
  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
      blues->numStemSnapH = 0;
  else {
      /* get the number of values in the array */
      if (HintEntryP->len > NUMSTEMSNAPH) {
          blues->numStemSnapH = NUMSTEMSNAPH;
      } else
          blues->numStemSnapH = HintEntryP->len;
      for (i = 0; i<= blues->numStemSnapH-1; ++i) {
          if (objPIsInteger(&HintEntryP->data.arrayP[i]))
              blues->StemSnapH[i] =
                  HintEntryP->data.arrayP[i].data.integer;
          else if (objPIsReal(&HintEntryP->data.arrayP[i]))
              blues->StemSnapH[i] =
                  HintEntryP->data.arrayP[i].data.real;
          else
              blues->StemSnapH[i] = 0;
      }
  }
 
  /* fill in the StemSnapV array */
  HintEntryP =  &(PrivateDictP[STEMSNAPV].value);
  /* check to see if the entry exists and if it's an array */
  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
      blues->numStemSnapV = 0;
  else {
      /* get the number of values in the array */
      if (HintEntryP->len > NUMSTEMSNAPV) {
          blues->numStemSnapV = NUMSTEMSNAPV;
      } else
          blues->numStemSnapV = HintEntryP->len;
      for (i = 0; i<= blues->numStemSnapV-1; ++i) {
          if (objPIsInteger(&HintEntryP->data.arrayP[i]))
              blues->StemSnapV[i] =
                  HintEntryP->data.arrayP[i].data.integer;
          else if (objPIsReal(&HintEntryP->data.arrayP[i]))
              blues->StemSnapV[i] =
                  HintEntryP->data.arrayP[i].data.real;
          else
              blues->StemSnapV[i] = 0;
      }
  }
 
  /* fill in the StdVW array */
  HintEntryP =  &(PrivateDictP[STDVW].value);
  /* check to see if the entry exists and if it's an array */
  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
      /* a value of zero signifies no entry */
      blues->StdVW = 0.0;
  else {
      if (HintEntryP->len > NUMSTDVW) {
      }
      if (objPIsInteger(&HintEntryP->data.arrayP[0]))
          blues->StdVW = HintEntryP->data.arrayP[0].data.integer;
      else if (objPIsReal(&HintEntryP->data.arrayP[0]))
          blues->StdVW = HintEntryP->data.arrayP[0].data.real;
      else
          blues->StdVW = 0.0;
  }
 
  /* fill in the StdHW array */
  HintEntryP =  &(PrivateDictP[STDHW].value);
  /* check to see if the entry exists and if it's an array */
  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
      /* a value of zero signifies no entry */
      blues->StdHW = 0;
  else {
      if (HintEntryP->len > NUMSTDHW) {
      }
          if (objPIsInteger(&HintEntryP->data.arrayP[0]))
             blues->StdHW = HintEntryP->data.arrayP[0].data.integer;
          else if (objPIsReal(&HintEntryP->data.arrayP[0]))
             blues->StdHW = HintEntryP->data.arrayP[0].data.real;
          else
             blues->StdHW = 0;
  }
 
 
  /* get the ptr to the BlueScale entry */
  HintEntryP =  &(PrivateDictP[BLUESCALE].value);
  /* put the BlueScale in the blues structure */
  if (objPIsInteger(HintEntryP)) /* Must be integer! */
      blues->BlueScale = HintEntryP->data.integer;
  else if (objPIsReal(HintEntryP)) /* Error? */
      blues->BlueScale = HintEntryP->data.real;
  else
      blues->BlueScale = DEFAULTBLUESCALE;
 
  /* get the ptr to the BlueShift entry */
  HintEntryP =  &(PrivateDictP[BLUESHIFT].value);
  if (objPIsInteger(HintEntryP)) /* Must be integer! */
      blues->BlueShift = HintEntryP->data.integer;
  else if (objPIsReal(HintEntryP)) /* Error? */
      blues->BlueShift = HintEntryP->data.real;
  else
      blues->BlueShift = DEFAULTBLUESHIFT;
 
  /* get the ptr to the BlueFuzz entry */
  HintEntryP =  &(PrivateDictP[BLUEFUZZ].value);
  if (objPIsInteger(HintEntryP)) /* Must be integer! */
      blues->BlueFuzz = HintEntryP->data.integer;
  else if (objPIsReal(HintEntryP)) /* Error? */
      blues->BlueFuzz = HintEntryP->data.real;
  else
      blues->BlueFuzz = DEFAULTBLUEFUZZ;
 
  /* get the ptr to the ForceBold entry */
  HintEntryP =  &(PrivateDictP[FORCEBOLD].value);
  if (objPIsBoolean(HintEntryP))  /* Must be integer! */
      blues->ForceBold = HintEntryP->data.boolean;
  else
      blues->ForceBold = DEFAULTFORCEBOLD;
 
  /* get the ptr to the LanguageGroup entry */
  HintEntryP =  &(PrivateDictP[LANGUAGEGROUP].value);
  if (objPIsInteger(HintEntryP)) /* Must be integer! */
      blues->LanguageGroup = HintEntryP->data.integer;
  else
      blues->LanguageGroup = DEFAULTLANGUAGEGROUP;
 
  /* get the ptr to the RndStemUp entry */
  HintEntryP =  &(PrivateDictP[RNDSTEMUP].value);
  if (objPIsBoolean(HintEntryP)) /* Must be integer! */
      blues->RndStemUp = HintEntryP->data.boolean;
  else
      blues->RndStemUp = DEFAULTRNDSTEMUP;
 
  /* get the ptr to the lenIV entry */
  HintEntryP =  &(PrivateDictP[LENIV].value);
  if (objPIsInteger(HintEntryP)) {/* Must be integer! */
    blues->lenIV = HintEntryP->data.integer;
  }
  else{
    blues->lenIV = DEFAULTLENIV;
  }
  
 
  /* get the ptr to the ExpansionFactor entry */
  HintEntryP =  &(PrivateDictP[EXPANSIONFACTOR].value);
  if (objPIsInteger(HintEntryP))
      blues->ExpansionFactor = HintEntryP->data.integer;
  else if (objPIsReal(HintEntryP))
      blues->ExpansionFactor = HintEntryP->data.real;
  else
      blues->ExpansionFactor = DEFAULTEXPANSIONFACTOR;
  return(SCAN_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

psobj* GetType1CharString ( psfont fontP,
unsigned char  code 
) [read]

Definition at line 1087 of file scanfont.c.

{
  int  N;           /* the 'Nth' entry in the CharStrings       */
  psobj *charnameP; /* points to psobj that is name of character*/
 
  psdict *CharStringsDictP; /* dictionary with char strings     */
  psobj  *theStringP;  /* the definition for the code */
  
  
  if (StdEncArrayP == NULL) {
    return(NULL);
  }
  /* use the code to index into the standard encoding vector  */
  charnameP = &(StdEncArrayP[code]);
  
  /* test if the encoding array points to a name */
  if (!(objPIsName(charnameP)) ) {
    return(NULL);
  }

  /* Now that we have the character name out of the standardencoding */
  /* get the character definition out of the current font */
  CharStringsDictP =  fontP->CharStringsP;
 
  /* search the chars string for this charname as key */
  N = SearchDictName(CharStringsDictP,charnameP);
  if (N<=0) {
    return(NULL);
  }

  /* OK, the nth item is the psobj that is the string for this char */
  theStringP = &(CharStringsDictP[N].value);
 
  return(theStringP);
}

Definition at line 269 of file scanfont.c.

{
  StdEncArrayP = MakeEncodingArrayP(StdEnc);
  if (StdEncArrayP==NULL)
    return( FALSE);
  else
    return( TRUE);
}
static psobj* MakeEncodingArrayP ( EncodingTable encodingTable) [static]

Definition at line 245 of file scanfont.c.

{
  int i;
  psobj *encodingArrayP;
 
  encodingArrayP = (psobj *)malloc(256*(sizeof(psobj)));
  if (!encodingArrayP)
      return NULL;

  /* initialize everything to .notdef */
  for (i=0; i<256;i++)
      objFormatName(&(encodingArrayP[i]),7, not_def);

  for (i=0; encodingTable[i].name; i++)
  {
    objFormatName(&(encodingArrayP[encodingTable[i].index]),
                strlen(encodingTable[i].name),
                encodingTable[i].name);
  }

  return(encodingArrayP);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void objFormatArray ( psobj objP,
int  length,
psobj valueP 
)

Definition at line 159 of file util.c.

{
  if (objP != NULL) {
    objP->type        = OBJ_ARRAY;
    objP->len         = length;
    objP->data.arrayP = valueP;
  }
}

Here is the caller graph for this function:

void objFormatBoolean ( psobj objP,
boolean  value 
)

Definition at line 135 of file util.c.

{
  if (objP != NULL) {
    objP->type         = OBJ_BOOLEAN;
    objP->len          = 0;
    objP->data.boolean = value;
  }
}

Here is the caller graph for this function:

void objFormatEncoding ( psobj objP,
int  length,
psobj valueP 
)

Definition at line 147 of file util.c.

{
  if (objP != NULL) {
    objP->type        = OBJ_ENCODING;
    objP->len         = length;
    objP->data.arrayP = valueP;
  }
}

Here is the caller graph for this function:

void objFormatFile ( psobj objP,
FILE valueP 
)

Definition at line 196 of file util.c.

{
  if (objP != NULL) {
    objP->type         = OBJ_FILE;
    objP->len          = 0;
    objP->data.fileP   = valueP;
  }
}

Here is the caller graph for this function:

void objFormatInteger ( psobj objP,
int  value 
)

Definition at line 111 of file util.c.

{
  if (objP != NULL) {
    objP->type         = OBJ_INTEGER;
    objP->len          = 0;
    objP->data.integer = value;
  }
}

Here is the caller graph for this function:

void objFormatName ( psobj objP,
int  length,
char *  valueP 
)

Definition at line 184 of file util.c.

{
  if (objP != NULL) {
    objP->type         = OBJ_NAME;
    objP->len          = length;
    objP->data.nameP   = valueP;
  }
}
void objFormatReal ( psobj objP,
float  value 
)

Definition at line 123 of file util.c.

{
  if (objP != NULL) {
    objP->type       = OBJ_REAL;
    objP->len        = 0;
    objP->data.real  = value;
  }
}

Here is the caller graph for this function:

void objFormatString ( psobj objP,
int  length,
char *  valueP 
)

Definition at line 172 of file util.c.

{
  if (objP != NULL) {
    objP->type         = OBJ_STRING;
    objP->len          = length;
    objP->data.valueP  = valueP;
  }
}

Here is the caller graph for this function:

int scan_font ( psfont FontP)

Definition at line 1216 of file scanfont.c.

{
 
 
  char   filename[MAXPATHLEN];
  FILE   *fileP;
  char   *nameP;
  int    namelen;
 
    /* copy the filename and remove leading or trailing blanks */
    /* point to name and search for leading blanks */
    nameP= FontP->FontFileName.data.nameP;
    namelen  = FontP->FontFileName.len;
    while (nameP[0] == ' ') {
        nameP++;
        namelen--;
    }
    /* now remove any trailing blanks */
    while ((namelen>0) && ( nameP[namelen-1] == ' ')) {
      namelen--;
    }
    if ( namelen >= MAXPATHLEN ) {
      /* Hopefully, this will lead to a file open error */
      namelen = MAXPATHLEN - 1; /* - 1 added by SU */
    }
    strncpy(filename,nameP,namelen);
    filename[namelen] = '\0';
    /* file name is now constructed */
    inputFile.data.fileP = NULL;
    filterFile.data.fileP = NULL;
 
    inputP = &inputFile;
    if ((fileP = fopen(filename,"rb"))!=NULL) {
      objFormatFile(inputP,fileP);
    }
    else {
      return(SCAN_FILE_OPEN_ERROR);
    };
 
  WantFontInfo  = TRUE;
  InPrivateDict = FALSE;
  TwoSubrs      = FALSE;
  rc = BuildFontInfo(FontP);
#ifdef DEBUG_SCANFONT
  printf("BuildFontInfo(): retval=%d\n", rc);
#endif
  if (rc != 0) return(rc);
 
  /* Assume everything will be OK */
  rc       = 0;
 
  /* Loop until complete font is read  */
  do {
    /* Scan the next token */
    scan_token(inputP);

    /* ==> tokenLength, tokenTooLong, tokenType, and tokenValue are */
    /* now set */
 
    switch (tokenType) {
      case TOKEN_EOF:
      case TOKEN_NONE:
      case TOKEN_INVALID:
        /* in this case we are done */
        if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
        rc = SCAN_ERROR;
        break;
      case TOKEN_LITERAL_NAME:
            /* Look up the name */
            tokenStartP[tokenLength] = '\0';
           /* At this point we check for the font not being a
              Multiple Master Font. If it is, we return an error.
              (RMz, 01/29/1999) */
           if (strncmp(tokenStartP, "BlendAxisTypes", 14)==0){
             rc=SCAN_MMFONT;
             break;
           }
            if (InPrivateDict ) {
              if (0== strncmp(tokenStartP,"Subrs",5) ) {
                rc = BuildSubrs(FontP);
#ifdef DEBUG_SCANFONT
              printf("BuildSubrs(): retval=%d\n", rc);
#endif
                break;
              }
              if (0== strncmp(tokenStartP,"CharStrings",11) ) {
                rc = BuildCharStrings(FontP);
#ifdef DEBUG_SCANFONT
              printf("BuildCharstrings(): retval=%d\n", rc);
#endif
                if ( (rc == SCAN_OK) ||(rc == SCAN_END) ) {
                  fclose(inputP->data.fileP);
                  /* Build the Blues Structure */
                rc = GetType1Blues(FontP);
#ifdef DEBUG_SCANFONT
                printf("GetType1Blues(): retval=%d\n", rc);
#endif
                  /* whatever the return code, return it */
                  /* all the work is done. This is the normal exit.*/
                  return(rc);
                }
                break;
              }
              rc = FindDictValue(FontP->Private);
              /* we are not going to report errors */
              /* Sometimes the font file may test a value such as */
              /* testing to see if the font is alreadly loaded with */
              /* same UniqueID.  We would faile on /UniqueID get  */
              /* because we are expecting a int to follow UniqueID*/
              /* If the correct object type does not follow a Name*/
              /* then we will skip over it without reporting error*/
              rc = SCAN_OK;
              break;
            }   /* end of reading Private dictionary */
            else
              if (0== strncmp(tokenStartP,"Private",7) ) {
                InPrivateDict = TRUE;
                rc = BuildPrivate(FontP);
                break;
              }
              else
                if (WantFontInfo) {
                  rc = FindDictValue(FontP->fontInfoP);
                  /* we are not going to report errors */
                  rc = SCAN_OK;
                  break;
                }
        break;
      case TOKEN_NAME:
            if (0 == strncmp(tokenStartP,"eexec",5) ) {
             /* We check for the pfb-headers in I/O-module */ 
             filterFile.data.fileP = T1eexec(inputP->data.fileP);
             if (filterFile.data.fileP == NULL) {
              fclose(inputFile.data.fileP);
              /* SCAN_FILE_OPEN_ERROR replaced because at this point
                 a portion of the file has already been read successfully.
                 We hence have encountered a premature end of file
                 (2002-08-17, RMz). */
              return SCAN_FILE_EOF;
             }
             inputP = &filterFile;
             
             WantFontInfo = FALSE;
            }
        break;
    }
 
  }
  while (rc ==0);
  fclose(inputP->data.fileP);
  if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
  return(rc);
}
int SearchDictName ( psdict dictP,
psobj keyP 
)

Definition at line 132 of file fontfcn.c.

{
  int i,n;
 
 
  n =  dictP[0].key.len;
  for (i=1;i<=n;i++) {          /* scan the intire dictionary */
    if (
        (dictP[i].key.len  == keyP->len )
        &&
        (strncmp(dictP[i].key.data.valueP,
                 keyP->data.valueP,
                 keyP->len) == 0
        )
       ) return(i);
  }
  return(0);
}
int T1Getc ( F_FILE )

Definition at line 134 of file t1io.c.

{
  if (f->b_base == NULL) return EOF;  /* already closed */
 
  if (f->flags & UNGOTTENC) { /* there is an ungotten c */
    f->flags &= ~UNGOTTENC;
    return (int) f->ungotc;
  }
 
  if (f->b_cnt == 0)  /* Buffer needs to be (re)filled */
    f->b_cnt = T1Fill(f);
  if (f->b_cnt > 0) return (f->b_cnt--, (int) *(f->b_ptr++));
  else {
    f->flags |= FIOEOF;
    return EOF;
  }
} /* end Getc */

Here is the caller graph for this function:

void T1io_setblocklen ( long  len)
int T1Ungetc ( int  ,
F_FILE  
)

Definition at line 337 of file t1io.c.

{
  if (c != EOF) {
    f->ungotc = c;
    f->flags |= UNGOTTENC;  /* set flag */
    f->flags &= ~FIOEOF;    /* reset EOF */
  }
  return c;
} /* end Ungetc */

Here is the caller graph for this function:


Variable Documentation

psobj filterFile [static]

Definition at line 49 of file scanfont.c.

Definition at line 45 of file scanfont.c.

psobj inputFile [static]

Definition at line 48 of file scanfont.c.

psobj* inputP [static]

Definition at line 50 of file scanfont.c.

char not_def[] = ".notdef"

Definition at line 83 of file scanfont.c.

int rc [static]

Definition at line 44 of file scanfont.c.

EncodingTable StdEnc[] [static]

Definition at line 86 of file scanfont.c.

Definition at line 242 of file scanfont.c.

boolean TwoSubrs [static]

Definition at line 47 of file scanfont.c.

Definition at line 46 of file scanfont.c.