⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scanfont.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 3 页
字号:
  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;  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;  }   /* 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);}/**********************************************************************//*   GetType1CharString(fontP,code)                                   *//*                                                                    *//*          Look up code in the standard encoding vector and return   *//*          the charstring associated with the character name.        *//*                                                                    *//*   fontP  is the psfont structure.                                  *//*                                                                    *//*   Returns a psobj (string)                                         *//**********************************************************************/psobj *GetType1CharString(fontP, code)psfont *fontP;unsigned char code;{  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);} /***================================================================***//* *   FindDictValue *//***================================================================***/ static int FindDictValue(dictP)    psdict    *dictP;{   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);     }   }   /* Name is not in dictionary.  That is ok. */   return(SCAN_OK); }/***================================================================***/ /* * ------------------------------------------------------------------- *  Scan the next token and convert it into an object *  Result is placed on the Operand Stack as next object * ------------------------------------------------------------------- */int scan_font(FontP)  psfont *FontP;{    char   filename[128];  char   filetype[3];  FILE   *fileP;  char   *nameP;  int    namelen;  int    V;  int    i;  boolean starthex80;     starthex80 = FALSE;    filetype[0] = 'r';    filetype[1] = 'b';    filetype[2] = '\0';    /* 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--;    }    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,filetype)) {      /* get the first byte of file */      V = getc(fileP);      /* if file starts with x'80' then skip next 5 bytes */      if ( V == 0X80 ) {        for (i=0;i<5;i++) V = getc(fileP);        starthex80 = TRUE;      }      else ungetc(V,fileP);      objFormatFile(inputP,fileP);    }    else {      return(SCAN_FILE_OPEN_ERROR);    };   WantFontInfo  = TRUE;  InPrivateDict = FALSE;  TwoSubrs      = FALSE;  rc = BuildFontInfo(FontP);  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';            if (InPrivateDict ) {              if (0== strncmp(tokenStartP,"Subrs",5) ) {                rc = BuildSubrs(FontP);                break;              }              if (0== strncmp(tokenStartP,"CharStrings",11) ) {                rc = BuildCharStrings(FontP);                if ( (rc == SCAN_OK) ||(rc == SCAN_END) ) {                  fclose(inputP->data.fileP);                  /* Build the Blues Structure */                  rc = GetType1Blues(FontP);                  /* 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) ) {               /* if file started with x'80', check next 5 bytes */               if (starthex80) {                 V = getc(fileP);                 if ( V == 0X80 ) {                   for (i=0;i<5;i++) V = getc(fileP);                 }                 else ungetc(V,fileP);               }               filterFile.data.fileP = T1eexec(inputP->data.fileP);               if (filterFile.data.fileP == NULL) {                 fclose(inputFile.data.fileP);                 return(SCAN_FILE_OPEN_ERROR);               }               inputP = &filterFile;                WantFontInfo = FALSE;            }        break;    }   }  while (rc ==0);  fclose(inputP->data.fileP);  if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);  return(rc);} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -