1 /*
2  * see COPYRIGHT
3  */
4 
5 
6 /* options */
7 
8 extern int      encode;	/* encode the resulting file */
9 extern int      pfbflag;	/* produce compressed file */
10 extern int      wantafm;	/* want to see .afm instead of .t1a on stdout */
11 extern int      correctvsize;	/* try to correct the vertical size of characters */
12 extern int      wantuid;	/* user wants UniqueID entry in the font */
13 extern int      allglyphs;	/* convert all glyphs, not only 256 of them */
14 extern int      warnlevel;	/* the level of permitted warnings */
15 extern int      forcemap; /* do mapping even on non-Unicode fonts */
16 /* options - maximal limits */
17 extern int      max_stemdepth;	/* maximal depth of stem stack in interpreter */
18 /* options - debugging */
19 extern int      absolute;	/* print out in absolute values */
20 extern int      reverse;	/* reverse font to Type1 path directions */
21 /* options - suboptions of Outline Processing */
22 extern int      optimize;	/* enables space optimization */
23 extern int      smooth;	/* enable smoothing of outlines */
24 extern int      transform;	/* enables transformation to 1000x1000 matrix */
25 extern int      hints;	/* enables autogeneration of hints */
26 extern int      subhints;	/* enables autogeneration of substituted hints */
27 extern int      trybold;	/* try to guess whether the font is bold */
28 extern int      correctwidth;	/* try to correct the character width */
29 extern int      vectorize;	/* vectorize the bitmaps */
30 extern int      use_autotrace;	/* use the autotrace library on bitmap */
31 /* options - suboptions of File Generation */
32 extern int      gen_pfa;	/* generate the font file */
33 extern int      gen_afm;	/* generate the metrics file */
34 extern int      gen_dvienc;	/* generate the dvips encoding file */
35 
36 /* not quite options to select a particular source encoding */
37 extern int      force_pid; /* specific platform id */
38 extern int      force_eid; /* specific encoding id */
39 
40 /* other globals */
41 extern FILE    *null_file, *pfa_file, *afm_file, *dvienc_file;
42 extern int      numglyphs;
43 
44 /* warnings */
45 
46 #define WARNING_1	if(warnlevel >= 1)
47 #define WARNING_2	if(warnlevel >= 2)
48 #define WARNING_3	if(warnlevel >= 3)
49 #define WARNING_4	if(warnlevel >= 4)
50 
51 /*
52  * Bitmap control macros
53  */
54 
55 #define BITMAP_BYTES(size)	(((size)+7)>>3)
56 #define DEF_BITMAP(name, size)	unsigned char name[BITMAP_BYTES(size)]
57 #define SET_BITMAP(name, bit)	( name[(bit)>>3] |= (1<<((bit)&7)) )
58 #define CLR_BITMAP(name, bit)	( name[(bit)>>3] &= ~(1<<((bit)&7)) )
59 #define IS_BITMAP(name, bit)	( name[(bit)>>3] & (1<<((bit)&7)) )
60 
61 /* debugging */
62 
63 /* debug flags */
64 #define DEBUG_UNICODE	0x00000001 /* unicode to 8-bit code conversion */
65 #define DEBUG_MAINSTEMS	0x00000002 /* glyph-wide main stem generation */
66 #define DEBUG_SUBSTEMS	0x00000004 /* substituted stem generation */
67 #define DEBUG_STEMS	(DEBUG_MAINSTEMS|DEBUG_SUBSTEMS)
68 #define DEBUG_REVERSAL	0x00000008 /* reversal of the paths */
69 #define DEBUG_FIXCVDIR	0x00000010 /* fixcvdir() */
70 #define DEBUG_STEMOVERLAP	0x00000020 /* stemoverlap() */
71 #define DEBUG_BLUESTEMS	0x00000040 /* markbluestems() */
72 #define DEBUG_STRAIGHTEN	0x00000080 /* markbluestems() */
73 #define DEBUG_EXTMAP	0x00000100 /* parsing of external map */
74 #define DEBUG_TOINT	0x00000200 /* conversion of path to integer */
75 #define DEBUG_BUILDG	0x00000400 /* building of glyph path */
76 #define DEBUG_QUAD	0x00000800 /* splitting curves by quadrants */
77 #define DEBUG_SQEQ	0x00001000 /* square equation solver */
78 #define DEBUG_COMPOSITE	0x00002000 /* handling of composite glyphs */
79 #define DEBUG_FCONCISE	0x00004000 /* normalization of curves */
80 #define DEBUG_FT		0x00008000 /* FreeType front-end */
81 #define DEBUG_BITMAP	0x00010000 /* conversion from bitmap */
82 #define DEBUG_DISABLED	0x80000000 /* special flag: temporary disable debugging */
83 
84 /* at what we want to look now */
85 #ifndef DEBUG
86 #	define DEBUG (0)
87 #endif
88 
89 /* uncomment the next line if debugging data is wanted for one glyph only */
90 /* #define DBG_GLYPH	"C118"  /* */
91 
92 #if DEBUG==0
93 #	define ISDBG(name)	(0)
94 #	define ENABLEDBG(condition) (0)
95 #	define DISABLEDBG(condition) (0)
96 #else
97 	extern int debug; /* collection of the flags */
98 /* this ISDBG will only work on ANSI C, not K&R */
99 #	define ISDBG(name)	( (debug & DEBUG_DISABLED) ? 0 : (debug & (DEBUG_##name)) )
100 #	define ENABLEDBG(condition) ( (condition) ? (debug&=~DEBUG_DISABLED) : 0 )
101 #	define DISABLEDBG(condition) ( (condition) ? (debug|=DEBUG_DISABLED) : 0 )
102 #endif
103 
104 #ifdef DBG_GLYPH
105 #	define DBG_TO_GLYPH(g) DISABLEDBG( strcmp( (g)->name, DBG_GLYPH ) )
106 #	define DBG_FROM_GLYPH(g) ENABLEDBG(1)
107 #else
108 #	define DBG_TO_GLYPH(g) (0)
109 #	define DBG_FROM_GLYPH(g) (0)
110 #endif
111 
112 /* prototypes */
113 int iscale( int val);
114 double fscale( double val);
115 int unicode_rev_lookup( int unival);
116 void bmp_outline( GLYPH *g, int scale, char *bmap,
117 	int xsz, int ysz, int xoff, int yoff);
118 int isign( int x);
119 int fsign( double x);
120 char *dupcnstring( unsigned char *s, int len);
121 
122 /* global metrics for a font */
123 
124 struct font_metrics {
125 	/* post */
126 	double	italic_angle;
127 	short	underline_position;
128 	short	underline_thickness;
129 	short	is_fixed_pitch;
130 
131 	/* hhea */
132 	short	ascender;
133 	short	descender;
134 
135 	/* head */
136 	unsigned short	units_per_em;
137 	short   bbox[4];
138 
139 	/* name */
140 	char	*name_copyright;
141 	char	*name_family;
142 	char	*name_style;
143 	char	*name_full;
144 	char	*name_version;
145 	char	*name_ps;
146 
147 	/* other */
148 	int		force_bold;
149 };
150 
151 /* size of the encoding table - glyphs beyond 255 are actually unnumbered */
152 
153 #define ENCTABSZ	1024
154 
155 /* switch table structure for front-ends */
156 
157 #define MAXSUFFIX	10
158 
159 struct frontsw {
160 	char  *name; /* name of the front end */
161 	char  *descr; /* description of the front end */
162 	char  *suffix[MAXSUFFIX]; /* possible file name suffixes */
163 
164 	void  (*open)(char *fname, char *arg); /* open font file */
165 	void  (*close)(void); /* close font file */
166 	int   (*nglyphs)(void); /* get the number of glyphs */
167 	int   (*glnames)(GLYPH *glyphs); /* get the names of glyphs */
168 	void  (*glmetrics)(GLYPH *glyphs); /* get the metrics of glyphs */
169 	int   (*glenc)(GLYPH *glyphs, int *enc, int *unimap); /* get the encoding */
170 	void  (*fnmetrics)(struct font_metrics *fm); /* get the font metrics */
171 	void  (*glpath)(int glyphno, GLYPH *glyphs); /* get the glyph path */
172 	void  (*kerning)(GLYPH *glyph_list); /* extract the kerning data */
173 };
174