1
4
5# ifndef LMT_PACKAGING_H
6# define LMT_PACKAGING_H
7
8# include "luametatex.h"
9
10
11
12typedef enum hpack_subtypes {
13 packing_exactly,
14 packing_additional,
15 packing_expanded,
16 packing_substitute,
17 packing_adapted,
18 packing_linebreak,
19} hpack_subtypes;
20
21typedef enum box_codes {
22 box_code,
23 copy_code,
24 unpack_code,
25 last_box_code,
26 tsplit_code,
27 vsplit_code,
28 dsplit_code,
29
30 tpack_code,
31 vpack_code,
32 dpack_code,
33 hpack_code,
34 vtop_code,
35 vbox_code,
36 dbox_code,
37 hbox_code,
38 insert_box_code,
39 insert_copy_code,
40 local_left_box_box_code,
41 local_right_box_box_code,
42 local_middle_box_box_code,
43 page_discards_code,
44 split_discards_code,
45} box_codes;
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73typedef enum holding_migration_options {
74 holding_none_option = 0x00,
75 holding_marks_option = 0x01,
76 holding_inserts_option = 0x02,
77 holding_adjusts_option = 0x04,
78} holding_migration_options ;
79
80# define retain_marks(r) (((r | holding_migrations_par) & holding_marks_option ) == holding_marks_option )
81# define retain_inserts(r) (((r | holding_migrations_par) & holding_inserts_option) == holding_inserts_option)
82# define retain_adjusts(r) (((r | holding_migrations_par) & holding_adjusts_option) == holding_adjusts_option)
83
84typedef struct packaging_state_info {
85 scaled total_stretch[6];
86 scaled total_shrink[6];
87 int last_badness;
88 scaled last_overshoot;
89 halfword post_adjust_tail;
90 halfword pre_adjust_tail;
91 halfword post_migrate_tail;
92 halfword pre_migrate_tail;
93 halfword last_leftmost_char;
94 halfword last_rightmost_char;
95 int pack_begin_line;
96 scaled best_height_plus_depth;
97 halfword previous_char_ptr;
98 scaled font_expansion_ratio;
99 halfword page_discards_tail;
100 halfword page_discards_head;
101 halfword split_discards_head;
102 halfword padding;
103} packaging_state_info;
104
105typedef enum box_limit_modes {
106 box_limit_none = 0x00,
107 box_limit_hlist = 0x01,
108 box_limit_vlist = 0x02,
109 box_limit_line = 0x04,
110} box_limit_modes;
111
112extern packaging_state_info lmt_packaging_state;
113
114extern scaled tex_char_stretch (halfword p);
115extern scaled tex_char_shrink (halfword p);
116
117extern scaled tex_kern_stretch (halfword p);
118extern scaled tex_kern_shrink (halfword p);
119extern scaled tex_char_protrusion (halfword p, int side);
120
121
122extern scaled tex_left_marginkern (halfword p);
123extern scaled tex_right_marginkern (halfword p);
124
125extern halfword tex_filtered_hpack (halfword p, halfword qt, scaled w, int m, int grp, halfword d, int just_pack, halfword attr, int state, int retain);
126extern halfword tex_filtered_vpack (halfword p, scaled h, int m, scaled maxdepth, int grp, halfword direction, int just_pack, halfword attr, int state, int retain, int *excess);
127
128extern scaledwhd tex_natural_hsizes (halfword p, halfword pp, glueratio g_mult, int g_sign, int g_order);
129extern scaledwhd tex_natural_vsizes (halfword p, halfword pp, glueratio g_mult, int g_sign, int g_order);
130extern halfword tex_natural_width (halfword p, halfword pp, glueratio g_mult, int g_sign, int g_order);
131extern halfword tex_natural_hsize (halfword p, halfword *correction);
132extern halfword tex_natural_vsize (halfword p);
133
134extern halfword tex_hpack (halfword p, scaled w, int m, singleword d, int retain, int limit);
135extern halfword tex_vpack (halfword p, scaled h, int m, scaled l, singleword d, int retain, int *excess);
136
137extern void tex_repack (halfword p, scaled w, int m);
138extern void tex_limit (halfword p);
139extern void tex_freeze (halfword p, int recurse, int limitate, halfword factor);
140extern scaled tex_stretch (halfword p);
141extern scaled tex_shrink (halfword p);
142
143extern void tex_package (singleword nature);
144extern void tex_run_unpackage (void);
145
146extern void tex_append_to_vlist (halfword b, int location, const line_break_properties *properties);
147
148extern halfword tex_prune_page_top (halfword p, int s);
149extern halfword tex_vert_break (halfword p, scaled h, scaled d);
150extern halfword tex_vsplit (halfword n, scaled h, int m);
151
152extern void tex_finish_vcenter_group (void);
153extern void tex_run_vcenter (void);
154
155extern void tex_show_packaging_group (const char *package);
156extern int tex_show_packaging_record (void);
157
158extern int tex_get_packaging_context (void);
159extern int tex_get_packaging_shift (void);
160
161
162
163# define first_un_box_code box_code
164# define last_un_box_code unpack_code
165# define first_nu_box_code box_code
166# define last_nu_box_code local_middle_box_box_code
167
168
204
205# define biggest_reg 65535
206
207typedef enum box_flags {
208 direct_box_flag = 0x00,
209
210
211 box_flag = 0x02,
212 global_box_flag = 0x03,
213 left_box_flag = 0x04,
214 right_box_flag = 0x05,
215 middle_box_flag = 0x06,
216 shipout_flag = 0x07,
217 lua_scan_flag = 0x08,
218 a_leaders_flag = 0x09,
219 c_leaders_flag = 0x0A,
220 x_leaders_flag = 0x0B,
221 g_leaders_flag = 0x0C,
222 u_leaders_flag = 0x0D,
223
224} box_flags;
225
226# define box_leaders_flag(f) (f >= a_leaders_flag && f <= u_leaders_flag)
227
228extern void tex_begin_box (int boxcontext, scaled shift, halfword slot, halfword callback);
229extern int tex_ignore_math_skip (halfword p);
230
231static inline scaled tex_aux_checked_dimension1(halfword v)
232{
233 if (v > max_dimension) {
234 return max_dimension;
235 } else if (v < -max_dimension) {
236 return -max_dimension;
237 } else {
238 return v;
239 }
240}
241
242static inline scaled tex_aux_checked_dimension2(halfword v)
243{
244 if (v > max_dimension) {
245 return max_dimension;
246 } else if (v < 0) {
247 return 0;
248 } else {
249 return v;
250 }
251}
252
253# endif
254 |