d8e9b025eb085db863d40306afcb9123eb4ae87f
[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
30 /* not quite options to select a particular source encoding */
31 extern int      force_pid; /* specific platform id */
32 extern int      force_eid; /* specific encoding id */
33
34 /* other globals */
35 extern FILE    *pfa_file, *afm_file;
36 extern int      numglyphs;
37
38 /* warnings */
39
40 #define WARNING_1       if(warnlevel >= 1)
41 #define WARNING_2       if(warnlevel >= 2)
42 #define WARNING_3       if(warnlevel >= 3)
43 #define WARNING_4       if(warnlevel >= 4)
44
45 /*
46  * Bitmap control macros
47  */
48
49 #define BITMAP_BYTES(size)      (((size)+7)>>3)
50 #define DEF_BITMAP(name, size)  unsigned char name[BITMAP_BYTES(size)]
51 #define SET_BITMAP(name, bit)   ( name[(bit)>>3] |= (1<<((bit)&7)) )
52 #define CLR_BITMAP(name, bit)   ( name[(bit)>>3] &= ~(1<<((bit)&7)) )
53 #define IS_BITMAP(name, bit)    ( name[(bit)>>3] & (1<<((bit)&7)) )
54
55 /* debugging */
56
57 /* debug flags */
58 #define DEBUG_UNICODE   0x00000001 /* unicode to 8-bit code conversion */
59 #define DEBUG_MAINSTEMS 0x00000002 /* glyph-wide main stem generation */
60 #define DEBUG_SUBSTEMS  0x00000004 /* substituted stem generation */
61 #define DEBUG_STEMS     (DEBUG_MAINSTEMS|DEBUG_SUBSTEMS)
62 #define DEBUG_REVERSAL  0x00000008 /* reversal of the paths */
63 #define DEBUG_FIXCVDIR  0x00000010 /* fixcvdir() */
64 #define DEBUG_STEMOVERLAP       0x00000020 /* stemoverlap() */
65 #define DEBUG_BLUESTEMS 0x00000040 /* markbluestems() */
66 #define DEBUG_STRAIGHTEN        0x00000080 /* markbluestems() */
67 #define DEBUG_EXTMAP    0x00000100 /* parsing of external map */
68 #define DEBUG_TOINT     0x00000200 /* conversion of path to integer */
69 #define DEBUG_BUILDG    0x00000400 /* building of glyph path */
70 #define DEBUG_QUAD      0x00000800 /* splitting curves by quadrants */
71 #define DEBUG_SQEQ      0x00001000 /* square equation solver */
72 #define DEBUG_COMPOSITE 0x00002000 /* handling of composite glyphs */
73 #define DEBUG_FCONCISE  0x00004000 /* normalization of curves */
74 #define DEBUG_FT                0x00008000 /* FreeType front-end */
75 #define DEBUG_DISABLED  0x80000000 /* special flag: temporary disable debugging */
76
77 /* at what we want to look now */
78 #ifndef DEBUG
79 #       define DEBUG (0)
80 #endif
81
82 /* uncomment the next line if debugging data is wanted for one glyph only */
83 /* #define DBG_GLYPH    "_517"  /* */
84
85 #if DEBUG==0
86 #       define ISDBG(name)      (0)
87 #       define ENABLEDBG(condition) (0)
88 #       define DISABLEDBG(condition) (0)
89 #else
90         extern int debug; /* collection of the flags */
91 /* this ISDBG will only work on ANSI C, not K&R */
92 #       define ISDBG(name)      ( (debug & DEBUG_DISABLED) ? 0 : (debug & (DEBUG_##name)) )
93 #       define ENABLEDBG(condition) ( (condition) ? (debug&=~DEBUG_DISABLED) : 0 )
94 #       define DISABLEDBG(condition) ( (condition) ? (debug|=DEBUG_DISABLED) : 0 )
95 #endif
96
97 #ifdef DBG_GLYPH
98 #       define DBG_TO_GLYPH(g) DISABLEDBG( strcmp( (g)->name, DBG_GLYPH ) )
99 #       define DBG_FROM_GLYPH(g) ENABLEDBG(1)
100 #else
101 #       define DBG_TO_GLYPH(g) (0)
102 #       define DBG_FROM_GLYPH(g) (0)
103 #endif
104
105 /* prototypes */
106 int iscale( int val);
107 double fscale( double val);
108 int unicode_rev_lookup( int unival);
109
110 /* global metrics for a font */
111
112 struct font_metrics {
113         /* post */
114         double  italic_angle;
115         short   underline_position;
116         short   underline_thickness;
117         short   is_fixed_pitch;
118
119         /* hhea */
120         short   ascender; 
121         short   descender;
122
123         /* head */
124         unsigned short  units_per_em;
125         short   bbox[4];
126
127         /* name */
128         char    *name_copyright;
129         char    *name_family;
130         char    *name_style;
131         char    *name_full;
132         char    *name_version;
133         char    *name_ps;
134
135         /* other */
136         int             force_bold;
137 };
138
139 /* size of the encoding table - glyphs beyond 255 are actually unnumbered */
140
141 #define ENCTABSZ        1024
142
143 /* switch table structure for front-ends */
144
145 #define MAXSUFFIX       10
146
147 struct frontsw {
148         char  *name; /* name of the front end */
149         char  *descr; /* description of the front end */
150         char  *suffix[MAXSUFFIX]; /* possible file name suffixes */
151
152         void  (*open)(char *fname, char *arg); /* open font file */
153         void  (*close)(void); /* close font file */
154         int   (*nglyphs)(void); /* get the number of glyphs */
155         int   (*glnames)(GLYPH *glyphs); /* get the names of glyphs */
156         void  (*glmetrics)(GLYPH *glyphs); /* get the metrics of glyphs */
157         int   (*glenc)(GLYPH *glyphs, int *enc, int *unimap); /* get the encoding */
158         void  (*fnmetrics)(struct font_metrics *fm); /* get the font metrics */
159         void  (*glpath)(int glyphno, GLYPH *glyphs); /* get the glyph path */
160         void  (*kerning)(GLYPH *glyph_list); /* extract the kerning data */
161 };