source: trunk/filemanager/tp/dompdf/lib/ttf2ufm/ttf2ufm-src/pt1.h @ 2000

Revision 2000, 9.1 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Implementação do módulo gerenciador de arquivos

Line 
1/*
2 * see COPYRIGHT
3 */
4
5
6/* glyph entry, one drawing command */
7typedef struct gentry {
8        /* this list links all GENTRYs of a GLYPH sequentially */
9        struct gentry  *next;   /* double linked list */
10        struct gentry  *prev;
11
12        /* this list links all GENTRYs of one contour -
13         * of types GE_LINE and GE_CURVE only
14         * bkwd is also reused: in the very first entry (normally
15         * of type GE_MOVE) it points to g->entries
16         */
17        struct gentry  *cntr[2]; /* double-linked circular list */
18/* convenience handles */
19#define bkwd cntr[0]
20#define frwd cntr[1]
21
22        /* various extended structures used at some stage of transformation */
23        void *ext;
24
25        union {
26                struct {
27                        int  val[2][3]; /* integer values */
28                } i;
29                struct {
30                        double  val[2][3];      /* floating values */
31                } f;
32        } points; /* absolute values, NOT deltas */
33/* convenience handles */
34#define ipoints points.i.val
35#define fpoints points.f.val
36#define ixn ipoints[0]
37#define iyn ipoints[1]
38#define fxn fpoints[0]
39#define fyn fpoints[1]
40#define ix1     ixn[0]
41#define ix2 ixn[1]
42#define ix3 ixn[2]
43#define iy1     iyn[0]
44#define iy2 iyn[1]
45#define iy3 iyn[2]
46#define fx1     fxn[0]
47#define fx2 fxn[1]
48#define fx3 fxn[2]
49#define fy1     fyn[0]
50#define fy2 fyn[1]
51#define fy3 fyn[2]
52
53        char            flags;
54#define GEF_FLOAT       0x02 /* entry contains floating point data */
55#define GEF_LINE        0x04 /* entry looks like a line even if it's a curve */
56
57        unsigned char   dir; /* used to temporarily store the values for
58                                * the directions of the ends of curves */
59/* front end */
60#define CVDIR_FUP       0x02    /* goes over the line connecting the ends */
61#define CVDIR_FEQUAL    0x01    /* coincides with the line connecting the
62                                 * ends */
63#define CVDIR_FDOWN     0x00    /* goes under the line connecting the ends */
64#define CVDIR_FRONT     0x0F    /* mask of all front directions */
65/* rear end */
66#define CVDIR_RSAME     0x30    /* is the same as for the front end */
67#define CVDIR_RUP       0x20    /* goes over the line connecting the ends */
68#define CVDIR_REQUAL    0x10    /* coincides with the line connecting the
69                                 * ends */
70#define CVDIR_RDOWN     0x00    /* goes under the line connecting the ends */
71#define CVDIR_REAR      0xF0    /* mask of all rear directions */
72
73        signed char     stemid; /* connection to the substituted stem group */
74        char            type;
75#define GE_HSBW 'B'
76#define GE_MOVE 'M'
77#define GE_LINE 'L'
78#define GE_CURVE 'C'
79#define GE_PATH 'P'
80
81        /* indexes of the points to be used for calculation of the tangents */
82        signed char     ftg; /* front tangent */
83        signed char     rtg; /* rear tangent, -1 means "idx 2 of the previous entry" */
84}               GENTRY;
85
86/* stem structure, describes one [hv]stem  */
87/* acually, it describes one border of a stem */
88/* the whole stem is a pair of these structures */
89
90typedef struct stem {
91        short           value;  /* value of X or Y coordinate */
92        short           origin; /* point of origin for curve stems */
93        GENTRY         *ge; /* entry that has (value, origin) as its first dot */
94                /* also for all the stems the couple (value, origin)
95                 * is used to determine whether a stem is relevant for a
96                 * line, it's considered revelant if this tuple is
97                 * equal to any of the ends of the line.
98                 * ge is also used to resolve ambiguity if there is more than
99                 * one line going through certain pointi, it is used to
100                 * distinguish these lines.
101                 */
102         
103        short           from, to;       /* values of other coordinate between
104                                         * which this stem is valid */
105
106        short           flags;
107        /* ordering of ST_END, ST_FLAT, ST_ZONE is IMPORTANT for sorting */
108#define ST_END          0x01    /* end of line, lowest priority */
109#define ST_FLAT         0x02    /* stem is defined by a flat line, not a
110                                 * curve */
111#define ST_ZONE         0x04    /* pseudo-stem, the limit of a blue zone */
112#define ST_UP           0x08    /* the black area is to up or right from
113                                 * value */
114#define ST_3            0x20    /* first stem of [hv]stem3 */
115#define ST_BLUE         0x40    /* stem is in blue zone */
116#define ST_TOPZONE      0x80    /* 1 - top zone, 0 - bottom zone */
117#define ST_VERT     0x100       /* vertical stem (used in substitutions) */
118}               STEM;
119
120#define MAX_STEMS       2000    /* we can't have more stems than path
121                                 * elements (or hope so) */
122#define NSTEMGRP        50      /* maximal number of the substituted stem groups */
123
124/* structure for economical representation of the
125 * substituted stems
126 */
127
128typedef struct stembounds {
129        short low; /* low bound */
130        short high; /* high bound */
131        char isvert; /* 1 - vertical, 0 - horizontal */
132        char already; /* temp. flag: is aleready included */
133} STEMBOUNDS;
134
135struct kern {
136        unsigned id; /* ID of the second glyph */
137        int val; /* kerning value */
138};
139
140typedef struct contour {
141        short           ymin, xofmin;
142        short           inside; /* inside which contour */
143        char            direction;
144#define DIR_OUTER 1
145#define DIR_INNER 0
146}               CONTOUR;
147
148/* becnjcarson: allow glyphs to have multiple character codes.  This isn't 100%
149   perfect, but should be enough for most normal fonts. */
150#define GLYPH_MAX_ENCODINGS  (4)
151
152typedef struct glyph {
153        int             char_no;/* Encoding of glyph */
154        int             orig_code[GLYPH_MAX_ENCODINGS]; /* code(s) of glyph in the font's original encoding */
155        char           *name;   /* Postscript name of glyph */
156        int             xMin, yMin, xMax, yMax; /* values from TTF dictionary */
157        int             lsb; /* left sidebearing */
158        int             ttf_pathlen; /* total length of TTF paths */
159        short           width;
160        short           flags;
161#define GF_USED 0x0001          /* whether is this glyph used in T1 font */
162#define GF_FLOAT 0x0002         /* thys glyph contains floating point entries */
163
164        GENTRY         *entries;/* doube linked list of entries */
165        GENTRY         *lastentry;      /* the last inserted entry */
166        GENTRY         *path;   /* beggining of the last path */
167        int             oldwidth; /* actually also scaled */
168        int             scaledwidth;
169#define MAXLEGALWIDTH   10000
170
171        struct kern    *kern; /* kerning data */
172        int             kerncount; /* number of kerning pairs */
173        int             kernalloc; /* for how many pairs we have space */
174
175        STEM           *hstems; /* global horiz. and vert. stems */
176        STEM           *vstems;
177        int             nhs, nvs;       /* numbers of stems */
178
179        STEMBOUNDS     *sbstems; /* substituted stems for all the groups */
180        short          *nsbs; /* indexes of the group ends in the common array */
181        int             nsg; /* actual number of the stem groups */
182        int             firstsubr; /* first substistuted stems subroutine number */
183
184        CONTOUR        *contours;       /* it is not used now */
185        int             ncontours;
186
187        int             rymin, rymax;   /* real values */
188        /* do we have flat surfaces on top/bottom */
189        char            flatymin, flatymax;
190
191}               GLYPH;
192
193/* description of a dot for calculation of its distance to a curve */
194
195struct dot_dist {
196        double p[2 /*X,Y*/]; /* coordinates of a dot */
197        double dist2; /* squared distance from the dot to the curve */
198        short seg; /* the closest segment of the curve */
199};
200
201extern int      stdhw, stdvw;   /* dominant stems widths */
202extern int      stemsnaph[12], stemsnapv[12];   /* most typical stem width */
203
204extern int      bluevalues[14];
205extern int      nblues;
206extern int      otherblues[10];
207extern int      notherb;
208extern int      bbox[4];        /* the FontBBox array */
209extern double   italic_angle;
210
211extern GLYPH   *glyph_list;
212extern int    encoding[];       /* inverse of glyph[].char_no */
213
214/* prototypes of functions */
215void rmoveto( int dx, int dy);
216void rlineto( int dx, int dy);
217void rrcurveto( int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
218void assertpath( GENTRY * from, char *file, int line, char *name);
219
220void fg_rmoveto( GLYPH * g, double x, double y);
221void ig_rmoveto( GLYPH * g, int x, int y);
222void fg_rlineto( GLYPH * g, double x, double y);
223void ig_rlineto( GLYPH * g, int x, int y);
224void fg_rrcurveto( GLYPH * g, double x1, double y1,
225        double x2, double y2, double x3, double y3);
226void ig_rrcurveto( GLYPH * g, int x1, int y1,
227        int x2, int y2, int x3, int y3);
228void g_closepath( GLYPH * g);
229
230void pathtoint( GLYPH *g);
231void ffixquadrants( GLYPH *g);
232void flattencurves( GLYPH * g);
233int checkcv( GENTRY * ge, int dx, int dy);
234void iclosepaths( GLYPH * g);
235void fclosepaths( GLYPH * g);
236void smoothjoints( GLYPH * g);
237void buildstems( GLYPH * g);
238void fstraighten( GLYPH * g);
239void istraighten( GLYPH * g, int zigonly);
240void isplitzigzags( GLYPH * g);
241void fsplitzigzags( GLYPH * g);
242void fforceconcise( GLYPH * g);
243void iforceconcise( GLYPH * g);
244void reversepathsfromto( GENTRY * from, GENTRY * to);
245void reversepaths( GLYPH * g);
246void dumppaths( GLYPH * g, GENTRY *start, GENTRY *end);
247void print_glyph( int glyphno);
248int print_glyph_subs( int glyphno, int startid);
249void print_glyph_metrics( FILE *afm_file, int code, int glyphno);
250void print_glyph_metrics_ufm( FILE *ufm_file, int code, int glyphno);
251void findblues(void);
252void stemstatistics(void);
253void docorrectwidth(void);
254void addkernpair( unsigned id1, unsigned id2, int unscval);
255void print_kerning( FILE *afm_file);
256
257int fcrossrayscv( double curve[4][2], double *max1, double *max2);
258int fcrossraysge( GENTRY *ge1, GENTRY *ge2, double *max1, double *max2,
259        double crossdot[2][2]);
260double fdotsegdist2( double seg[2][2], double dot[2]);
261double fdotcurvdist2( double curve[4][2], struct dot_dist *dots, int ndots, double *maxp);
262void fapproxcurve( double cv[4][2], struct dot_dist *dots, int ndots);
Note: See TracBrowser for help on using the repository browser.