Back to index

tetex-bin  3.0
Classes | Defines | Typedefs | Enumerations | Functions | Variables
t1info.c File Reference
#include "types.h"
#include <stdio.h>
#include <string.h>
#include "ffilest.h"
#include "t1intf.h"

Go to the source code of this file.

Classes

struct  _fontProp

Defines

#define DECIPOINTSPERINCH   722.7
#define DEFAULTRES   75
#define DEFAULTPOINTSIZE   120
#define FONTPROP   0
#define COPYRIGHTPROP   1
#define NNAMEPROPS   (sizeof(fontNamePropTable) / sizeof(fontProp))
#define NEXTRAPROPS   (sizeof(extraProps) / sizeof(fontProp))
#define NPROPS   (NNAMEPROPS + NEXTRAPROPS)
#define MINMAX(field, ci)

Typedefs

typedef struct _fontProp fontProp

Enumerations

enum  scaleType {
  atom, pixel_size, point_size, resolution_x,
  resolution_y, average_width, scaledX, scaledY,
  unscaled, scaledXoverY, uncomputed
}

Functions

char * Xalloc (int size)
void Xfree (void *)
int FontComputeInfoAccelerators (FontInfoPtr)
long MakeAtom (char *, unsigned int, Bool)
int Type1OpenScalable (FontPathElementPtr ev, FontPtr *ppFont, int flags, FontEntryPtr entry, char *fileName, FontScalablePtr vals, unsigned long format, unsigned long fmask, double efactor, double slant)
void Type1CloseFont (struct _Font *pFont)
void QueryFontLib (char *env, char *infoName, void *infoValue, int *rcodeP)
static void FillHeader (FontInfoPtr pInfo, FontScalablePtr Vals)
static void adjust_min_max (xCharInfo *minc, xCharInfo *maxc, xCharInfo *tmp)
static void ComputeBounds (FontInfoPtr pInfo, CharInfoPtr pChars, FontScalablePtr Vals)
static void ComputeProps (FontInfoPtr pInfo, FontScalablePtr Vals, char *Filename)
static void ComputeStdProps (FontInfoPtr pInfo, FontScalablePtr Vals, char *Filename, char *Fontname)
int Type1GetInfoScalable (FontPathElementPtr fpe, FontInfoPtr pInfo, FontEntryPtr entry, FontNamePtr fontName, char *fileName, FontScalablePtr Vals)
void T1FillFontInfo (FontPtr pFont, FontScalablePtr Vals, char *Filename, char *Fontname)
void T1InitStdProps ()

Variables

static fontProp fontNamePropTable []
static fontProp extraProps []

Class Documentation

struct _fontProp

Definition at line 91 of file t1info.c.

Class Members
LONG atom
char * name

Define Documentation

#define COPYRIGHTPROP   1

Definition at line 121 of file t1info.c.

#define DECIPOINTSPERINCH   722.7

Definition at line 81 of file t1info.c.

#define DEFAULTPOINTSIZE   120

Definition at line 83 of file t1info.c.

#define DEFAULTRES   75

Definition at line 82 of file t1info.c.

#define FONTPROP   0

Definition at line 120 of file t1info.c.

#define MINMAX (   field,
  ci 
)
Value:
if (minc->field > (ci)->field) \
             minc->field = (ci)->field; \
        if (maxc->field < (ci)->field) \
            maxc->field = (ci)->field;
#define NEXTRAPROPS   (sizeof(extraProps) / sizeof(fontProp))

Definition at line 124 of file t1info.c.

#define NNAMEPROPS   (sizeof(fontNamePropTable) / sizeof(fontProp))

Definition at line 123 of file t1info.c.

#define NPROPS   (NNAMEPROPS + NEXTRAPROPS)

Definition at line 126 of file t1info.c.


Typedef Documentation

typedef struct _fontProp fontProp

Enumeration Type Documentation

enum scaleType
Enumerator:
atom 
pixel_size 
point_size 
resolution_x 
resolution_y 
average_width 
scaledX 
scaledY 
unscaled 
scaledXoverY 
uncomputed 

Definition at line 85 of file t1info.c.


Function Documentation

static void adjust_min_max ( xCharInfo minc,
xCharInfo maxc,
xCharInfo tmp 
) [static]

Definition at line 153 of file t1info.c.

{
#define MINMAX(field,ci) \
        if (minc->field > (ci)->field) \
             minc->field = (ci)->field; \
        if (maxc->field < (ci)->field) \
            maxc->field = (ci)->field;
 
    MINMAX(ascent, tmp);
    MINMAX(descent, tmp);
    MINMAX(leftSideBearing, tmp);
    MINMAX(rightSideBearing, tmp);
    MINMAX(characterWidth, tmp);
 
#undef  MINMAX
}

Here is the caller graph for this function:

static void ComputeBounds ( FontInfoPtr  pInfo,
CharInfoPtr  pChars,
FontScalablePtr  Vals 
) [static]

Definition at line 174 of file t1info.c.

{
    int i;
    xCharInfo minchar, maxchar;
    LONG width = 0;
    int numchars = 0;
    int totchars;
    int overlap;
    int maxlap;
 
    minchar.ascent = minchar.descent =
        minchar.leftSideBearing = minchar.rightSideBearing =
        minchar.characterWidth = 32767;
    minchar.attributes = 0;  /* What's this for? +++ */
    maxchar.ascent = maxchar.descent =
        maxchar.leftSideBearing = maxchar.rightSideBearing =
        maxchar.characterWidth = -32767;
    maxchar.attributes = 0;
 
    maxlap = -32767;
    totchars = pInfo->lastCol - pInfo->firstCol + 1;
    pInfo->allExist = 1;
    for (i = 0; i < totchars; i++,pChars++) {
        xCharInfo *pmetrics = &pChars->metrics;
 
        if (pmetrics->characterWidth) {
            width += pmetrics->characterWidth;
            numchars++;
            adjust_min_max(&minchar, &maxchar, pmetrics);
            overlap = pmetrics->rightSideBearing - pmetrics->characterWidth;
            if (overlap > maxlap) maxlap = overlap;
        }
        else pInfo->allExist = 0;
    }

    Vals->width = ((width * 10)+((numchars+1)/2)) / numchars;
    /* (We think the above average width value should be put into
        the Vals structure.  This may be wrong, and the proper
        behavior might be to regard the values in Vals as sacred,
        and for us to squirrel the computed number in a static, and
        then use that static in ComputeStdProps.) */
    pInfo->maxbounds = maxchar;
    pInfo->minbounds = minchar;
    pInfo->ink_maxbounds = maxchar;
    pInfo->ink_minbounds = minchar;
    pInfo->maxOverlap = maxlap + -(minchar.leftSideBearing);
 
    /* Set the pInfo flags */
    /* Properties set by FontComputeInfoAccelerators:
        pInfo->noOverlap;
        pInfo->terminalFont;
        pInfo->constantMetrics;
        pInfo->constantWidth;
        pInfo->inkInside;
 
    */
    FontComputeInfoAccelerators (pInfo);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ComputeProps ( FontInfoPtr  pInfo,
FontScalablePtr  Vals,
char *  Filename 
) [static]

Definition at line 237 of file t1info.c.

{
    int infoint;
    int infoBBox[4];
    int rc;
 
    QueryFontLib(Filename, "isFixedPitch", &infoint, &rc);
    if (!rc) {
        pInfo->constantWidth = infoint;
    }
    QueryFontLib((char *)0, "FontBBox", infoBBox, &rc);
    if (!rc) {
        pInfo->fontAscent = (infoBBox[3] * Vals->pixel) / 1000;
        pInfo->fontDescent = - (infoBBox[1] * Vals->pixel) / 1000;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ComputeStdProps ( FontInfoPtr  pInfo,
FontScalablePtr  Vals,
char *  Filename,
char *  Fontname 
) [static]

Definition at line 258 of file t1info.c.

{
    FontPropPtr pp;
    int         i,
                nprops;
    fontProp   *fpt;
    char       *is_str;
    char       *ptr1,
               *ptr2;
    char *infostrP;
    LONG rc;
    char      scaledName[MAXFONTNAMELEN];
 
    strcpy (scaledName, Fontname);
#ifdef WIN32
    /* Fill in our copy of the fontname from the Vals structure */
    FontParseXLFDName (scaledName, Vals, FONT_XLFD_REPLACE_VALUE);
#endif
 
    /* This form of the properties is used by the X-client; the X-server
       doesn't care what they are. */
    nprops = pInfo->nprops = NPROPS;
    pInfo->isStringProp = (char *) Xalloc(sizeof(char) * nprops);
    pInfo->props = (FontPropPtr) Xalloc(sizeof(FontPropRec) * nprops);
    if (!pInfo->isStringProp || !pInfo->props) {
        Xfree(pInfo->isStringProp);
        pInfo->isStringProp = (char *) 0;
        Xfree(pInfo->props);
        pInfo->props = (FontPropPtr) 0;
        return;
    }
    (void) memset(pInfo->isStringProp, 0, (sizeof(char) * nprops));
 
    ptr2 = scaledName;
    for (i = NNAMEPROPS, pp = pInfo->props, fpt = fontNamePropTable, is_str = pInfo->isStringProp;
            i;
            i--, pp++, fpt++, is_str++) {
        ptr1 = ptr2 + 1;
        if (*ptr1 == '-')
            ptr2 = ptr1;
        else {
            if (i > 1)
                ptr2 = strchr(ptr1 + 1, '-');
            else
                ptr2 = strchr(ptr1 + 1, '\0');
        }
        pp->name = fpt->atom;
        switch (fpt->type) {
         case atom:  /* Just copy info from scaledName */
            *is_str = TRUE;
            pp->value = MakeAtom(ptr1, ptr2 - ptr1, TRUE);
            break;
         case pixel_size:
            pp->value = Vals->pixel;
            break;
         case point_size:
            pp->value = Vals->point;
            break;
         case resolution_x:
            pp->value = Vals->x;
            break;
         case resolution_y:
            pp->value = Vals->y;
            break;
         case average_width:
            pp->value = Vals->width;
            break;
        }
    }
 
    for (i = 0, fpt = extraProps;
          i < NEXTRAPROPS;
          i++, is_str++, pp++, fpt++) {
        pp->name = fpt->atom;
        switch (i) {
         case FONTPROP:
            /* Why do we need this property -- nice for debug anyway */
            *is_str = TRUE;
            pp->value = MakeAtom(scaledName, strlen(scaledName), TRUE);
            break;
         case COPYRIGHTPROP:
            *is_str = TRUE;
            QueryFontLib(Filename, "Notice", &infostrP, &rc);
            if (rc || !infostrP) {
                infostrP = "Copyright Notice not available";
            }
            pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
            break;
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void FillHeader ( FontInfoPtr  pInfo,
FontScalablePtr  Vals 
) [static]

Definition at line 130 of file t1info.c.

{
    /* OpenScalable in T1FUNCS sets the following:
    pInfo->firstCol,
    pInfo->firstRow,
    pInfo->lastCol, and
    pInfo->lastRow. */
    /* the following are ununsed
    pInfo->pad. */
 
    /* Items we should handle better someday +++ */
    pInfo->defaultCh = 0;
    pInfo->drawDirection = LeftToRight;
    /* our size is based only on Vals->pixel, so we won't
       create an anamorphic font (yet) */
    pInfo->anamorphic = 0;
    pInfo->inkMetrics = 0;  /* no ink metrics here */
    pInfo->cachable = 1;    /* no licensing (yet) */
}

Here is the caller graph for this function:

long MakeAtom ( char *  ,
unsigned  int,
Bool   
)

Definition at line 668 of file ps2pk.c.

{
       return (long)p;
}
void QueryFontLib ( char *  env,
char *  infoName,
void infoValue,
int rcodeP 
)
void T1FillFontInfo ( FontPtr  pFont,
FontScalablePtr  Vals,
char *  Filename,
char *  Fontname 
)

Definition at line 384 of file t1info.c.

{
    FontInfoPtr         pInfo = &pFont->info;
    struct type1font *p = (struct type1font *)pFont->fontPrivate;
 
    FillHeader(pInfo, Vals);
 
    ComputeBounds(pInfo, p->glyphs, Vals);
 
    ComputeProps(pInfo, Vals, Filename);
    ComputeStdProps(pInfo, Vals, Filename, Fontname);
}

Here is the call graph for this function:

Definition at line 403 of file t1info.c.

{
    int         i;
    fontProp   *t;
 
    i = sizeof(fontNamePropTable) / sizeof(fontProp);
    for (t = fontNamePropTable; i; i--, t++)
        t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
    i = sizeof(extraProps) / sizeof(fontProp);
    for (t = extraProps; i; i--, t++)
        t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Type1CloseFont ( struct _Font pFont)
int Type1GetInfoScalable ( FontPathElementPtr  fpe,
FontInfoPtr  pInfo,
FontEntryPtr  entry,
FontNamePtr  fontName,
char *  fileName,
FontScalablePtr  Vals 
)

Definition at line 356 of file t1info.c.

{
    FontPtr pfont;
    int flags = 0;
    LONG format = 0;  /* It doesn't matter what format for just info */
    LONG fmask = 0;
    int ret;
 
    ret = Type1OpenScalable(fpe, &pfont, flags, entry, fileName, Vals, format, fmask, 1.0, 0.0);
    if (ret != Successful)
       return ret;
    *pInfo = pfont->info;

    /* XXX - Set pointers in pfont->info to NULL so they are not freed. */
    pfont->info.props = NULL;
    pfont->info.isStringProp = NULL;

    Type1CloseFont(pfont);
    return Successful;
}

Here is the call graph for this function:

int Type1OpenScalable ( FontPathElementPtr  ev,
FontPtr ppFont,
int  flags,
FontEntryPtr  entry,
char *  fileName,
FontScalablePtr  vals,
unsigned long  format,
unsigned long  fmask,
double  efactor,
double  slant 
)
char* Xalloc ( int  size)

Definition at line 509 of file t1test.c.

{
       extern char *malloc();
       return(malloc(size));
}
void Xfree ( void )

Definition at line 689 of file ps2pk.c.

{
       free(p);
}

Here is the call graph for this function:


Variable Documentation

fontProp extraProps[] [static]
Initial value:
 {
    "FONT", 0, atom,
    "COPYRIGHT", 0, atom,
}

Definition at line 114 of file t1info.c.

Initial value:
 {  
    "FOUNDRY", 0, atom,                  
    "FAMILY_NAME", 0, atom,              
    "WEIGHT_NAME", 0, atom,              
    "SLANT", 0, atom,                    
    "SETWIDTH_NAME", 0, atom,            
    "ADD_STYLE_NAME", 0, atom,           
    "PIXEL_SIZE", 0, pixel_size,         
    "POINT_SIZE", 0, point_size,         
    "RESOLUTION_X", 0, resolution_x,     
    "RESOLUTION_Y", 0, resolution_y,     
    "SPACING", 0, atom,                  
    "AVERAGE_WIDTH", 0, average_width,   
    "CHARSET_REGISTRY", 0, atom,         
    "CHARSET_ENCODING", 0, atom,         
}

Definition at line 97 of file t1info.c.