Back to index

tetex-bin  3.0
Classes | Defines | Functions | Variables
fontfcn.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "t1imager.h"
#include "util.h"
#include "fontfcn.h"
#include "fontmisc.h"
#include "paths_rmz.h"
#include "../t1lib/parseAFM.h"
#include "../t1lib/t1types.h"
#include "../t1lib/t1extern.h"
#include "../t1lib/t1misc.h"
#include "../t1lib/t1base.h"
#include "../t1lib/t1finfo.h"

Go to the source code of this file.

Classes

struct  region
struct  edgelist

Defines

#define BEZIERTYPE   0x10+0x02
#define LINETYPE   0x10+0x00
#define MOVETYPE   0x10+0x05
#define MAXTRIAL   4

Functions

xobject Type1Char (psfont *env, struct XYspace *S, psobj *charstrP, psobj *subrsP, psobj *osubrsP, struct blues_struct *bluesP, int *modeP, char *name, float strokewidth)
xobject Type1Line (psfont *env, struct XYspace *S, float line_position, float line_thickness, float line_length, float strokewidth)
void objFormatName (psobj *objP, int length, char *valueP)
void T1io_reset (void)
int SearchDictName (psdict *dictP, psobj *keyP)
boolean initFont ()
int resetFont (char *env)
int readFont (char *env)
static int isCompositeChar (int FontID, char *charname)
static T1_PATHPOINT getDisplacement (struct segment *path)
xobject fontfcnB (int FontID, int modflag, struct XYspace *S, char **ev, unsigned char index, int *mode, psfont *Font_Ptr, int do_raster, float strokewidth)
Bool fontfcnA (char *env, int *mode, psfont *Font_Ptr)
void QueryFontLib (char *env, char *infoName, pointer infoValue, int *rcodeP)
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, float strokewidth)
xobject fontfcnB_ByName (int FontID, int modflag, struct XYspace *S, unsigned char *charname, int *mode, psfont *Font_Ptr, int do_raster)
xobject fontfcnRect (float width, float height, struct XYspace *S, int *mode, int do_raster, float strokewidth)

Variables

static char CurCharName [257] = ""
static char BaseCharName [257] = ""
char CurFontName [MAXPATHLEN]
char * CurFontEnv
char * vm_base = NULL
static char notdef [] = ".notdef"
char * vm_used = NULL
int vm_init_count
int vm_init_amount
static psfontFontP = NULL
psfont TheCurrentFont

Class Documentation

struct edgelist

Definition at line 94 of file fontfcn.c.

Collaboration diagram for edgelist:
Class Members
fractpel fpx1
fractpel fpx2
fractpel fpy1
fractpel fpy2
XOBJ_COMMON struct edgelist * link
struct edgelist * subpath
pel xmax
pel xmin
pel * xvalues
pel ymax
pel ymin

Define Documentation

#define BEZIERTYPE   0x10+0x02

Definition at line 64 of file fontfcn.c.

#define LINETYPE   0x10+0x00

Definition at line 65 of file fontfcn.c.

#define MAXTRIAL   4

Definition at line 484 of file fontfcn.c.

#define MOVETYPE   0x10+0x05

Definition at line 66 of file fontfcn.c.


Function Documentation

Bool fontfcnA ( char *  env,
int mode,
psfont Font_Ptr 
)

Definition at line 487 of file fontfcn.c.

{
  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);

}

Here is the call graph for this function:

Here is the caller graph for this function:

xobject fontfcnB ( int  FontID,
int  modflag,
struct XYspace S,
char **  ev,
unsigned char  index,
int mode,
psfont Font_Ptr,
int  do_raster,
float  strokewidth 
) [read]

Definition at line 277 of file fontfcn.c.

{
 
  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;

  if (ev==NULL){  /* font-internal encoding should be used */
    charnameP->len = FontP->fontInfoP[ENCODING].value.data.arrayP[index].len;
    charnameP->data.stringP = (unsigned char *) FontP->fontInfoP[ENCODING].value.data.arrayP[index].data.arrayP;
  }
  else{           /* some user-supplied encoding is to be used */
    charnameP->len = strlen(ev[index]);
    charnameP->data.stringP = (unsigned char *) ev[index];
  }
  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,strokewidth);
  /* 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,strokewidth);
    /* 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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

xobject fontfcnB_ByName ( int  FontID,
int  modflag,
struct XYspace S,
unsigned char *  charname,
int mode,
psfont Font_Ptr,
int  do_raster 
)

Definition at line 959 of file fontfcn.c.

{
 
  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, 0.0f);
  /* 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,0.0f);
    /* 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);

}

Here is the call graph for this function:

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,
float  strokewidth 
) [read]

Definition at line 629 of file fontfcn.c.

{
 
  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,strokewidth);
      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);
       }
       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,strokewidth);
       /* 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,strokewidth);
    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,strokewidth);
    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,strokewidth);
    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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

xobject fontfcnRect ( float  width,
float  height,
struct XYspace S,
int mode,
int  do_raster,
float  strokewidth 
) [read]

Definition at line 1146 of file fontfcn.c.

{
  struct segment *charpath = NULL;   /* the path for this character (rectangle)  */           
  
  charpath = (struct segment *) Type1Line( NULL, S,
                                      0.5f * height,    /* position */
                                      height,           /* thickness */
                                      -width,            /* width */
                                      strokewidth       /* strokewidth */
                                      );
  
  if (do_raster) { 
    /* fill with winding rule unless path was requested */
    if (*mode != FF_PATH) {
      charpath =  (struct segment *)Interior(charpath,WINDINGRULE+CONTINUITY);
    }
  }

  return((xobject) charpath);
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

static T1_PATHPOINT getDisplacement ( struct segment path) [static]

Definition at line 236 of file fontfcn.c.

{

  register struct segment *ipath;
  register struct beziersegment *ibpath;
  T1_PATHPOINT point={0,0};
  
  /* Step through the path list */
  ipath=(struct segment *)path;
  
  do {
    if (ipath->type==LINETYPE) {
      point.x+=ipath->dest.x;
      point.y+=ipath->dest.y;
    }
    else if (ipath->type==MOVETYPE) {
      point.x+=ipath->dest.x;
      point.y+=ipath->dest.y;
    }
    else if (ipath->type==BEZIERTYPE) {
      ibpath=(struct beziersegment *)ipath;
      point.x+=ibpath->dest.x;
      point.y+=ibpath->dest.y;
    }
    ipath=ipath->link;
  } while (ipath!=NULL);
  return( point);
  
}

Here is the caller graph for this function:

Definition at line 155 of file fontfcn.c.

{
  if (!(vm_init())) return(FALSE);
  vm_base = vm_next_byte();
  strcpy(CurFontName, "");    /* iniitialize to none */
  FontP->vm_start = vm_next_byte();
  FontP->FontFileName.len = 0;
  FontP->FontFileName.data.valueP = CurFontName;
  return(TRUE);
}

Here is the caller graph for this function:

static int isCompositeChar ( int  FontID,
char *  charname 
) [static]

Definition at line 212 of file fontfcn.c.

{
  int i;
  FontInfo *pAFMData;
  
  if (pFontBase->pFontArray[FontID].pAFMData==NULL) {
    /* No AFM data present */
    return( -1);
  }

  pAFMData=pFontBase->pFontArray[FontID].pAFMData;
  for ( i=0; i<pAFMData->numOfComps; i++) {
    if (strcmp( pAFMData->ccd[i].ccName, charname)==0)
      return( i);
  }
  
  return( -1);
  
}

Here is the call graph for this function:

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;
  }
}

Here is the caller graph for this function:

void QueryFontLib ( char *  env,
char *  infoName,
pointer  infoValue,
int rcodeP 
)

Definition at line 542 of file fontfcn.c.

{

  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;
}

Here is the caller graph for this function:

int readFont ( char *  env)

Definition at line 196 of file fontfcn.c.

{
  int rcode;
  /* int memscale = 2; */ /* initially, try twice just like we used to ... */
 
  /* restore the virtual memory and eliminate old font */
  
  resetFont(env);
  /* This will load the font into the FontP */
 
  rcode = scan_font(FontP);
  return(rcode);
}

Here is the caller graph for this function:

int resetFont ( char *  env)

Definition at line 166 of file fontfcn.c.

{
 
  vm_next =  FontP->vm_start;
  vm_free = vm_size - ( vm_next - vm_base);
  FontP->Subrs.len = 0;
  FontP->Subrs.data.stringP = NULL;
  FontP->CharStringsP = NULL;
  FontP->Private = NULL;
  FontP->fontInfoP = NULL;
  FontP->BluesP = NULL;
  /* This will load the font into the FontP */
  strncpy(CurFontName,env, MAXPATHLEN);
  CurFontName[MAXPATHLEN-1] = '\0';
  FontP->FontFileName.len = strlen(CurFontName);
  FontP->FontFileName.data.nameP = CurFontName;
  T1io_reset();

  return(0);
  
}

Here is the caller graph for this function:

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);
}

Here is the caller graph for this function:

Definition at line 630 of file t1io.c.

Here is the caller graph for this function:

xobject Type1Char ( psfont env,
struct XYspace S,
psobj charstrP,
psobj subrsP,
psobj osubrsP,
struct blues_struct bluesP,
int modeP,
char *  name,
float  strokewidth 
) [read]

Definition at line 2401 of file type1.c.

{
  int Code;
  long i = 0;
  
  double xp, yp;
#ifdef DUMPDEBUGPATH
  char fnbuf[128];
#endif
  struct segment* p;

  /* Reset point list */
  ppoints          = NULL;
  numppoints       = 0;
  numppointchunks  = 0;

  /* disable hinting for stroking */
  if ( strokewidth != 0.0f )
    ProcessHints = 0;
  
  if ( env->fontInfoP[PAINTTYPE].value.data.integer == 1 )
    ProcessHints = 0;

  path    = NULL;
  apath   = NULL;
  errflag = FALSE;
 
  /* Make parameters available to all Type1 routines */
  currentchar=charname;
  Environment = (char *)env;
  CharSpace = S; /* used when creating path elements */
  CharStringP = charstrP;
  SubrsP = subrsP;
  OtherSubrsP = osubrsP;
  ModeP = modeP;
 
  blues = bluesP;
 
  QuerySpace( S, &scxx, &scyx, &scxy, &scyy); /* Transformation matrix */
  p = ILoc( S, 1, 0);
  QueryLoc(p, IDENTITY, &xp, &yp);
  up = FABS(xp);
 
  size = scxx * 1000.0;
#ifdef DUMPDEBUGPATH
  sprintf( fnbuf, "t1dump_%s_%f.eps", charname, size); 
  psfile = fopen( fnbuf, "wb");
  if ( psfile != NULL ) {
    PSDumpProlog( psfile);
    fprintf( psfile, "T1LibDict begin\n\ngsave\n%f t1SetupSize\nt1PreparePage\n", size);
  }
  
#endif

  /* compute the alignment zones */
  SetRasterFlags();
  ComputeAlignmentZones();
  StartDecrypt();
  ClearStack();
  ClearPSFakeStack();
  ClearCallStack();
  InitStems();

  /* reset variables */
  currx = curry = 0.0;
  hcurrx = hcurry = 0.0;
  escapementX = escapementY = 0;
  sidebearingX = sidebearingY = 0;
  accentoffsetX = accentoffsetY = 0;
  wsoffsetX = wsoffsetY = 0;           /* No shift to preserve whitspace. */
  wsset = 0;                           /* wsoffsetX,Y haven't been set yet. */

  
  for (;;) {
    if (!DoRead(&Code)) break;
    Decode(Code);
    if (errflag) break;
  }

  /* We now have a point list in absolute charspace coordinates. Adjust
     non-hinted points to suppress hinting artifacts and generate path. */
  for ( i=0; i<numppoints; i++ ) {
    if ( ppoints[i].type == PPOINT_BEZIER_D)
      adjustBezier( i);
  }
  /* Create path elements */
#if defined(DUMPDEBUGPATH) & defined(DUMPDEBUGPATHBOTH)
  if ( env->fontInfoP[PAINTTYPE].value.data.integer == 0 ) {
    /* For this special debug case, we generate both a filled and a stroked
       path!. */
      createStrokePath( strokewidth, SUBPATH_CLOSED);
      createFillPath();
  }
  else if ( env->fontInfoP[PAINTTYPE].value.data.integer == 1 ) {
    /* PaintType = 1 indicates stroked font. If strokewidth is 0.0f,
       we stroke using the font's internal strokewidth. Otherwise, the
       user supplied value is used. */
    if ( strokewidth != 0.0f )
      createStrokePath( strokewidth, SUBPATH_OPEN);
    else
      createStrokePath( env->fontInfoP[STROKEWIDTH].value.data.real, SUBPATH_OPEN);
  }
#else
  if ( env->fontInfoP[PAINTTYPE].value.data.integer == 0 ) {
    /* PaintType = 0 indicates filled font. Hence, a strokewidth value
       other than 0.0 indicates the character is to be stroked instead
       of to be filled. */
    if ( strokewidth != 0.0f )
      createStrokePath( strokewidth, SUBPATH_CLOSED);
    else
      createFillPath();
  }
  else if ( env->fontInfoP[PAINTTYPE].value.data.integer == 1 ) {
    /* PaintType = 1 indicates stroked font. If strokewidth is 0.0f,
       we stroke using the font's internal strokewidth. Otherwise, the
       user supplied value is used. */
    if ( strokewidth != 0.0f )
      createStrokePath( strokewidth, SUBPATH_OPEN);
    else
      createStrokePath( env->fontInfoP[STROKEWIDTH].value.data.real, SUBPATH_OPEN);
  }
#endif
  
  /* check and handle accented char */
  if ( apath != NULL ) {
    path = Join( apath, path);
  }
  
  /* Report a possible error: */
  *modeP=errflag;
  
  /* Clean up if an error has occurred */
  if (errflag) {
    if (path != NULL) {
      Destroy(path); /* Reclaim storage */
      path = NULL;   /* Indicate that character could not be built */
    }
  }
 
#ifdef DUMPDEBUGPATH
  if ( psfile != NULL ) {
    PSDumpEpilog( psfile);
    fclose( psfile);
    psfile = 0;
  }
#endif

  /* Cleanup ppoints */
  if ( ppoints != NULL ) {
    free( ppoints);
    ppoints = NULL;
    numppoints = 0;
  }
  
  return((struct xobject *) path);
}

Here is the call graph for this function:

Here is the caller graph for this function:

xobject Type1Line ( psfont env,
struct XYspace S,
float  line_position,
float  line_thickness,
float  line_length,
float  strokewidth 
) [read]

Definition at line 2565 of file type1.c.

{

  /* Reset point list */
  ppoints          = NULL;
  numppoints       = 0;
  numppointchunks  = 0;
  
  path    = NULL;
  apath   = NULL;
  errflag = FALSE;

  
  /* Make parameters available to all Type1 routines */
  Environment = (char *)env;
  CharSpace = S; /* used when creating path elements */

  currx = curry = 0;
  escapementX = escapementY = 0;
  sidebearingX = sidebearingY = 0;
  /* We have to initialize the stems-structures because
     the lineto commands refer to them! */
  SetRasterFlags();
  InitStems();
  
  /* Draw Character */
  Sbw(-1.0*line_length, 0.0, 0.0, 0.0);
  RMoveTo( 0.0,  (double) (line_position+0.5*line_thickness));
  RLineTo( 0.0, (double) -line_thickness);
  RLineTo( (double) line_length, 0.0);
  RLineTo( 0.0, (double) line_thickness);
  DoClosePath();  
  EndChar();

  /* Create path */
  if ( strokewidth != 0.0f )
    createStrokePath( strokewidth, SUBPATH_CLOSED);
  else
    createFillPath();
  
  /* Cleanup ppoints */
  if ( ppoints != NULL ) {
    free( ppoints);
    ppoints = NULL;
  }

  return((struct xobject *)path);
  
}

Here is the call graph for this function:


Variable Documentation

char BaseCharName[257] = "" [static]

Definition at line 109 of file fontfcn.c.

char CurCharName[257] = "" [static]

Definition at line 108 of file fontfcn.c.

char* CurFontEnv

Definition at line 111 of file fontfcn.c.

Definition at line 110 of file fontfcn.c.

psfont* FontP = NULL [static]

Definition at line 122 of file fontfcn.c.

char notdef[] = ".notdef" [static]

Definition at line 114 of file fontfcn.c.

Definition at line 123 of file fontfcn.c.

char* vm_base = NULL

Definition at line 112 of file fontfcn.c.

Definition at line 49 of file util.c.

Definition at line 47 of file util.c.

char* vm_used = NULL

Definition at line 118 of file fontfcn.c.