6 /* glyph entry, one drawing command */
7 typedef struct gentry {
8 /* this list links all GENTRYs of a GLYPH sequentially */
9 struct gentry *next; /* double linked list */
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
17 struct gentry *cntr[2]; /* double-linked circular list */
18 /* convenience handles */
24 int val[2][3]; /* integer values */
27 double val[2][3]; /* floating values */
29 } points; /* absolute values, NOT deltas */
30 /* convenience handles */
31 #define ipoints points.i.val
32 #define fpoints points.f.val
33 #define ixn ipoints[0]
34 #define iyn ipoints[1]
35 #define fxn fpoints[0]
36 #define fyn fpoints[1]
51 #define GEF_FLOAT 0x02 /* entry contains floating point data */
53 unsigned char dir; /* used to temporarily store the values for
54 * the directions of the ends of curves */
56 #define CVDIR_FUP 0x02 /* goes over the line connecting the ends */
57 #define CVDIR_FEQUAL 0x01 /* coincides with the line connecting the
59 #define CVDIR_FDOWN 0x00 /* goes under the line connecting the ends */
60 #define CVDIR_FRONT 0x0F /* mask of all front directions */
62 #define CVDIR_RSAME 0x30 /* is the same as for the front end */
63 #define CVDIR_RUP 0x20 /* goes over the line connecting the ends */
64 #define CVDIR_REQUAL 0x10 /* coincides with the line connecting the
66 #define CVDIR_RDOWN 0x00 /* goes under the line connecting the ends */
67 #define CVDIR_REAR 0xF0 /* mask of all rear directions */
69 signed char stemid; /* connection to the substituted stem group */
78 /* stem structure, describes one [hv]stem */
79 /* acually, it describes one border of a stem */
80 /* the whole stem is a pair of these structures */
83 short value; /* value of X or Y coordinate */
84 short origin; /* point of origin for curve stems */
85 GENTRY *ge; /* entry that has (value, origin) as its first dot */
86 /* also for all the stems the couple (value, origin)
87 * is used to determine whether a stem is relevant for a
88 * line, it's considered revelant if this tuple is
89 * equal to any of the ends of the line.
90 * ge is also used to resolve ambiguity if there is more than
91 * one line going through certain pointi, it is used to
92 * distinguish these lines.
95 short from, to; /* values of other coordinate between
96 * which this stem is valid */
99 /* ordering of ST_END, ST_FLAT, ST_ZONE is IMPORTANT for sorting */
100 #define ST_END 0x01 /* end of line, lowest priority */
101 #define ST_FLAT 0x02 /* stem is defined by a flat line, not a
103 #define ST_ZONE 0x04 /* pseudo-stem, the limit of a blue zone */
104 #define ST_UP 0x08 /* the black area is to up or right from
106 #define ST_3 0x20 /* first stem of [hv]stem3 */
107 #define ST_BLUE 0x40 /* stem is in blue zone */
108 #define ST_TOPZONE 0x80 /* 1 - top zone, 0 - bottom zone */
109 #define ST_VERT 0x100 /* vertical stem (used in substitutions) */
112 #define MAX_STEMS 2000 /* we can't have more stems than path
113 * elements (or hope so) */
114 #define NSTEMGRP 50 /* maximal number of the substituted stem groups */
116 /* structure for economical representation of the
120 typedef struct stembounds {
121 short low; /* low bound */
122 short high; /* high bound */
123 char isvert; /* 1 - vertical, 0 - horizontal */
124 char already; /* temp. flag: is aleready included */
128 unsigned id; /* ID of the second glyph */
129 int val; /* kerning value */
132 typedef struct contour {
134 short inside; /* inside which contour */
140 typedef struct glyph {
141 int char_no;/* Encoding of glyph */
142 int orig_code;/* code of glyph in the font's original encoding */
143 char *name; /* Postscript name of glyph */
144 int xMin, yMin, xMax, yMax; /* values from TTF dictionary */
145 int lsb; /* left sidebearing */
146 int ttf_pathlen; /* total length of TTF paths */
149 #define GF_USED 0x0001 /* whether is this glyph used in T1 font */
150 #define GF_FLOAT 0x0002 /* thys glyph contains floating point entries */
152 GENTRY *entries;/* doube linked list of entries */
153 GENTRY *lastentry; /* the last inserted entry */
154 GENTRY *path; /* beggining of the last path */
155 int oldwidth; /* actually also scaled */
157 #define MAXLEGALWIDTH 10000
159 struct kern *kern; /* kerning data */
160 int kerncount; /* number of kerning pairs */
161 int kernalloc; /* for how many pairs we have space */
163 STEM *hstems; /* global horiz. and vert. stems */
165 int nhs, nvs; /* numbers of stems */
167 STEMBOUNDS *sbstems; /* substituted stems for all the groups */
168 short *nsbs; /* indexes of the group ends in the common array */
169 int nsg; /* actual number of the stem groups */
170 int firstsubr; /* first substistuted stems subroutine number */
172 CONTOUR *contours; /* it is not used now */
175 int rymin, rymax; /* real values */
176 /* do we have flat surfaces on top/bottom */
177 char flatymin, flatymax;
181 extern int stdhw, stdvw; /* dominant stems widths */
182 extern int stemsnaph[12], stemsnapv[12]; /* most typical stem width */
184 extern int bluevalues[14];
186 extern int otherblues[10];
188 extern int bbox[4]; /* the FontBBox array */
189 extern double italic_angle;
191 extern GLYPH *glyph_list;
192 extern int encoding[]; /* inverse of glyph[].char_no */
194 /* prototypes of functions */
195 void rmoveto( int dx, int dy);
196 void rlineto( int dx, int dy);
197 void rrcurveto( int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
198 void assertpath( GENTRY * from, char *file, int line, char *name);
200 void fg_rmoveto( GLYPH * g, double x, double y);
201 void ig_rmoveto( GLYPH * g, int x, int y);
202 void fg_rlineto( GLYPH * g, double x, double y);
203 void ig_rlineto( GLYPH * g, int x, int y);
204 void fg_rrcurveto( GLYPH * g, double x1, double y1,
205 double x2, double y2, double x3, double y3);
206 void ig_rrcurveto( GLYPH * g, int x1, int y1,
207 int x2, int y2, int x3, int y3);
208 void g_closepath( GLYPH * g);
210 void pathtoint( GLYPH *g);
211 void ffixquadrants( GLYPH *g);
212 void flattencurves( GLYPH * g);
213 int checkcv( GENTRY * ge, int dx, int dy);
214 void iclosepaths( GLYPH * g);
215 void fclosepaths( GLYPH * g);
216 void smoothjoints( GLYPH * g);
217 void buildstems( GLYPH * g);
218 void fstraighten( GLYPH * g);
219 void istraighten( GLYPH * g, int zigonly);
220 void isplitzigzags( GLYPH * g);
221 void fsplitzigzags( GLYPH * g);
222 void fforceconcise( GLYPH * g);
223 void iforceconcise( GLYPH * g);
224 void reversepathsfromto( GENTRY * from, GENTRY * to);
225 void reversepaths( GLYPH * g);
226 void dumppaths( GLYPH * g, GENTRY *start, GENTRY *end);
227 void print_glyph( int glyphno);
228 int print_glyph_subs( int glyphno, int startid);
229 void print_glyph_metrics( int code, int glyphno);
230 void findblues(void);
231 void stemstatistics(void);
232 void docorrectwidth(void);
233 void addkernpair( unsigned id1, unsigned id2, int unscval);
234 void print_kerning( FILE *afm_file);