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

📄 fontfcn.c

📁 source code: Covert TXT to PDF
💻 C
📖 第 1 页 / 共 3 页
字号:
	return(NULL);      }	      /* Defer rastering to later, we first have to handle the composite	 symbols */      for (j=1; j<numPieces; j++) {	/* get composite symbol name */	charnameP->len=strlen( pAFMData->ccd[i].pieces[j].pccName);	charnameP->data.stringP=(unsigned char*)pAFMData->ccd[i].pieces[j].pccName;	/* get CharString definition */	if ((N=SearchDictName(CharStringsDictP,charnameP))<=0) {	  /* handling of errors, see comments above ... */	  sprintf( err_warn_msg_buf,		   "Charstring \"%s\" needed to construct composite char \"%s\" not defined (FontID=%d)",		   pAFMData->ccd[i].pieces[j].pccName,		   pAFMData->ccd[i].ccName, FontID);	  T1_PrintLog( "fontfcnB():", err_warn_msg_buf, T1LOG_WARNING);	  charnameP = &CodeName;	  charnameP->len = 7;	  charnameP->data.stringP = (unsigned char *) notdef;	  N = SearchDictName(CharStringsDictP,charnameP);	  localmode=FF_NOTDEF_SUBST;	  /* an undefined .notdef is fatal -> clean up and return */	  if (N<=0) {	    *mode=FF_PARSE_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);	    }	    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';	tmppath5=(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( tmppath5);	/* concat displacement and symbol path */	tmppath5=(struct segment *)Join(tmppath1,tmppath5);	/* 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(tmppath5,tmppath3);	}	else {	  tmppath5=(struct segment *)Join(tmppath5,tmppath3);	  tmppath4=(struct segment *)Join(tmppath4,tmppath5);	}      }            /* concat composite symbols and base char. We use tmppath5 to store	 the path of the resulting (possibly composite) character. */      if (tmppath4==NULL) { /* no previous composite symbols */	tmppath5=tmppath2; /* a simple char */      }      else { 	tmppath5=(struct segment *)Join(tmppath4,tmppath2);      }            /* Accumulate displacement, but be careful: In case of composite	 characters, we have to take the escapement of the base char only	 into account, because accents do not cause spacing. The path is	 constructed in a way that this automatically matches.      */      if (numPieces>1) { /* composite character */	acc_width +=pFontBase->pFontArray[FontID].pAFMData->ccd[-(pFontBase->pFontArray[FontID].pEncMap[string[k]]+1)].wx;      }      else { /* ordinary character */	acc_width +=pFontBase->pFontArray[FontID].pAFMData->cmi[pFontBase->pFontArray[FontID].pEncMap[string[k]]-1].wx;      }          } /* else (if (char==space) */    /* character path is now stored in tmppath5. It may be a composite character.       Insert kerning amount, if it is not the last character of the string. */    if (k<no_chars-1){      tmppath2=(struct segment *)ILoc(S,kern_pairs[k],0);       tmppath5=(struct segment *)Join(tmppath5,tmppath2);      acc_width += kern_pairs[k];    }    if (charpath!=NULL){      charpath=(struct segment *)Join(charpath,tmppath5);    }    else{      charpath=(struct segment *)tmppath5;    }    /* reset the temporary paths so that constructing composite       characters wiil continue to work properly in the next interation. */    tmppath1=NULL;    tmppath2=NULL;    tmppath3=NULL;    tmppath4=NULL;    tmppath5=NULL;    /* reset composition parameters */    i=-1;    numPieces=1;      } /* for (k<no_chars) */      /* Take care for underlining and such */  if (modflag & T1_UNDERLINE){    tmppath2=(struct segment *)Type1Line(FontP,S,					 pFontBase->pFontArray[FontID].UndrLnPos,					 pFontBase->pFontArray[FontID].UndrLnThick,					 (float) acc_width);    charpath=(struct segment *)Join(charpath,tmppath2);  }  if (modflag & T1_OVERLINE){    tmppath2=(struct segment *)Type1Line(FontP,S,					 pFontBase->pFontArray[FontID].OvrLnPos,					 pFontBase->pFontArray[FontID].OvrLnThick,					 (float) acc_width);    charpath=(struct segment *)Join(charpath,tmppath2);  }  if (modflag & T1_OVERSTRIKE){    tmppath2=(struct segment *)Type1Line(FontP,S,					 pFontBase->pFontArray[FontID].OvrStrkPos,					 pFontBase->pFontArray[FontID].OvrStrkThick,					 (float) acc_width);    charpath=(struct segment *)Join(charpath,tmppath2);  }    /*  printf("charpath->type: %x\n",charpath->type);  printf("path1->type: %x\n",path1->type);  printf("path2->type: %x\n",path2->type);  */  /* if Type1Char reported an error, then return */  if ( *mode == FF_PARSE_ERROR)  return(NULL);  if ( *mode == FF_PATH_ERROR)  return(NULL);  if (do_raster) {     /* fill with winding rule unless path was requested */    if (*mode != FF_PATH) {      charpath = (struct segment *) Interior((path) charpath,WINDINGRULE+CONTINUITY);    }  }    if (*mode==0)    *mode=localmode;  return((path)charpath);}/* This special variant is for generating character bitmaps from   charactername */xobject fontfcnB_ByName( int FontID, int modflag,			 struct XYspace *S,			 unsigned char *charname,			 int *mode, psfont *Font_Ptr,			 int do_raster){   psobj *charnameP; /* points to psobj that is name of character*/  FontInfo *pAFMData=NULL;  int i=-1;  int j=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;       /* 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;  charnameP->len = strlen((char*)charname);  charnameP->data.stringP = charname;  strncpy( (char *)CurCharName, (char *)charnameP->data.stringP, charnameP->len);  CurCharName[charnameP->len]='\0';     /* search the chars string 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);  /* if Type1Char reported an error, then return */  if ( *mode == FF_PARSE_ERROR || *mode==FF_PATH_ERROR)    return(NULL);    /* Defer rastering to later, we first have to handle the composite     symbols */  for (j=1; j<numPieces; j++) {    /* get composite symbol name */    charnameP->len=strlen( pAFMData->ccd[i].pieces[j].pccName);    charnameP->data.stringP=(unsigned char*)pAFMData->ccd[i].pieces[j].pccName;    /* get CharString definition */    if ((N=SearchDictName(CharStringsDictP,charnameP))<=0) {      /* handling of errors, see comments above ... */      sprintf( err_warn_msg_buf,	       "Charstring \"%s\" needed to construct composite char \"%s\" not defined (FontID=%d)",	       pAFMData->ccd[i].pieces[j].pccName,	       pAFMData->ccd[i].ccName, FontID);      T1_PrintLog( "fontfcnB():", err_warn_msg_buf, T1LOG_WARNING);      charnameP = &CodeName;      charnameP->len = 7;      charnameP->data.stringP = (unsigned char *) notdef;      N = SearchDictName(CharStringsDictP,charnameP);      localmode=FF_NOTDEF_SUBST;      /* damaged Font */      if (N<=0) {	*mode=FF_PARSE_ERROR;	if (charpath!=NULL) {	  KillPath( charpath);	}	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);}

⌨️ 快捷键说明

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