Back to index

tetex-bin  3.0
t1types.h
Go to the documentation of this file.
00001 /*--------------------------------------------------------------------------
00002   ----- File:        t1types.h
00003   ----- Author:      Rainer Menzner (Rainer.Menzner@web.de)
00004   ----- Date:        2001-06-04
00005   ----- Description: This file is part of the t1-library. It contains
00006                      type definitions used by the t1-library.
00007   ----- Copyright:   t1lib is copyrighted (c) Rainer Menzner, 1996-2001. 
00008                      As of version 0.5, t1lib is distributed under the
00009                    GNU General Public Library Lincense. The
00010                    conditions can be found in the files LICENSE and
00011                    LGPL, which should reside in the toplevel
00012                    directory of the distribution.  Please note that 
00013                    there are parts of t1lib that are subject to
00014                    other licenses:
00015                    The parseAFM-package is copyrighted by Adobe Systems
00016                    Inc.
00017                    The type1 rasterizer is copyrighted by IBM and the
00018                    X11-consortium.
00019   ----- Warranties:  Of course, there's NO WARRANTY OF ANY KIND :-)
00020   ----- Credits:     I want to thank IBM and the X11-consortium for making
00021                      their rasterizer freely available.
00022                    Also thanks to Piet Tutelaers for his ps2pk, from
00023                    which I took the rasterizer sources in a format
00024                    independent from X11.
00025                      Thanks to all people who make free software living!
00026 --------------------------------------------------------------------------*/
00027   
00028 
00029 #define T1TYPES_H
00030 
00031 
00032 typedef struct
00033 {
00034   int flags;
00035   int chars;
00036   int hkern;
00037 } METRICS_ENTRY;
00038 
00039 
00040 typedef struct 
00041 {
00042   char *pFontFileName; /* Pointer to the font's filename */
00043   char *pAfmFileName;  /* Pointer to the afm filename, IFF set explicitly */
00044   FontInfo *pAFMData;  /* A pointer to a struct which gives access to all
00045                        the data contained in the .afm-file. If this
00046                        pointer is NULL, no .afm-file had been found.
00047                        => There's no advanced info on the font available.
00048                      */
00049   psfont *pType1Data;  /* A pointer to a struct giving access to all
00050                        information contained in the .pfa/.pfb-file. This
00051                        is needed! */
00052   int *pEncMap;           /* For fast mapping from charnames to encoding
00053                           indices */
00054   METRICS_ENTRY *pKernMap;   /* dito */
00055   int KernMapSize;
00056   char **pFontEnc;        /* This is the pointer to the encoding array
00057                           associated with that particular font. If
00058                           FontEnc=NULL, it means the internal
00059                           (fontspecific)  encoding is to be used. */
00060   char *vm_base;  /* The base address of the virtual memory area for this
00061                    font. It must be stored in order to be able to realloc
00062                    and free those memory areas later. */
00063   void *pFontSizeDeps;  /* This one points to a linked list of structures
00064                         which store all font size dependent data. */
00065   double FontMatrix[4]; /* Two matrices which store the font matrix and special
00066                         Transformation to be applied, such as slant and
00067                         extend or probably some rotation. */
00068   double FontTransform[4];
00069   float slant;    /* A slant factor for the font */
00070   float extend;   /* A extension factor for the font */
00071   float UndrLnPos;     /* Parameters for ~lining rules */
00072   float UndrLnThick;
00073   float OvrLnPos;
00074   float OvrLnThick;
00075   float OvrStrkPos;
00076   float OvrStrkThick;
00077   float StrokeWidth;
00078   float SavedStrokeWidth;
00079   
00080   unsigned short physical; /* This entry is used to decide, whether a
00081                            font is associated with an own physical
00082                            fontfile, or whether it has been created
00083                            as a "logical" font by copying another
00084                            "physical" font. */ 
00085   unsigned short refcount; /* At load time this counter is set to 1. Every
00086                            time, a T1_CopyFont() is executed on this font,
00087                            this counter is incremented by 1. This gives
00088                            the possibility to decide whether a physical
00089                            font is used by some logical font. */
00090   short space_position; /* The position where "space" is encoded, is saved
00091                         in this entry. The space character needs special
00092                         treatment. Saving its position here yields faster
00093                         execution during rastering of strings with a
00094                         user-supplied space-offset! */
00095   short info_flags;     /* Here some info may be stored */
00096 } FONTPRIVATE;
00097 
00098 
00099 /* A structure representing a matrix */
00100 typedef struct
00101 {
00102   double cxx;
00103   double cyx;
00104   double cxy;
00105   double cyy;
00106 } T1_TMATRIX;
00107 
00108 
00109 /* Following struct is used for storing all information for a particular
00110    rendered character glyph */
00111 typedef struct
00112 {
00113   char *bits;         /* A pointer to the characters local bitmap */
00114   struct              /* A struct containing diverse metric information */
00115   {
00116     int ascent;
00117     int descent;
00118     int leftSideBearing;
00119     int rightSideBearing;
00120     int advanceX;
00121     int advanceY;
00122   } metrics;
00123   void *pFontCacheInfo;
00124   unsigned long bpp;    /* The number of bits that represent 1 pixel */
00125 } GLYPH;
00126 
00127 
00128 
00129 /* Next comes the struct declaration for FontSizeDeps, which stores size
00130    specific data of a font */
00131 typedef struct
00132 {
00133   GLYPH    *pFontCache;         /* Pointer to the cache area of this
00134                                font at this size */
00135   void     *pNextFontSizeDeps;  /* A pointer to the next size's
00136                                FontSizeDeps-structure. */
00137   void     *pPrevFontSizeDeps;  /* A pointer to the previous size's
00138                                FontSizeDeps-structure or NULL if
00139                                the current is the first. */
00140   struct XYspace *pCharSpaceLocal;    /* This is a scaled version of the
00141                                     global version for this font. */
00142   float    size;                /* The desired size, to be specified
00143                                in bp's. */
00144   int      antialias;           /* Switch for marking the current size
00145                                antialiased */
00146 } FONTSIZEDEPS;
00147 
00148 
00149 
00150 /* A data type that makes most important information available to user. */
00151 typedef struct
00152 {
00153   int      width;       /* The glyph's width */
00154   BBox     bbox;        /* The glyph's bounding box */
00155   int      numchars;    /* The number of characters in the glyph (string) */
00156   int      *charpos;    /* A pointer to an integer array were the horizontal
00157                         positions in (afm units) of the individual
00158                         characters in the string are stored */
00159 } METRICSINFO;
00160 
00161 
00162 /* Handling of outlines: These definitions  decouple from the type 1 rasterizers
00163    def's and make the necessary stuff available to end users */
00164  
00165 #define   FRACTBITS     16   /* number of fractional bits in 'fractpel'      */
00166 /* From/to conversion of pels/fractpels */
00167 #define   T1_TOPATHPOINT(p)      (((long)p)<<FRACTBITS)
00168 #define   PPHALF                 (1<<(FRACTBITS-1))
00169 #define   T1_NEARESTPOINT(fp)    (((fp)+PPHALF)>>FRACTBITS)
00170 
00171 /* A fractional point */
00172 typedef struct {
00173   long x;
00174   long y;
00175 } T1_PATHPOINT;
00176 
00177 
00178 /* A straight outline segment, stroked or not stroked */
00179 typedef struct pathsegment {  
00180   char type;                /* type of segment (line or move) */
00181   unsigned char flag;       /* type1 rasterizer internal stuff */
00182   short references;         /* type1 rasterizer internal stuff */
00183   unsigned char size;       /* size of the structure */
00184   unsigned char context;    /* index to device context */
00185   struct pathsegment *link; /* pointer to next structure in linked list */
00186   struct pathsegment *last; /* pointer to last structure in list */
00187   T1_PATHPOINT    dest;     /* relative ending location of path segment */
00188 } T1_PATHSEGMENT;
00189 
00190 /* A third order bezier segment */
00191 typedef struct bezierpathsegment {
00192   char type;                /* type of segment (bezier) */
00193   unsigned char flag;       /* type1 rasterizer internal stuff */
00194   short references;         /* type1 rasterizer internal stuff */
00195   unsigned char size;       /* as with any 'segment' type */
00196   unsigned char context;    /* as with any 'segment' type */
00197   T1_PATHSEGMENT *link;     /* as with any 'segment' type */
00198   T1_PATHSEGMENT *last;     /* as with any 'segment' type */
00199   T1_PATHPOINT    dest;     /* ending point (D) */
00200   T1_PATHPOINT    B;        /* control point B */
00201   T1_PATHPOINT    C;        /* control point C */
00202 } T1_BEZIERSEGMENT;
00203 
00204 typedef T1_PATHSEGMENT  T1_OUTLINE;
00205 
00206 
00207 /* Two structures for handling composite character data */
00208 /* One structure for each symbol of the composite character */
00209 typedef struct
00210 {
00211   int piece;               /* the index of the current symbol */
00212   int deltax;              /* horizontal displacement of current symbol in CS */ 
00213   int deltay;              /* vertical displacement of current symbol in CS */ 
00214 } T1_COMP_PIECE;
00215 
00216 /* This one defines the composite character, the number of pieces and how to
00217    access their data. */
00218 typedef struct 
00219 {
00220   int compchar;             /* the base character in the current encoding */
00221   int numPieces;            /* the number of defined pieces including the base char */
00222   T1_COMP_PIECE *pieces;   /* a pointer to the pieces' information */
00223 } T1_COMP_CHAR_INFO;
00224