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

📄 fontfcn.c

📁 source code: Covert TXT to PDF
💻 C
📖 第 1 页 / 共 3 页
字号:
	return(NULL);      }    }    theStringP = &(CharStringsDictP[N].value);    tmppath1=(struct segment *)ILoc(S,				    pAFMData->ccd[i].pieces[j].deltax,				    pAFMData->ccd[i].pieces[j].deltay);        strncpy( (char *)CurCharName, (char *)charnameP->data.stringP, charnameP->len);    CurCharName[charnameP->len]='\0';    charpath=(struct segment *)Type1Char(FontP,S,theStringP,SubrsArrayP,NULL,					 FontP->BluesP,mode,CurCharName);    /* return if Type1Char reports an error */    if ( *mode == FF_PARSE_ERROR || *mode==FF_PATH_ERROR)      return(NULL);    /* get escapement of current symbol */    currdisp=getDisplacement( charpath);    /* concat displacement and symbol path */    charpath=(struct segment *)Join(tmppath1,charpath);    /* for composite symbols we have to step back the char escapement.       this is, in order to be able to use accents that cause a       non zero displacement of the current point! We further have to       step back the displacement from composite char data. */    tmppath1=(struct segment *)t1_PathSegment( MOVETYPE, -currdisp.x, -currdisp.y);    tmppath3=(struct segment *)ILoc(S,				    -pAFMData->ccd[i].pieces[j].deltax,				    -pAFMData->ccd[i].pieces[j].deltay);    tmppath3=(struct segment *)Join(tmppath1,tmppath3);    /* create path, or, respectively, append to existing path */    if (tmppath4==NULL) {      tmppath4=(struct segment *)Join(charpath,tmppath3);    }    else {      charpath=(struct segment *)Join(charpath,tmppath3);      tmppath4=(struct segment *)Join(tmppath4,charpath);    }  }  /* concat composite symbols and base char */  if (tmppath4==NULL) { /* no previous composite symbols */    charpath=tmppath2; /* a simple char */  }  else {     charpath=(struct segment *)Join(tmppath4,tmppath2);  }      if (do_raster) {     /* fill with winding rule unless path was requested */    if (*mode != FF_PATH) {      charpath =  (struct segment *)Interior(charpath,WINDINGRULE+CONTINUITY);    }  }  if (*mode==0)    *mode=localmode;    return((xobject) charpath);}/***================================================================***//*   fontfcnA(env, mode)                                              *//*                                                                    *//*          env is a pointer to a string that contains the fontname.  *//*                                                                    *//*     1) initialize the font     - global indicates it has been done *//*     2) load the font                                               *//*                                                                    *//* This function has been modified by RMz. It now takes a pointer which   already contains the address of a valid type1 font structure as the   third argument. The value of this pointer is first handed to FontP   so that most other routines may be used without changes */#define MAXTRIAL              4/***================================================================***/Bool fontfcnA(env,mode,Font_Ptr)char *env;int  *mode;psfont *Font_Ptr;{  int i, result;    /* set the global font pointer to the address of already allocated     structure */  FontP=Font_Ptr;  InitImager();  /* Read the font program. */  for (i=1; i<MAXTRIAL; i++){    vm_init_count=0;    /* We allocate larger chunks (4*65536 Bytes) in order to reduce load       time for large fonts by initially requesting somewhat more       memory. */    vm_init_amount=MAX_STRING_LEN * 4 * i;    if (!(initFont())) {      /* we are really out of memory, not simulated! */      *mode = SCAN_OUT_OF_MEMORY;      return(FALSE);    }    /* Try to read font into memory */    if ((result=readFont(env))==0){      /* In order to get the amount of memory that was really used */            vm_used=vm_next_byte();      return(TRUE);    }    else{      /* VM did not suffice, free it and try again with larger	 value: */      free(vm_base);    }  }  /* Font could not be loaded: */  *mode = result;  return(FALSE);}/***================================================================***//*   QueryFontLib(env, infoName,infoValue,rcodeP)                     *//*                                                                    *//*          env is a pointer to a string that contains the fontname.  *//*                                                                    *//*     1) initialize the font     - global indicates it has been done *//*     2) load the font                                               *//*     3) use the font to call getInfo for that value.                *//***================================================================***/void QueryFontLib(env,infoName,infoValue,rcodeP)char *env;char *infoName;pointer infoValue;    /* parameter returned here    */int  *rcodeP;{  int rc,N,i;  psdict *dictP;  psobj  nameObj;  psobj  *valueP;   /* Has the FontP initialized?  If not, then   */  /* Initialize  */  if (FontP == NULL) {    InitImager();    if (!(initFont())) {      *rcodeP = 1;      return;    }  }  /* if the env is null, then use font already loaded */  /* if the not same font name, reset and load next font */  if ( (env) && (strcmp(env,CurFontName) != 0 ) ) {    /* restore the virtual memory and eliminate old font */    rc = readFont(env);    if (rc != 0 ) {      strcpy(CurFontName, "");    /* no font loaded */      *rcodeP = 1;      return;    }  }  dictP = FontP->fontInfoP;  objFormatName(&nameObj,strlen(infoName),infoName);  N = SearchDictName(dictP,&nameObj);  /* if found */  if ( N > 0 ) {    *rcodeP = 0;    switch (dictP[N].value.type) {       case OBJ_ARRAY:         valueP = dictP[N].value.data.arrayP;         if (strcmp(infoName,"FontMatrix") == 0) {           /* 6 elments, return them as floats      */           for (i=0;i<6;i++) {             if (valueP->type == OBJ_INTEGER )               ((float *)infoValue)[i] = valueP->data.integer;             else               ((float *)infoValue)[i] = valueP->data.real;            valueP++;           }         }         if (strcmp(infoName,"FontBBox") == 0) {           /* 4 elments for Bounding Box.  all integers   */           for (i=0;i<4;i++) {             ((int *)infoValue)[i] = valueP->data.integer;             valueP++;           }         break;       case OBJ_INTEGER:       case OBJ_BOOLEAN:         *((int *)infoValue) = dictP[N].value.data.integer;         break;       case OBJ_REAL:         *((float *)infoValue) = dictP[N].value.data.real;         break;       case OBJ_NAME:       case OBJ_STRING:         *((char **)infoValue) =  dictP[N].value.data.valueP;         break;       default:         *rcodeP = 1;         break;     }   }  }  else *rcodeP = 1;}/***================================================================***//* RMz: instead of code, which is a character pointer to the name        of the character, we use "ev" which is a pointer to a desired	encoding vector (or NULL if font-internal encoding should be	used) and "index" as an index into the desired encoding vector!	The user thus has the opportunity of supplying whatever encoding	he wants. Font_Ptr is the pointer to the local psfont-structure. 	*/xobject fontfcnB_string( int FontID, int modflag,			 struct XYspace *S, char **ev,			 unsigned char *string, int no_chars,			 int *mode, psfont *Font_Ptr,			 int *kern_pairs, long spacewidth,			 int do_raster){   psobj *charnameP; /* points to psobj that is name of character*/  FontInfo *pAFMData=NULL;  int i=-1;  int j=0;  int k=0;  long acc_width=0;  int numPieces=1;  int N;  T1_PATHPOINT currdisp;  int basechar;    psdict *CharStringsDictP; /* dictionary with char strings     */  psobj   CodeName;   /* used to store the translation of the name*/  psobj  *SubrsArrayP;  psobj  *theStringP;  int localmode=0;    struct segment *charpath=NULL;   /* the path for this character   */             struct segment *tmppath1=NULL;  struct segment *tmppath2=NULL;  struct segment *tmppath3=NULL;  struct segment *tmppath4=NULL;  struct segment *tmppath5=NULL;       /* set the global font pointer to the address of already allocated     structure and setup pointers*/  FontP=Font_Ptr;  CharStringsDictP =  FontP->CharStringsP;  SubrsArrayP = &(FontP->Subrs);  charnameP = &CodeName;    /* In the following for-loop, all characters are processed, one after     the other. Between them, the amount of kerning is inserted.     The number of path variables used is somewhat numerous. We use the     follwing conventions:     charpath:  the overall path of the string.     tmppath5:  the overall path of one component (possibly a composite symbol)     tmppath2:  the path of a simple char or base char of a composite     tmppath4:  the path of all "accents" of a composite symbol  */  for (k=0; k<no_chars;k++) {    if (ev==NULL){  /* font-internal encoding should be used */      charnameP = &CodeName;      charnameP->len = FontP->fontInfoP[ENCODING].value.data.arrayP[string[k]].len;      charnameP->data.stringP = (unsigned char *) FontP->fontInfoP[ENCODING].value.data.arrayP[string[k]].data.arrayP;    }    else {           /* some user-supplied encoding is to be used */      charnameP = &CodeName;      charnameP->len = strlen(ev[string[k]]);      charnameP->data.stringP = (unsigned char*) ev[string[k]];    }        /* Spacing is to be under users control: => if space is the charname, don't       raster it. Rather, generate a horizontal movement of spacewidth: */    if (strcmp((char *)charnameP->data.stringP, "space")==0){      tmppath5=(struct segment *)ILoc(S, spacewidth,0);      acc_width += spacewidth;    }    else {      /* here a character or composite character is to be constructed */      strncpy( (char *)CurCharName, (char *)charnameP->data.stringP, charnameP->len);      CurCharName[charnameP->len]='\0';            /* search the CharString for this charname as key */      basechar = SearchDictName(CharStringsDictP,charnameP);      if (basechar<=0) {	/* Check first, whether a char in question is a composite char */	if ((i=isCompositeChar( FontID, CurCharName))>-1) {	  /* i is now the index of the composite char definitions	     (starting at 0). At this point it is clear that AFM-info	     must be present -> fetch first component of composite char. */	  pAFMData=pFontBase->pFontArray[FontID].pAFMData;	  charnameP->len=strlen( pAFMData->ccd[i].pieces[0].pccName);	  charnameP->data.stringP=(unsigned char*)pAFMData->ccd[i].pieces[0].pccName;	  numPieces=pAFMData->ccd[i].numOfPieces;	  	  if ((basechar=SearchDictName(CharStringsDictP,charnameP))<=0) {	    /* this is bad, AFM-file and font file do not match. This 	       will most probably lead to errors or inconsistencies later.	       However, we substitute .notdef and inform the user via	       logfile and T1_errno. */	    sprintf( err_warn_msg_buf,		     "Charstring \"%s\" needed to construct composite char \"%s\" not defined (FontID=%d)",		     pAFMData->ccd[i].pieces[0].pccName,		     pAFMData->ccd[i].ccName, FontID);	    T1_PrintLog( "fontfcnB():", err_warn_msg_buf, T1LOG_WARNING);	    T1_errno=T1ERR_COMPOSITE_CHAR;	  }	}      }            if (basechar<=0) { /* This  means the requested char is unknown or the			    base char of a composite is not found ->			    we substitute .notdef */	charnameP = &CodeName;	charnameP->len = 7;	charnameP->data.stringP = (unsigned char *) notdef;	basechar = SearchDictName(CharStringsDictP,charnameP);	localmode=FF_NOTDEF_SUBST;	/* Font must be completely damaged if it doesn't define a .notdef */	if (basechar<=0) {	  *mode=FF_PARSE_ERROR;	  return(NULL);	}      } /* if (basechar<=0) */      /* basechar is now the index of the base character in the CharStrings	 dictionary */            /* we provide the Type1Char() procedure with the name of the character	 to rasterize for debugging purposes */      strncpy( (char *)CurCharName, (char *)charnameP->data.stringP, charnameP->len);      CurCharName[charnameP->len]='\0';      /* get CharString and character path */      theStringP = &(CharStringsDictP[basechar].value);      tmppath2 = (struct segment *) Type1Char(FontP,S,theStringP,SubrsArrayP,NULL,					      FontP->BluesP,mode,CurCharName);      strcpy( BaseCharName, CurCharName);      /* if Type1Char reports an error, clean up and return */      if ( *mode == FF_PARSE_ERROR || *mode==FF_PATH_ERROR) {	if (charpath!=NULL) {	  KillPath( charpath);	}	if (tmppath1!=NULL) {	  KillPath( tmppath1);	}	if (tmppath2!=NULL) {	  KillPath( tmppath2);	}	if (tmppath3!=NULL) {	  KillPath( tmppath3);	}	if (tmppath4!=NULL) {	  KillPath( tmppath4);	}	if (tmppath5!=NULL) {	  KillPath( tmppath5);	}

⌨️ 快捷键说明

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