Back to index

tetex-bin  3.0
Defines | Typedefs | Functions | Variables
t1funcs.c File Reference
#include "types.h"
#include <string.h>
#include "ffilest.h"
#include "t1intf.h"
#include "objects.h"
#include "spaces.h"
#include "regions.h"
#include "t1stdio.h"
#include "util.h"
#include "fontfcn.h"

Go to the source code of this file.

Defines

#define DECIPOINTSPERINCH   722.7
#define PAD(bits, pad)   (((bits)+(pad)-1)&-(pad))
#define ALLONES   0xFF

Typedefs

typedef char * encoding [256]

Functions

int Type1OpenScalable ()
static int Type1GetGlyphs ()
void Type1CloseFont ()
int Type1GetInfoScalable ()
static int Type1GetMetrics ()
static void fillrun ()
char * Xalloc ()
void Xfree ()
static void fill ()
Bool fontfcnA ()
struct regionfontfcnB ()
int CheckFSFormat ()
void QueryFontLib ()
void T1FillFontInfo ()
void T1InitStdProps ()
int FontFileRegisterRenderer ()
int Type1OpenScalable (encoding ev, FontPtr *ppFont, int flags, FontEntryPtr entry, char *fileName, FontScalablePtr vals, fsBitmapFormat format, fsBitmapFormatMask fmask, DOUBLE efactor, DOUBLE slant)
static int Type1GetGlyphs (FontPtr pFont, ULONG count, unsigned char *chars, FontEncoding charEncoding, ULONG *glyphCount, CharInfoPtr *glyphs)
static int Type1GetMetrics (FontPtr pFont, ULONG count, unsigned char *chars, FontEncoding charEncoding, ULONG *glyphCount, xCharInfo **glyphs)
void Type1CloseFont (FontPtr pFont)
static void fill (char *dest, int h, int w, struct region *area, int byte, int bit, int wordsize)
static void fillrun (register char *p, pel x0, pel x1, int bit)
 Type1RegisterFontFileFunctions ()

Variables

psfontFontP
psobjISOLatin1EncArrayP
int currentchar
static FontRendererRec renderers []

Define Documentation

#define ALLONES   0xFF

Definition at line 515 of file t1funcs.c.

#define DECIPOINTSPERINCH   722.7

Definition at line 134 of file t1funcs.c.

#define PAD (   bits,
  pad 
)    (((bits)+(pad)-1)&-(pad))

Typedef Documentation

typedef char* encoding[256]

Definition at line 73 of file t1funcs.c.


Function Documentation

static void fill ( ) [static]
static void fill ( char *  dest,
int  h,
int  w,
struct region area,
int  byte,
int  bit,
int  wordsize 
) [static]

Definition at line 437 of file t1funcs.c.

{
       register struct edgelist *edge;  /* for looping through edges         */
       register char *p;     /* current scan line in 'dest'                  */
       register int y;       /* for looping through scans                    */
       register int wbytes = w / 8;  /* number of bytes in width             */
       register pel *leftP,*rightP;  /* pointers to X values, left and right */
       int xmin = area->xmin;  /* upper left X                               */
       int ymin = area->ymin;  /* upper left Y                               */
 
       for (edge = area->anchor; VALIDEDGE(edge); edge = edge->link->link) {
 
               p = dest + (edge->ymin - ymin) * wbytes;
               leftP = edge->xvalues;
               rightP = edge->link->xvalues;
 
               for (y = edge->ymin; y < edge->ymax; y++) {
                       fillrun(p, *leftP++ - xmin, *rightP++ - xmin, bit);
                       p += wbytes;
               }
       }
/*
Now, as an afterthought, we'll go reorganize if odd byte order requires
it:
*/
       if (byte == LSBFirst && wordsize != 8) {
               register int i;
 
               switch (wordsize) {
                   case 16:
                   {
                       register unsigned short data,*p;
 
                       p = (unsigned short *) dest;
 
                       for (i = h * w /16; --i >= 0;) {
                               data = *p;
                               *p++ = (data << 8) + (data >> 8);
                       }
                       break;
                   }
                   case 64:
                   case 32:
                   {
                       register ULONG data,*p;
 
                       p = (ULONG *) dest;
 
                       for (i = h * w / 32; --i >= 0;) {
                               data = *p;
                               *p++ = (data << 24) + (data >> 24)
                                      + (0xFF00 & (data >> 8))
                                      + (0xFF0000 & (data << 8));
                       }
                       if (wordsize == 64) {
 
                               p = (ULONG *) dest;
 
                               for (i = h * w / 64; --i >= 0;) {
                                       data = *p++;
                                       p[-1] = p[0];
                                       *p++ = data;
                               }
                       }
                       break;
                   }
                   default:
                       t1_abort("xiFill: unknown format");
               }
       }
 
}

Here is the call graph for this function:

static void fillrun ( ) [static]
static void fillrun ( register char *  p,
pel  x0,
pel  x1,
int  bit 
) [static]

Definition at line 517 of file t1funcs.c.

{
       register int startmask,endmask;  /* bits to set in first and last char*/
       register int middle;  /* number of chars between start and end + 1    */
 
       if (x1 <= x0)
               return;
       middle = x1/8 - x0/8;
       p += x0/8;
       x0 &= 7;  x1 &= 7;
       if (bit == LSBFirst) {
               startmask = ALLONES << x0;
               endmask = ~(ALLONES << x1);
       }
       else {
               startmask = ALLONES >> x0;
               endmask = ~(ALLONES >> x1);
       }
       if (middle == 0)
               *p++ |= startmask & endmask;
       else {
               *p++ |= startmask;
               while (--middle > 0)
                       *p++ = ALLONES;
               *p |= endmask;
       }
}
struct region* fontfcnB ( ) [read]

Definition at line 703 of file ps2pk.c.

{ ; }

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:

Definition at line 414 of file t1funcs.c.

{
       register int i;
       struct type1font *type1;
 
       type1 = (struct type1font *) pFont->fontPrivate;
       for (i=0; i < 256 - pFont->info.firstCol; i++)
               if (type1->glyphs[i].bits != NULL)
                        Xfree(type1->glyphs[i].bits);
       Xfree(type1);

       if (pFont->info.props)
          Xfree(pFont->info.props);

       if (pFont->info.isStringProp)
          Xfree(pFont->info.isStringProp);

       Xfree(pFont);
}

Here is the call graph for this function:

static int Type1GetGlyphs ( ) [static]
static int Type1GetGlyphs ( FontPtr  pFont,
ULONG  count,
unsigned char *  chars,
FontEncoding  charEncoding,
ULONG glyphCount,
CharInfoPtr glyphs 
) [static]

Definition at line 326 of file t1funcs.c.

{
    unsigned int firstRow;
    unsigned int numRows;
    CharInfoPtr *glyphsBase;
    register unsigned int c;
    register CharInfoPtr pci;
    unsigned int r;
    CharInfoPtr pDefault;
    register struct type1font *type1Font;
    register int firstCol;
 
    type1Font  = (struct type1font *) pFont->fontPrivate;
    firstCol   = pFont->info.firstCol;
    pDefault   = type1Font->pDefault;
    glyphsBase = glyphs;

    switch (charEncoding) {

    case Linear8Bit:
    case TwoD8Bit:
        if (pFont->info.firstRow > 0)
            break;
        while (count--) {
                c = (*chars++);
                if (c >= firstCol)
                    *glyphs++ = &type1Font->glyphs[c-firstCol];
                else if (pDefault)
                    *glyphs++ = pDefault;
        }
        break;
    case Linear16Bit:
        while (count--) {
                c = *chars++ << 8;
                c = (c | *chars++);
                if (c < 256 && c >= firstCol)
                    *glyphs++ = &type1Font->glyphs[c-firstCol];
                else if (pDefault)
                    *glyphs++ = pDefault;
        }
        break;
 
    case TwoD16Bit:
        firstRow = pFont->info.firstRow;
        numRows = pFont->info.lastRow - firstRow + 1;
        while (count--) {
            r = (*chars++) - firstRow;
            c = (*chars++);
            if (r < numRows && c < 256 && c >= firstCol)
                *glyphs++ = &type1Font->glyphs[(r << 8) + c - firstCol];
            else if (pDefault)
                *glyphs++ = pDefault;
        }
        break;
    }
    *glyphCount = glyphs - glyphsBase;
    return Successful;
}
static int Type1GetMetrics ( ) [static]
static int Type1GetMetrics ( FontPtr  pFont,
ULONG  count,
unsigned char *  chars,
FontEncoding  charEncoding,
ULONG glyphCount,
xCharInfo **  glyphs 
) [static]

Definition at line 392 of file t1funcs.c.

{
    static CharInfoRec nonExistantChar;
 
    int         ret;
    struct type1font *type1Font;
    CharInfoPtr oldDefault;
 
    type1Font = (struct type1font *) pFont->fontPrivate;
    oldDefault = type1Font->pDefault;
    type1Font->pDefault = &nonExistantChar;
    ret = Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, (CharInfoPtr *) glyphs);
    type1Font->pDefault = oldDefault;
    return ret;
}

Here is the call graph for this function:

int Type1OpenScalable ( encoding  ev,
FontPtr ppFont,
int  flags,
FontEntryPtr  entry,
char *  fileName,
FontScalablePtr  vals,
fsBitmapFormat  format,
fsBitmapFormatMask  fmask,
DOUBLE  efactor,
DOUBLE  slant 
)

Definition at line 139 of file t1funcs.c.

{
       extern struct XYspace *IDENTITY;
 
       FontPtr     pFont;
       int         bit,
                   byte,
                   glyph,
                   scan,
                   image;
       int pad,wordsize;     /* scan & image in bits                         */
       int size;             /* for memory size calculations                 */
       struct XYspace *S;    /* coordinate space for character               */
       struct region *area;
       DOUBLE scale;         /* scale factor for font                        */
       DOUBLE txx, tyx, txy, tyy;
       CharInfoRec *glyphs;
       register int i;
       int len,rc;
       struct type1font *type1;
       char *p;

       /* set up default values */
       FontDefaultFormat(&bit, &byte, &glyph, &scan);
       /* get any changes made from above */
       rc = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
       if (rc != Successful)
               return rc;
 
       pad                = glyph * 8;
       wordsize           = scan * 8;
 
#define  PAD(bits, pad)  (((bits)+(pad)-1)&-(pad))
 
       pFont = (FontPtr) Xalloc(sizeof(FontRec));
       if (pFont == NULL)
           return AllocError;
 
       type1 = (struct type1font *)Xalloc(sizeof(struct type1font));
       if (type1 == NULL) {
               Xfree(pFont);
               return AllocError;
       }
       (void) memset(type1, 0, sizeof(struct type1font));

       scale = (DOUBLE) vals->pixel;

      /* Code added by E. Schenk. July 25, 1992.
       * The following code reads the FontMatrix for the font,
       * and transforms the font using it. This is necessary
       * for fonts that are just an oblique, or extend of
       * a normal font. 
       */
       {  float fontmatrix[6];
         int rc;
         QueryFontLib(fileName,"FontMatrix",fontmatrix,&rc);
         if (!rc) {
            S = (struct XYspace *) Transform(IDENTITY,
                  fontmatrix[0], fontmatrix[1], fontmatrix[2], fontmatrix[3]);
         }
         else {
            S = (struct XYspace *) Scale(IDENTITY,0.001,0.001);
         }
       }
       /* End of additional code */
       
       if (efactor == 1.0 && slant == 0.0)
         S = (struct XYspace *)Permanent(Scale(S, scale, - scale));
       else {
          txx = (DOUBLE)vals->x * efactor * vals->point / DECIPOINTSPERINCH;
          tyy = (DOUBLE)vals->y * vals->point / DECIPOINTSPERINCH;
          tyx = 0.0;
          txy = (DOUBLE)vals->x * slant * vals->point / DECIPOINTSPERINCH;
          S = (struct XYspace *) Permanent(Transform(S, txx, tyx, txy, -tyy));
       }
 
       glyphs = type1->glyphs;
 
       /* load font if not already loaded */
       if (!fontfcnA(fileName, &rc))
          return (rc);

       for (i=0; i < 256-FIRSTCOL; i++) {
               LONG h,w;
               LONG paddedW;

              if (ev[i] == NULL) continue;
              len = strlen(ev[i]);

               currentchar = i;

               rc = 0;
              area = fontfcnB(S, ev[i], &len, &rc);
               if (rc < 0) {
                       rc = BadFontName;
                       break;
               }
               else if (rc > 0)
                       continue;
 
               if (area == NULL)
                       continue;
 
               h       = area->ymax - area->ymin;
               w       = area->xmax - area->xmin;
               paddedW = PAD(w, pad);
 
               if (h > 0 && w > 0) {
                       size = h * paddedW / 8;
                       glyphs[i].bits = (char *)Xalloc(size);
                       if (glyphs[i].bits == NULL) {
                               rc = AllocError;
                               break;
                       }
               }
               else {
                       h = w = 0;
                       area->xmin = area->xmax = 0;
                       area->ymax = area->ymax = 0;
               }
 
               glyphs[i].metrics.leftSideBearing  = area->xmin;
               glyphs[i].metrics.characterWidth   = NEARESTPEL(area->ending.x - area->origin.x);
               glyphs[i].metrics.rightSideBearing = w + area->xmin;
               glyphs[i].metrics.descent          = area->ymax - NEARESTPEL(area->origin.y);
               glyphs[i].metrics.ascent           = h - glyphs[i].metrics.descent;
 
               if (h > 0 && w > 0) {
                       (void) memset(glyphs[i].bits, 0, size);
                       fill(glyphs[i].bits, h, paddedW, area, byte, bit, wordsize );
               }
 
               Destroy(area);
       }

       if (i != 256 - FIRSTCOL) {
               for (i--; i >= 0; i--)
                       if (glyphs[i].bits != NULL)
                               Xfree(glyphs[i].bits);
               Xfree(type1);
               Xfree(pFont);
               return rc;
       }
       type1->pDefault    = NULL;
 
       pFont->format      = format;
 
       pFont->bit         = bit;
       pFont->byte        = byte;
       pFont->glyph       = glyph;
       pFont->scan        = scan;
 
       pFont->info.firstCol = FIRSTCOL;
       pFont->info.lastCol  = 255;
       pFont->info.firstRow = 0;
       pFont->info.lastRow  = 0;
 
       pFont->get_metrics = Type1GetMetrics;
       pFont->get_glyphs  = Type1GetGlyphs;
       pFont->unload_font = Type1CloseFont;
       pFont->refcnt = 0;
       pFont->maxPrivate = -1;
       pFont->devPrivates = 0;
 
       pFont->fontPrivate = (unsigned char *) type1;
 
       T1FillFontInfo(pFont, vals, fileName, entry->name.name);
 
       *ppFont = pFont;
       return Successful;
}

Here is the call graph for this function:

Definition at line 553 of file t1funcs.c.

{
    int i;
 
    T1InitStdProps();
    for (i=0; i < sizeof(renderers) / sizeof(FontRendererRec); i++)
            FontFileRegisterRenderer(&renderers[i]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* Xalloc ( )
void Xfree ( )

Definition at line 516 of file t1test.c.

{
       free();
}

Here is the call graph for this function:


Variable Documentation

Definition at line 123 of file type1.c.

Definition at line 52 of file fontfcn.c.

Definition at line 425 of file scanfont.c.

Initial value:
 {
  { ".pfa", 4, (int (*)()) 0, Type1OpenScalable,
        (int (*)()) 0, Type1GetInfoScalable, 0 },
  { ".pfb", 4, (int (*)()) 0, Type1OpenScalable,
        (int (*)()) 0, Type1GetInfoScalable, 0 }
}

Definition at line 546 of file t1funcs.c.