Eliminate `sal_num_segments'.
[ttfautohint.git] / src / tabytecode.h
blob2d2dac1a826f83139c823ed5b5bf98b81ea8ddcf
1 /* tabytecode.h */
3 /*
4 * Copyright (C) 2011 by Werner Lemberg.
6 * This file is part of the ttfautohint library, and may only be used,
7 * modified, and distributed under the terms given in `COPYING'. By
8 * continuing to use, modify, or distribute this file you indicate that you
9 * have read `COPYING' and understand and accept it fully.
11 * The file `COPYING' mentioned in the previous paragraph is distributed
12 * with the ttfautohint library.
16 #ifndef __TABYTECODE_H__
17 #define __TABYTECODE_H__
19 #include "ta.h"
22 /* symbolic names for bytecode instruction codes */
24 #define SVTCA_y 0x00 /* set freedom and projection vectors to y axis */
25 #define SVTCA_x 0x01 /* set freedom and projection vectors to x axis */
26 #define SPVTCA_y 0x02 /* set projection vector to y axis */
27 #define SPVTCA_x 0x03 /* set projection vector to x axis */
28 #define SFVTCA_y 0x04 /* set freedom vector to y axis */
29 #define SFVTCA_x 0x05 /* set freedom vector to x axis */
30 #define SPVTL_para 0x06 /* set projection vector parallel to line */
31 #define SPVTL_perp 0x07 /* set projection vector perpendicular to line */
32 #define SFVTL_para 0x08 /* set freedom vector parallel to line */
33 #define SFVTL_perp 0x09 /* set freedom vector perpendicular to line */
34 #define SPVFS 0x0A /* set projection vector from stack */
35 #define SFVFS 0x0B /* set freedom vector from stack */
36 #define GPV 0x0C /* get projection vector */
37 #define GFV 0x0D /* get freedom vector */
38 #define SFVTPV 0x0E /* set freedom vector to projection vector */
39 #define ISECT 0x0F /* move point to intersection of lines */
41 #define SRP0 0x10 /* set reference point 0 */
42 #define SRP1 0x11 /* set reference point 1 */
43 #define SRP2 0x12 /* set reference point 2 */
44 #define SZP0 0x13 /* set zone pointer 0 */
45 #define SZP1 0x14 /* set zone pointer 1 */
46 #define SZP2 0x15 /* set zone pointer 2 */
47 #define SZPS 0x16 /* set zone pointers */
48 #define SLOOP 0x17 /* set loop counter */
49 #define RTG 0x18 /* round to grid */
50 #define RTHG 0x19 /* round to half grid */
51 #define SMD 0x1A /* set `minimum_distance' */
52 #define ELSE 0x1B /* begin of `else' clause */
53 #define JMPR 0x1C /* jump relative */
54 #define SCVTCI 0x1D /* set `control_value_cut_in' */
55 #define SSWCI 0x1E /* set `single_width_cut_in' */
56 #define SSW 0x1F /* set `single_width_value' */
58 #define DUP 0x20 /* duplicate top stack element */
59 #define POP 0x21 /* pop top stack element */
60 #define CLEAR 0x22 /* clear entire stack */
61 #define SWAP 0x23 /* swap top two elements of stack */
62 #define DEPTH 0x24 /* get depth of stack */
63 #define CINDEX 0x25 /* copy indexed element to top of stack */
64 #define MINDEX 0x26 /* move indexed element to top of stack */
65 #define ALIGNPTS 0x27 /* align points */
66 #define INS_28 0x28 /* undefined */
67 #define UTP 0x29 /* untouch point */
68 #define LOOPCALL 0x2A /* loop and call function */
69 #define CALL 0x2B /* call function */
70 #define FDEF 0x2C /* define function */
71 #define ENDF 0x2D /* end of function */
72 #define MDAP_noround 0x2E /* move direct absolute point without rounding */
73 #define MDAP_round 0x2F /* move direct absolute point with rounding */
75 #define IUP_y 0x30 /* interpolate untouched points along y axis */
76 #define IUP_x 0x31 /* interpolate untouched points along x axis */
77 #define SHP_rp2 0x32 /* shift point using rp2 */
78 #define SHP_rp1 0x33 /* shift point using rp1 */
79 #define SHC_rp2 0x34 /* shift contour using rp2 */
80 #define SHC_rp1 0x35 /* shift contour using rp1 */
81 #define SHZ_rp2 0x36 /* shift zone using rp2 */
82 #define SHZ_rp1 0x37 /* shift zone using rp1 */
83 #define SHPIX 0x38 /* shift point by pixel amount */
84 #define IP 0x39 /* interpolate point */
85 #define MSIRP_norp0 0x3A /* move stack indirect relative point, don't set rp0 */
86 #define MSIRP_rp0 0x3B /* move stack indirect relative point, set rp0 */
87 #define ALIGNRP 0x3C /* align relative point */
88 #define RTDG 0x3D /* round to double grid */
89 #define MIAP_noround 0x3E /* move indirect absolute point without rounding */
90 #define MIAP_round 0x3F /* move indirect absolute point with rounding */
92 #define NPUSHB 0x40 /* push `n' bytes */
93 #define NPUSHW 0x41 /* push `n' words */
94 #define WS 0x42 /* write to storage area */
95 #define RS 0x43 /* read from storage area */
96 #define WCVTP 0x44 /* write to CVT in pixel units */
97 #define RCVT 0x45 /* read from CVT */
98 #define GC_cur 0x46 /* get (projected) coordinate, current position */
99 #define GC_orig 0x47 /* get (projected) coordinate, original position */
100 #define SCFS 0x48 /* set coordinate from stack */
101 #define MD_cur 0x49 /* measure distance, current positions */
102 #define MD_orig 0x4A /* measure distance, original positions */
103 #define MPPEM 0x4B /* measure PPEM */
104 #define MPS 0x4C /* measure point size */
105 #define FLIPON 0x4D /* set `auto_flip' to TRUE */
106 #define FLIPOFF 0x4E /* set `auto_flip' to FALSE */
107 #define DEBUG 0x4F /* ignored */
109 #define LT 0x50 /* lower than */
110 #define LTEQ 0x51 /* lower than or equal */
111 #define GT 0x52 /* greater than */
112 #define GTEQ 0x53 /* greater than or equal */
113 #define EQ 0x54 /* equal */
114 #define NEQ 0x55 /* not equal */
115 #define ODD 0x56 /* TRUE if odd */
116 #define EVEN 0x57 /* TRUE if even */
117 #define IF 0x58 /* start of `if' clause */
118 #define EIF 0x59 /* end of `if' or `else' clause */
119 #define AND 0x5A /* logical AND */
120 #define OR 0x5B /* logical OR */
121 #define NOT 0x5C /* logical NOT */
122 #define DELTAP1 0x5D /* delta point exception 1 */
123 #define SDB 0x5E /* set `delta_base' */
124 #define SDS 0x5F /* set `delta_shift' */
126 #define ADD 0x60 /* addition */
127 #define SUB 0x61 /* subtraction */
128 #define DIV 0x62 /* division */
129 #define MUL 0x63 /* multiplication */
130 #define ABS 0x64 /* absolute value */
131 #define NEG 0x65 /* negation */
132 #define FLOOR 0x66 /* floor operation */
133 #define CEILING 0x67 /* ceiling operation */
134 #define ROUND_gray 0x68 /* round value with gray compensation */
135 #define ROUND_black 0x69 /* round value with black compensation */
136 #define ROUND_white 0x6A /* round value with white compensation */
137 #define ROUND_3 0x6B /* undefined */
138 #define NROUND_gray 0x6C /* apply gray compensation */
139 #define NROUND_black 0x6D /* apply black compensation */
140 #define NROUND_white 0x6E /* apply white compensation */
141 #define NROUND_3 0x6F /* undefined */
143 #define WCVTF 0x70 /* write to CVT in font units */
144 #define DELTAP2 0x71 /* delta point exception 2 */
145 #define DELTAP3 0x72 /* delta point exception 3 */
146 #define DELTAC1 0x73 /* delta cvt exception 1 */
147 #define DELTAC2 0x74 /* delta cvt exception 2 */
148 #define DELTAC3 0x75 /* delta cvt exception 3 */
149 #define SROUND 0x76 /* super round */
150 #define S45Round 0x77 /* super round at 45 degrees */
151 #define JROT 0x78 /* jump relative on TRUE */
152 #define JROF 0x79 /* jump relative on FALSE */
153 #define ROFF 0x7A /* turn off rounding */
154 #define INS_7B 0x7B /* undefined */
155 #define RUTG 0x7C /* round up to grid */
156 #define RDTG 0x7D /* round down to grid */
157 #define SANGW 0x7E /* ignored, obsolete */
158 #define AA 0x7F /* ignored, obsolete */
160 #define FLIPPT 0x80 /* flip point on-curve to off-curve and vice versa */
161 #define FLIPRGON 0x81 /* flip range of points to be on-curve */
162 #define FlIPRGOFF 0x82 /* flip range of points to be off-curve */
163 #define INS_83 0x83 /* undefined */
164 #define INS_84 0x84 /* undefined */
165 #define SCANCTRL 0x85 /* scan conversion control */
166 #define SDPVTL_para 0x86 /* set dual projection vector parallel to line */
167 #define SDPVTL_perp 0x87 /* set dual projection vector perpendicular to line */
168 #define GETINFO 0x88 /* get information about font scaler and current glyph */
169 #define IDEF 0x89 /* define instruction */
170 #define ROLL 0x8A /* roll top three stack elements */
171 #define MAX 0x8B /* maximum */
172 #define MIN 0x8C /* minimum */
173 #define SCANTYPE 0x8D /* set scan conversion rules */
174 #define INSTCTRL 0x8E /* set instruction control state */
175 #define INS_8F 0x8F /* undefined */
177 #define INS_90 0x90 /* undefined */
178 #define INS_91 0x91
179 #define INS_92 0x92
180 #define INS_93 0x93
181 #define INS_94 0x94
182 #define INS_95 0x95
183 #define INS_96 0x96
184 #define INS_97 0x97
185 #define INS_98 0x98
186 #define INS_99 0x99
187 #define INS_9A 0x9A
188 #define INS_9B 0x9B
189 #define INS_9C 0x9C
190 #define INS_9D 0x9D
191 #define INS_9E 0x9E
192 #define INS_9F 0x9F
194 #define INS_A0 0xA0 /* undefined */
195 #define INS_A1 0xA1
196 #define INS_A2 0xA2
197 #define INS_A3 0xA3
198 #define INS_A4 0xA4
199 #define INS_A5 0xA5
200 #define INS_A6 0xA6
201 #define INS_A7 0xA7
202 #define INS_A8 0xA8
203 #define INS_9A 0x9A
204 #define INS_AA 0xAA
205 #define INS_AB 0xAB
206 #define INS_AC 0xAC
207 #define INS_AD 0xAD
208 #define INS_AE 0xAE
209 #define INS_AF 0xAF
211 #define PUSHB_1 0xB0 /* push 1 byte */
212 #define PUSHB_2 0xB1 /* push 2 bytes */
213 #define PUSHB_3 0xB2 /* push 3 bytes */
214 #define PUSHB_4 0xB3 /* push 4 bytes */
215 #define PUSHB_5 0xB4 /* push 5 bytes */
216 #define PUSHB_6 0xB5 /* push 6 bytes */
217 #define PUSHB_7 0xB6 /* push 7 bytes */
218 #define PUSHB_8 0xB7 /* push 8 bytes */
219 #define PUSHW_1 0xB8 /* push 1 word */
220 #define PUSHW_2 0xB9 /* push 2 words */
221 #define PUSHW_3 0xBA /* push 3 words */
222 #define PUSHW_4 0xBB /* push 4 words */
223 #define PUSHW_5 0xBC /* push 5 words */
224 #define PUSHW_6 0xBD /* push 6 words */
225 #define PUSHW_7 0xBE /* push 7 words */
226 #define PUSHW_8 0xBF /* push 8 words */
228 #define MDRP_norp0_nokeep_noround_gray 0xC0 /* move direct relative point */
229 #define MDRP_norp0_nokeep_noround_black 0xC1
230 #define MDRP_norp0_nokeep_noround_white 0xC2
231 #define MDRP_norp0_nokeep_noround_3 0xC3 /* undefined */
232 #define MDRP_norp0_nokeep_round_gray 0xC4
233 #define MDRP_norp0_nokeep_round_black 0xC5
234 #define MDRP_norp0_nokeep_round_white 0xC6
235 #define MDRP_norp0_nokeep_round_3 0xC7
236 #define MDRP_norp0_keep_noround_gray 0xC8
237 #define MDRP_norp0_keep_noround_black 0xC9
238 #define MDRP_norp0_keep_noround_white 0xCA
239 #define MDRP_norp0_keep_noround_3 0xCB
240 #define MDRP_norp0_keep_round_gray 0xCC
241 #define MDRP_norp0_keep_round_black 0xCD
242 #define MDRP_norp0_keep_round_white 0xCE
243 #define MDRP_norp0_keep_round_3 0xCF
245 #define MDRP_rp0_nokeep_noround_gray 0xD0
246 #define MDRP_rp0_nokeep_noround_black 0xD1
247 #define MDRP_rp0_nokeep_noround_white 0xD2
248 #define MDRP_rp0_nokeep_noround_3 0xD3
249 #define MDRP_rp0_nokeep_round_gray 0xD4
250 #define MDRP_rp0_nokeep_round_black 0xD5
251 #define MDRP_rp0_nokeep_round_white 0xD6
252 #define MDRP_rp0_nokeep_round_3 0xD7
253 #define MDRP_rp0_keep_noround_gray 0xD8
254 #define MDRP_rp0_keep_noround_black 0xD9
255 #define MDRP_rp0_keep_noround_white 0xDA
256 #define MDRP_rp0_keep_noround_3 0xDB
257 #define MDRP_rp0_keep_round_gray 0xDC
258 #define MDRP_rp0_keep_round_black 0xDD
259 #define MDRP_rp0_keep_round_white 0xDE
260 #define MDRP_rp0_keep_round_3 0xDF
262 #define MIRP_norp0_nokeep_noround_gray 0xE0 /* move indirect relative point */
263 #define MIRP_norp0_nokeep_noround_black 0xE1
264 #define MIRP_norp0_nokeep_noround_white 0xE2
265 #define MIRP_norp0_nokeep_noround_3 0xE3 /* undefined */
266 #define MIRP_norp0_nokeep_round_gray 0xE4
267 #define MIRP_norp0_nokeep_round_black 0xE5
268 #define MIRP_norp0_nokeep_round_white 0xE6
269 #define MIRP_norp0_nokeep_round_3 0xE7
270 #define MIRP_norp0_keep_noround_gray 0xE8
271 #define MIRP_norp0_keep_noround_black 0xE9
272 #define MIRP_norp0_keep_noround_white 0xEA
273 #define MIRP_norp0_keep_noround_3 0xEB
274 #define MIRP_norp0_keep_round_gray 0xEC
275 #define MIRP_norp0_keep_round_black 0xED
276 #define MIRP_norp0_keep_round_white 0xEE
277 #define MIRP_norp0_keep_round_3 0xEF
279 #define MIRP_rp0_nokeep_noround_gray 0xF0
280 #define MIRP_rp0_nokeep_noround_black 0xF1
281 #define MIRP_rp0_nokeep_noround_white 0xF2
282 #define MIRP_rp0_nokeep_noround_3 0xF3
283 #define MIRP_rp0_nokeep_round_gray 0xF4
284 #define MIRP_rp0_nokeep_round_black 0xF5
285 #define MIRP_rp0_nokeep_round_white 0xF6
286 #define MIRP_rp0_nokeep_round_3 0xF7
287 #define MIRP_rp0_keep_noround_gray 0xF8
288 #define MIRP_rp0_keep_noround_black 0xF9
289 #define MIRP_rp0_keep_noround_white 0xFA
290 #define MIRP_rp0_keep_noround_3 0xFB
291 #define MIRP_rp0_keep_round_gray 0xFC
292 #define MIRP_rp0_keep_round_black 0xFD
293 #define MIRP_rp0_keep_round_white 0xFE
294 #define MIRP_rp0_keep_round_3 0xFF
297 /* symbolic names for storage area locations */
299 #define sal_i 0
300 #define sal_j sal_i + 1
301 #define sal_k sal_j + 1
302 #define sal_temp1 sal_k + 1
303 #define sal_temp2 sal_temp1 + 1
304 #define sal_temp3 sal_temp2 + 1
305 #define sal_limit sal_temp3 + 1
306 #define sal_func sal_limit +1
307 #define sal_anchor sal_func + 1
308 #define sal_point_min sal_anchor + 1
309 #define sal_point_max sal_point_min + 1
310 #define sal_segment_offset sal_point_max + 1 /* must be last */
313 /* bytecode function numbers */
315 #define bci_round 0
316 #define bci_compute_stem_width bci_round + 1
317 #define bci_loop bci_compute_stem_width + 1
318 #define bci_cvt_rescale bci_loop + 1
319 #define bci_blue_round bci_cvt_rescale + 1
320 #define bci_get_point_extrema bci_blue_round + 1
322 #define bci_create_segment bci_get_point_extrema + 1
323 #define bci_create_segments bci_create_segment + 1
324 #define bci_align_segment bci_create_segments + 1
325 #define bci_align_segments bci_align_segment + 1
327 #define bci_scale_contour bci_align_segments + 1
328 #define bci_scale_glyph bci_scale_contour + 1
329 #define bci_shift_contour bci_scale_glyph + 1
330 #define bci_shift_subglyph bci_shift_contour + 1
332 #define bci_ip_outer_align_point bci_shift_subglyph + 1
333 #define bci_ip_on_align_points bci_ip_outer_align_point + 1
334 #define bci_ip_between_align_point bci_ip_on_align_points + 1
335 #define bci_ip_between_align_points bci_ip_between_align_point + 1
337 /* the order of the `bci_action_*' entries must correspond */
338 /* to the order of the TA_Action enumeration entries */
339 #define bci_action_ip_before bci_ip_between_align_points + 1
340 #define bci_action_ip_after bci_action_ip_before + 1
341 #define bci_action_ip_on bci_action_ip_after + 1
342 #define bci_action_ip_between bci_action_ip_on + 1
344 #define bci_action_blue bci_action_ip_between + 1
345 #define bci_action_blue_anchor bci_action_blue + 1
346 #define bci_action_anchor bci_action_blue_anchor + 1
347 #define bci_action_adjust bci_action_anchor + 1
348 #define bci_action_adjust_bound bci_action_adjust + 1
349 #define bci_action_link bci_action_adjust_bound + 1
350 #define bci_action_stem bci_action_link + 1
351 #define bci_action_stem_bound bci_action_stem + 1
352 #define bci_action_serif bci_action_stem_bound + 1
353 #define bci_action_serif_lower_bound bci_action_serif + 1
354 #define bci_action_serif_upper_bound bci_action_serif_lower_bound + 1
355 #define bci_action_serif_lower_upper_bound bci_action_serif_upper_bound + 1
356 #define bci_action_serif_anchor bci_action_serif_lower_upper_bound + 1
357 #define bci_action_serif_anchor_lower_bound bci_action_serif_anchor + 1
358 #define bci_action_serif_anchor_upper_bound bci_action_serif_anchor_lower_bound + 1
359 #define bci_action_serif_anchor_lower_upper_bound bci_action_serif_anchor_upper_bound + 1
360 #define bci_action_serif_link1 bci_action_serif_anchor_lower_upper_bound + 1
361 #define bci_action_serif_link1_lower_bound bci_action_serif_link1 + 1
362 #define bci_action_serif_link1_upper_bound bci_action_serif_link1_lower_bound + 1
363 #define bci_action_serif_link1_lower_upper_bound bci_action_serif_link1_upper_bound + 1
364 #define bci_action_serif_link2 bci_action_serif_link1_lower_upper_bound + 1
365 #define bci_action_serif_link2_lower_bound bci_action_serif_link2 + 1
366 #define bci_action_serif_link2_upper_bound bci_action_serif_link2_lower_bound + 1
367 #define bci_action_serif_link2_lower_upper_bound bci_action_serif_link2_upper_bound + 1
369 #define bci_handle_action bci_action_serif_link2_lower_upper_bound + 1
370 #define bci_hint_glyph bci_handle_action + 1
372 #define NUM_FDEFS bci_hint_glyph + 1 /* must be last */
374 /* the first action handler */
375 #define ACTION_OFFSET bci_action_ip_before
378 /* symbolic names for run-time CVT locations */
379 /* (assigned in `prep' or `fpgm') */
381 #define cvtl_temp 0 /* used for creating twilight points */
382 #define cvtl_0x10000 cvtl_temp + 1
383 #define cvtl_scale cvtl_0x10000 + 1
384 #define cvtl_funits_to_pixels cvtl_scale + 1
385 #define cvtl_is_extra_light cvtl_funits_to_pixels + 1
386 #define cvtl_max_runtime cvtl_is_extra_light + 1 /* must be last */
388 /* symbolic names for compile-time CVT locations */
389 /* (assigned in `cvt') */
391 /* the horizontal and vertical standard widths */
392 #define CVT_HORZ_STANDARD_WIDTH_OFFSET(font) cvtl_max_runtime
393 #define CVT_VERT_STANDARD_WIDTH_OFFSET(font) \
394 CVT_HORZ_STANDARD_WIDTH_OFFSET(font) + 1
396 /* the horizontal stem widths */
397 #define CVT_HORZ_WIDTHS_OFFSET(font) \
398 CVT_VERT_STANDARD_WIDTH_OFFSET(font) + 1
399 #define CVT_HORZ_WIDTHS_SIZE(font) \
400 ((TA_LatinMetrics)font->loader->hints.metrics)->axis[0].width_count
402 /* the vertical stem widths */
403 #define CVT_VERT_WIDTHS_OFFSET(font) \
404 CVT_HORZ_WIDTHS_OFFSET(font) + CVT_HORZ_WIDTHS_SIZE(font)
405 #define CVT_VERT_WIDTHS_SIZE(font) \
406 ((TA_LatinMetrics)font->loader->hints.metrics)->axis[1].width_count
408 /* the number of blue zones */
409 #define CVT_BLUES_SIZE(font) \
410 ((TA_LatinMetrics)font->loader->hints.metrics)->axis[1].blue_count
412 /* the blue zone values for flat and round edges */
413 #define CVT_BLUE_REFS_OFFSET(font) \
414 CVT_VERT_WIDTHS_OFFSET(font) + CVT_VERT_WIDTHS_SIZE(font)
415 #define CVT_BLUE_SHOOTS_OFFSET(font) \
416 CVT_BLUE_REFS_OFFSET(font) + CVT_BLUES_SIZE(font)
419 FT_Error
420 TA_sfnt_build_cvt_table(SFNT* sfnt,
421 FONT* font);
423 FT_Error
424 TA_sfnt_build_fpgm_table(SFNT* sfnt,
425 FONT* font);
427 FT_Error
428 TA_sfnt_build_prep_table(SFNT* sfnt,
429 FONT* font);
431 FT_Error
432 TA_sfnt_build_glyf_hints(SFNT* sfnt,
433 FONT* font);
435 #endif /* __TABYTECODE_H__ */
437 /* end of tabytecode.h */