1 /*--------------------------------------------------------------------------
2   ----- File:        t1types.h
3   ----- Author:      Rainer Menzner (Rainer.Menzner@web.de)
4   ----- Date:        2004-12-09
5   ----- Description: This file is part of the t1-library. It contains
6                      type definitions used by the t1-library.
7   ----- Copyright:   t1lib is copyrighted (c) Rainer Menzner, 1996-2004.
8                      As of version 0.5, t1lib is distributed under the
9 		     GNU General Public Library Lincense. The
10 		     conditions can be found in the files LICENSE and
11 		     LGPL, which should reside in the toplevel
12 		     directory of the distribution.  Please note that
13 		     there are parts of t1lib that are subject to
14 		     other licenses:
15 		     The parseAFM-package is copyrighted by Adobe Systems
16 		     Inc.
17 		     The type1 rasterizer is copyrighted by IBM and the
18 		     X11-consortium.
19   ----- Warranties:  Of course, there's NO WARRANTY OF ANY KIND :-)
20   ----- Credits:     I want to thank IBM and the X11-consortium for making
21                      their rasterizer freely available.
22 		     Also thanks to Piet Tutelaers for his ps2pk, from
23 		     which I took the rasterizer sources in a format
24 		     independent from X11.
25                      Thanks to all people who make free software living!
26 --------------------------------------------------------------------------*/
27 
28 
29 #define T1TYPES_H
30 
31 #include "sysconf.h"
32 
33 typedef struct
34 {
35   int flags;
36   int chars;
37   int hkern;
38 } METRICS_ENTRY;
39 
40 
41 typedef struct
42 {
43   char *pFontFileName; /* Pointer to the font's filename */
44   char *pAfmFileName;  /* Pointer to the afm filename, IFF set explicitly */
45   FontInfo *pAFMData;  /* A pointer to a struct which gives access to all
46 			  the data contained in the .afm-file. If this
47 			  pointer is NULL, no .afm-file had been found.
48 			  => There's no advanced info on the font available.
49 		       */
50   psfont *pType1Data;  /* A pointer to a struct giving access to all
51 			  information contained in the .pfa/.pfb-file. This
52 			  is needed! */
53   int *pEncMap;           /* For fast mapping from charnames to encoding
54 			     indices */
55   METRICS_ENTRY *pKernMap;   /* dito */
56   int KernMapSize;
57   char **pFontEnc;        /* This is the pointer to the encoding array
58 			     associated with that particular font. If
59 			     FontEnc=NULL, it means the internal
60 			     (fontspecific)  encoding is to be used. */
61   char *vm_base;  /* The base address of the virtual memory area for this
62 		     font. It must be stored in order to be able to realloc
63 		     and free those memory areas later. */
64   void *pFontSizeDeps;  /* This one points to a linked list of structures
65 			   which store all font size dependent data. */
66   double FontMatrix[4]; /* Two matrices which store the font matrix and special
67 			   Transformation to be applied, such as slant and
68 			   extend or probably some rotation. */
69   double FontTransform[4];
70   float slant;    /* A slant factor for the font */
71   float extend;   /* A extension factor for the font */
72   float UndrLnPos;     /* Parameters for ~lining rules */
73   float UndrLnThick;
74   float OvrLnPos;
75   float OvrLnThick;
76   float OvrStrkPos;
77   float OvrStrkThick;
78   float StrokeWidth;
79   float SavedStrokeWidth;
80 
81   unsigned short physical; /* This entry is used to decide, whether a
82 			      font is associated with an own physical
83 			      fontfile, or whether it has been created
84 			      as a "logical" font by copying another
85 			      "physical" font. */
86   unsigned short refcount; /* At load time this counter is set to 1. Every
87 			      time, a T1_CopyFont() is executed on this font,
88 			      this counter is incremented by 1. This gives
89 			      the possibility to decide whether a physical
90 			      font is used by some logical font. */
91   short space_position; /* The position where "space" is encoded, is saved
92 			   in this entry. The space character needs special
93 			   treatment. Saving its position here yields faster
94 			   execution during rastering of strings with a
95 			   user-supplied space-offset! */
96   short info_flags;     /* Here some info may be stored */
97 } FONTPRIVATE;
98 
99 
100 /* A structure representing a matrix */
101 typedef struct
102 {
103   double cxx;
104   double cyx;
105   double cxy;
106   double cyy;
107 } T1_TMATRIX;
108 
109 
110 /* Following struct is used for storing all information for a particular
111    rendered character glyph */
112 typedef struct
113 {
114   char *bits;         /* A pointer to the characters local bitmap */
115   struct              /* A struct containing diverse metric information */
116   {
117     int ascent;
118     int descent;
119     int leftSideBearing;
120     int rightSideBearing;
121     int advanceX;
122     int advanceY;
123   } metrics;
124   void *pFontCacheInfo;
125   unsigned long bpp;    /* The number of bits that represent 1 pixel */
126 } GLYPH;
127 
128 
129 
130 /* Next comes the struct declaration for FontSizeDeps, which stores size
131    specific data of a font */
132 typedef struct
133 {
134   GLYPH    *pFontCache;         /* Pointer to the cache area of this
135 				   font at this size */
136   void     *pNextFontSizeDeps;  /* A pointer to the next size's
137 				   FontSizeDeps-structure. */
138   void     *pPrevFontSizeDeps;  /* A pointer to the previous size's
139 				   FontSizeDeps-structure or NULL if
140 				   the current is the first. */
141   struct XYspace *pCharSpaceLocal;    /* This is a scaled version of the
142 					 global version for this font. */
143   float    size;                /* The desired size, to be specified
144 				   in bp's. */
145   int      antialias;           /* Switch for marking the current size
146 				   antialiased */
147 } FONTSIZEDEPS;
148 
149 
150 
151 /* A data type that makes most important information available to user. */
152 typedef struct
153 {
154   int      width;       /* The glyph's width */
155   BBox     bbox;        /* The glyph's bounding box */
156   int      numchars;    /* The number of characters in the glyph (string) */
157   int      *charpos;    /* A pointer to an integer array were the horizontal
158 			   positions in (afm units) of the individual
159 			   characters in the string are stored */
160 } METRICSINFO;
161 
162 
163 /* Handling of outlines: These definitions  decouple from the type 1 rasterizers
164    def's and make the necessary stuff available to end users */
165 
166 #define   FRACTBITS     16   /* number of fractional bits in 'fractpel'      */
167 /* From/to conversion of pels/fractpels */
168 #define   T1_TOPATHPOINT(p)      (((T1_AA_TYPE32)p)<<FRACTBITS)
169 #define   PPHALF                 (1<<(FRACTBITS-1))
170 #define   T1_NEARESTPOINT(fp)    (((fp)+PPHALF)>>FRACTBITS)
171 
172 /* A fractional point */
173 typedef struct {
174   T1_AA_TYPE32 x;
175   T1_AA_TYPE32 y;
176 } T1_PATHPOINT;
177 
178 
179 /* A straight outline segment, stroked or not stroked */
180 typedef struct pathsegment {
181   char type;                /* type of segment (line or move) */
182   unsigned char flag;       /* type1 rasterizer internal stuff */
183   short references;         /* type1 rasterizer internal stuff */
184   unsigned char size;       /* size of the structure */
185   unsigned char context;    /* index to device context */
186   struct pathsegment *link; /* pointer to next structure in linked list */
187   struct pathsegment *last; /* pointer to last structure in list */
188   T1_PATHPOINT    dest;     /* relative ending location of path segment */
189 } T1_PATHSEGMENT;
190 
191 /* A third order bezier segment */
192 typedef struct bezierpathsegment {
193   char type;                /* type of segment (bezier) */
194   unsigned char flag;       /* type1 rasterizer internal stuff */
195   short references;         /* type1 rasterizer internal stuff */
196   unsigned char size;       /* as with any 'segment' type */
197   unsigned char context;    /* as with any 'segment' type */
198   T1_PATHSEGMENT *link;     /* as with any 'segment' type */
199   T1_PATHSEGMENT *last;     /* as with any 'segment' type */
200   T1_PATHPOINT    dest;     /* ending point (D) */
201   T1_PATHPOINT    B;        /* control point B */
202   T1_PATHPOINT    C;        /* control point C */
203 } T1_BEZIERSEGMENT;
204 
205 typedef T1_PATHSEGMENT  T1_OUTLINE;
206 
207 
208 /* Two structures for handling composite character data */
209 /* One structure for each symbol of the composite character */
210 typedef struct
211 {
212   int piece;               /* the index of the current symbol */
213   int deltax;              /* horizontal displacement of current symbol in CS */
214   int deltay;              /* vertical displacement of current symbol in CS */
215 } T1_COMP_PIECE;
216 
217 /* This one defines the composite character, the number of pieces and how to
218    access their data. */
219 typedef struct
220 {
221   int compchar;             /* the base character in the current encoding */
222   int numPieces;            /* the number of defined pieces including the base char */
223   T1_COMP_PIECE *pieces;   /* a pointer to the pieces' information */
224 } T1_COMP_CHAR_INFO;
225 
226