Back to index

tetex-bin  3.0
Classes | Defines | Typedefs | Functions
parseAFM.h File Reference
#include <stdio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BBox
struct  GlobalFontInfo
struct  _t_ligature
struct  CharMetricInfo
struct  TrackKernData
struct  PairKernData
struct  Pcc
struct  CompCharData
struct  FontInfo

Defines

#define T1LIB_TRUE   1
#define T1LIB_FALSE   0
#define EOL   '\n' /* end-of-line indicator */
#define MAX_NAME   4096 /* max length for identifiers */
#define BOOL   int
#define FLAGS   int
#define P_G   0x01 /* 0000 0001 */ /* Global Font Info */
#define P_W   0x02 /* 0000 0010 */ /* Character Widths ONLY */
#define P_M   0x06 /* 0000 0110 */ /* All Char Metric Info */
#define P_P   0x08 /* 0000 1000 */ /* Pair Kerning Info */
#define P_T   0x10 /* 0001 0000 */ /* Track Kerning Info */
#define P_C   0x20 /* 0010 0000 */ /* Composite Char Info */
#define P_GW   (P_G | P_W)
#define P_GM   (P_G | P_M)
#define P_GMP   (P_G | P_M | P_P)
#define P_GMK   (P_G | P_M | P_P | P_T)
#define P_ALL   (P_G | P_M | P_P | P_T | P_C)
#define ok   0
#define parseError   -1
#define earlyEOF   -2
#define storageProblem   -3

Typedefs

typedef struct _t_ligature Ligature

Functions

int T1lib_parseFile (FILE *fp, FontInfo **fi, FLAGS flags)

Class Documentation

struct BBox

Definition at line 173 of file parseAFM.h.

Class Members
int llx
int lly
int urx
int ury
struct GlobalFontInfo

Definition at line 187 of file parseAFM.h.

Collaboration diagram for GlobalFontInfo:
Class Members
char * afmVersion
int ascender
int capHeight
int descender
char * encodingScheme
char * familyName
BBox fontBBox
char * fontName
char * fullName
BOOL isFixedPitch
float italicAngle
char * notice
int underlinePosition
int underlineThickness
char * version
char * weight
int xHeight
struct _t_ligature

Definition at line 212 of file parseAFM.h.

Collaboration diagram for _t_ligature:
Class Members
char * lig
struct _t_ligature * next
char * succ
struct CharMetricInfo

Definition at line 229 of file parseAFM.h.

Collaboration diagram for CharMetricInfo:
Class Members
BBox charBBox
int code
Ligature * ligs
char * name
int wx
int wy
struct TrackKernData

Definition at line 248 of file parseAFM.h.

Class Members
int degree
float maxKernAmt
float maxPtSize
float minKernAmt
float minPtSize
struct PairKernData

Definition at line 266 of file parseAFM.h.

Class Members
char * name1
char * name2
int xamt
int yamt
struct Pcc

Definition at line 283 of file parseAFM.h.

Class Members
int deltax
int deltay
char * pccName
struct CompCharData

Definition at line 304 of file parseAFM.h.

Collaboration diagram for CompCharData:
Class Members
char * ccName
BBox charBBox
int numOfPieces
Pcc * pieces
int wx
struct FontInfo

Definition at line 320 of file parseAFM.h.

Collaboration diagram for FontInfo:
Class Members
CompCharData * ccd
CharMetricInfo * cmi
int * cwi
GlobalFontInfo * gfi
int numOfChars
int numOfComps
int numOfPairs
int numOfTracks
PairKernData * pkd
TrackKernData * tkd

Define Documentation

#define BOOL   int

Definition at line 114 of file parseAFM.h.

#define earlyEOF   -2

Definition at line 158 of file parseAFM.h.

#define EOL   '\n' /* end-of-line indicator */

Definition at line 112 of file parseAFM.h.

#define FLAGS   int

Definition at line 115 of file parseAFM.h.

#define MAX_NAME   4096 /* max length for identifiers */

Definition at line 113 of file parseAFM.h.

#define ok   0

Definition at line 156 of file parseAFM.h.

#define P_ALL   (P_G | P_M | P_P | P_T | P_C)

Definition at line 136 of file parseAFM.h.

#define P_C   0x20 /* 0010 0000 */ /* Composite Char Info */

Definition at line 127 of file parseAFM.h.

#define P_G   0x01 /* 0000 0001 */ /* Global Font Info */

Definition at line 122 of file parseAFM.h.

#define P_GM   (P_G | P_M)

Definition at line 133 of file parseAFM.h.

#define P_GMK   (P_G | P_M | P_P | P_T)

Definition at line 135 of file parseAFM.h.

#define P_GMP   (P_G | P_M | P_P)

Definition at line 134 of file parseAFM.h.

#define P_GW   (P_G | P_W)

Definition at line 132 of file parseAFM.h.

#define P_M   0x06 /* 0000 0110 */ /* All Char Metric Info */

Definition at line 124 of file parseAFM.h.

#define P_P   0x08 /* 0000 1000 */ /* Pair Kerning Info */

Definition at line 125 of file parseAFM.h.

#define P_T   0x10 /* 0001 0000 */ /* Track Kerning Info */

Definition at line 126 of file parseAFM.h.

#define P_W   0x02 /* 0000 0010 */ /* Character Widths ONLY */

Definition at line 123 of file parseAFM.h.

#define parseError   -1

Definition at line 157 of file parseAFM.h.

#define storageProblem   -3

Definition at line 159 of file parseAFM.h.

#define T1LIB_FALSE   0

Definition at line 111 of file parseAFM.h.

#define T1LIB_TRUE   1

Definition at line 110 of file parseAFM.h.


Typedef Documentation

typedef struct _t_ligature Ligature

Function Documentation

int T1lib_parseFile ( FILE fp,
FontInfo **  fi,
FLAGS  flags 
)

Definition at line 1142 of file parseAFM.c.

{
    
    int code = ok;   /* return code from each of the parsing routines */
    int error = ok;  /* used as the return code from this function */
    
    register char *keyword; /* used to store a token */  
    
                           
    /* storage data for the global variable ident */                        
    ident = (char *) calloc(MAX_NAME, sizeof(char)); 
    if (ident == NULL) {error = storageProblem; return(error);}      
  
    (*fi) = (FontInfo *) calloc(1, sizeof(FontInfo));
    if ((*fi) == NULL) {error = storageProblem; return(error);}      
  
    if (flags & P_G) 
    {
        (*fi)->gfi = (GlobalFontInfo *) calloc(1, sizeof(GlobalFontInfo));
        if ((*fi)->gfi == NULL) {error = storageProblem; return(error);}      
    }
    
    /* The AFM File begins with Global Font Information. This section */
    /* will be parsed whether or not information should be saved. */     
    code = parseGlobals(fp, (*fi)->gfi); 
    
    if (code < 0) error = code;
    
    /* The Global Font Information is followed by the Character Metrics */
    /* section. Which procedure is used to parse this section depends on */
    /* how much information should be saved. If all of the metrics info */
    /* is wanted, parseCharMetrics is called. If only the character widths */
    /* is wanted, parseCharWidths is called. parseCharWidths will also */
    /* be called in the case that no character data is to be saved, just */
    /* to parse through the section. */
  
    if ((code != normalEOF) && (code != earlyEOF))
    {
        (*fi)->numOfChars = atoi(token(fp));
           if (flags & (P_M ^ P_W))
        {
            (*fi)->cmi = (CharMetricInfo *) 
                      calloc((*fi)->numOfChars, sizeof(CharMetricInfo));
           if ((*fi)->cmi == NULL) {error = storageProblem; return(error);}
            code = parseCharMetrics(fp, *fi);             
        }
        else
        {
            if (flags & P_W)
            { 
                (*fi)->cwi = (int *) calloc(256, sizeof(int)); 
                if ((*fi)->cwi == NULL) 
                {
                     error = storageProblem; 
                     return(error);
                }
            }
            /* parse section regardless */
            code = parseCharWidths(fp, (*fi)->cwi);
        } /* else */
    } /* if */
    
    if ((error != earlyEOF) && (code < 0)) error = code;
    
    /* The remaining sections of the AFM are optional. This code will */
    /* look at the next keyword in the file to determine what section */
    /* is next, and then allocate the appropriate amount of storage */
    /* for the data (if the data is to be saved) and call the */
    /* appropriate parsing routine to parse the section. */
    
    while ((code != normalEOF) && (code != earlyEOF)) {
      keyword = token(fp);
      if (keyword == NULL)
       /* Have reached an early and unexpected EOF. */
       /* Set flag and stop parsing */
        {
         code = earlyEOF;
         break; /* get out of loop */
        }
      switch(recognize(keyword))
        {
         /* this case has been added for t1lib because otherwise comment line
            between (i.e., outside) the main sections would lead to parse
            errors. The Adobe spec does not seem to forbid comments at
            such locations (2001-05-14, RMz) */
       case COMMENT:
         keyword = linetoken(fp);
         break;
       case STARTKERNDATA:
         break;
       case ENDKERNDATA:
         break;
       case STARTTRACKKERN:
         keyword = token(fp);
         if (flags & P_T)
           {
             (*fi)->numOfTracks = atoi(keyword);
             (*fi)->tkd = (TrackKernData *) 
              calloc((*fi)->numOfTracks, sizeof(TrackKernData));
             if ((*fi)->tkd == NULL) 
              {
                error = storageProblem; 
                return(error);
              }
           } /* if */
         code = parseTrackKernData(fp, *fi);
         break;
       case STARTKERNPAIRS:
         keyword = token(fp);
         if (flags & P_P)
           {
             (*fi)->numOfPairs = atoi(keyword);
             (*fi)->pkd = (PairKernData *) 
              calloc((*fi)->numOfPairs, sizeof(PairKernData));
             if ((*fi)->pkd == NULL) 
              {
                error = storageProblem; 
                return(error);
              }
           } /* if */
         code = parsePairKernData(fp, *fi);
         break;
       case STARTCOMPOSITES:
         keyword = token(fp);
         if (flags & P_C)
           { 
             (*fi)->numOfComps = atoi(keyword);
             (*fi)->ccd = (CompCharData *) 
              calloc((*fi)->numOfComps, sizeof(CompCharData));
             if ((*fi)->ccd == NULL) 
              {
                error = storageProblem; 
                return(error);
              }
           } /* if */
         code = parseCompCharData(fp, *fi); 
         break;    
       case ENDFONTMETRICS:
         code = normalEOF;
         break;
       case NOPE:
       default:
         code = parseError;
         break;
        } /* switch */
      
      if ((error != earlyEOF) && (code < 0)) error = code;
      
    } /* while */
    
    if ((error != earlyEOF) && (code < 0)) error = code;
    
    if (ident != NULL) { free(ident); ident = NULL; }
        
    return(error);
  

Here is the call graph for this function:

Here is the caller graph for this function: