upgraded to 3.4.3.
[swftools.git] / pdf2swf / ttf2pt1 / global.h
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_DISABLED  0x80000000 /* special flag: temporary disable debugging */
82
83 /* at what we want to look now */
84 #ifndef DEBUG
85 #       define DEBUG (0)
86 #endif
87
88 /* uncomment the next line if debugging data is wanted for one glyph only */
89 /* #define DBG_GLYPH    "_517"  /* */
90
91 #if DEBUG==0
92 #       define ISDBG(name)      (0)
93 #       define ENABLEDBG(condition) (0)
94 #       define DISABLEDBG(condition) (0)
95 #else
96         extern int debug; /* collection of the flags */
97 /* this ISDBG will only work on ANSI C, not K&R */
98 #       define ISDBG(name)      ( (debug & DEBUG_DISABLED) ? 0 : (debug & (DEBUG_##name)) )
99 #       define ENABLEDBG(condition) ( (condition) ? (debug&=~DEBUG_DISABLED) : 0 )
100 #       define DISABLEDBG(condition) ( (condition) ? (debug|=DEBUG_DISABLED) : 0 )
101 #endif
102
103 #ifdef DBG_GLYPH
104 #       define DBG_TO_GLYPH(g) DISABLEDBG( strcmp( (g)->name, DBG_GLYPH ) )
105 #       define DBG_FROM_GLYPH(g) ENABLEDBG(1)
106 #else
107 #       define DBG_TO_GLYPH(g) (0)
108 #       define DBG_FROM_GLYPH(g) (0)
109 #endif
110
111 /* prototypes */
112 int iscale( int val);
113 double fscale( double val);
114 int unicode_rev_lookup( int unival);
115 void bmp_outline( GLYPH *g, int scale, char *bmap,
116         int xsz, int ysz, int xoff, int yoff);
117 int isign( int x);
118 int fsign( double x);
119
120 /* global metrics for a font */
121
122 struct font_metrics {
123         /* post */
124         double  italic_angle;
125         short   underline_position;
126         short   underline_thickness;
127         short   is_fixed_pitch;
128
129         /* hhea */
130         short   ascender; 
131         short   descender;
132
133         /* head */
134         unsigned short  units_per_em;
135         short   bbox[4];
136
137         /* name */
138         char    *name_copyright;
139         char    *name_family;
140         char    *name_style;
141         char    *name_full;
142         char    *name_version;
143         char    *name_ps;
144
145         /* other */
146         int             force_bold;
147 };
148
149 /* size of the encoding table - glyphs beyond 255 are actually unnumbered */
150
151 #define ENCTABSZ        1024
152
153 /* switch table structure for front-ends */
154
155 #define MAXSUFFIX       10
156
157 struct frontsw {
158         char  *name; /* name of the front end */
159         char  *descr; /* description of the front end */
160         char  *suffix[MAXSUFFIX]; /* possible file name suffixes */
161
162         void  (*open)(char *fname, char *arg); /* open font file */
163         void  (*close)(void); /* close font file */
164         int   (*nglyphs)(void); /* get the number of glyphs */
165         int   (*glnames)(GLYPH *glyphs); /* get the names of glyphs */
166         void  (*glmetrics)(GLYPH *glyphs); /* get the metrics of glyphs */
167         int   (*glenc)(GLYPH *glyphs, int *enc, int *unimap); /* get the encoding */
168         void  (*fnmetrics)(struct font_metrics *fm); /* get the font metrics */
169         void  (*glpath)(int glyphno, GLYPH *glyphs); /* get the glyph path */
170         void  (*kerning)(GLYPH *glyph_list); /* extract the kerning data */
171 };