summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/tex/directions.h
blob: f7b3e784d0799168be5bfe2e3b32fc07beb540df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/* directions.h

   Copyright 2009 Taco Hoekwater <taco@luatex.org>

   This file is part of LuaTeX.

   LuaTeX is free software; you can redistribute it and/or modify it under
   the terms of the GNU General Public License as published by the Free
   Software Foundation; either version 2 of the License, or (at your
   option) any later version.

   LuaTeX is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
   License for more details.

   You should have received a copy of the GNU General Public License along
   with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */

/* $Id: directions.h 3853 2010-09-03 18:05:14Z oneiros $ */

#ifndef DIRECTIONS_H
#  define DIRECTIONS_H

#  define dir_T 0
#  define dir_L 1
#  define dir_B 2
#  define dir_R 3

#  define dir_TLT  0
#  define dir_TRT  4
#  define dir_LTL  9
#  define dir_RTT  24


                                   /* #  define dir_array_size  25 *//* |dir_RTT + 1| */

/* inv(primary) == tertiary */
/*
boolean _is_mirrored[dir_array_size];
_is_mirrored[dir_TLT] = 0;
_is_mirrored[dir_TRT] = 0;
_is_mirrored[dir_LTL] = 0;
_is_mirrored[dir_RTT] = 0;
*/

#  define is_mirrored(a) 0

/* secondary == tertiary */
/*
boolean _is_rotated[dir_array_size];
_is_rotated[dir_TLT] = 0;
_is_rotated[dir_TRT] = 0;
_is_rotated[dir_LTL] = 0;
_is_rotated[dir_RTT] = 1;
*/

#  define is_rotated(a) (a == dir_RTT)

/* secondary == secondary */
/*
boolean _textdir_parallel[dir_array_size][dir_array_size];
_textdir_parallel[dir_TLT][dir_TLT] = 1;
_textdir_parallel[dir_TLT][dir_TRT] = 1;
_textdir_parallel[dir_TLT][dir_LTL] = 0;
_textdir_parallel[dir_TLT][dir_RTT] = 0;
_textdir_parallel[dir_TRT][dir_TLT] = 1;
_textdir_parallel[dir_TRT][dir_TRT] = 1;
_textdir_parallel[dir_TRT][dir_LTL] = 0;
_textdir_parallel[dir_TRT][dir_RTT] = 0;
_textdir_parallel[dir_LTL][dir_TLT] = 0;
_textdir_parallel[dir_LTL][dir_TRT] = 0;
_textdir_parallel[dir_LTL][dir_LTL] = 1;
_textdir_parallel[dir_LTL][dir_RTT] = 1;
_textdir_parallel[dir_RTT][dir_TLT] = 0;
_textdir_parallel[dir_RTT][dir_TRT] = 0;
_textdir_parallel[dir_RTT][dir_LTL] = 1;
_textdir_parallel[dir_RTT][dir_RTT] = 1;
*/

#  define textdir_parallel(a,b)  (((a == dir_TLT || a == dir_TRT)&&(b == dir_TLT || b == dir_TRT)) || \
				((a == dir_LTL || a == dir_RTT)&&(b == dir_LTL || b == dir_RTT)))


/* primary == primary */
/*
boolean _pardir_parallel[dir_array_size][dir_array_size];
_pardir_parallel[dir_TLT][dir_TLT] = 1;
_pardir_parallel[dir_TLT][dir_TRT] = 1;
_pardir_parallel[dir_TLT][dir_LTL] = 0;
_pardir_parallel[dir_TLT][dir_RTT] = 0;
_pardir_parallel[dir_TRT][dir_TLT] = 1;
_pardir_parallel[dir_TRT][dir_TRT] = 1;
_pardir_parallel[dir_TRT][dir_LTL] = 0;
_pardir_parallel[dir_TRT][dir_RTT] = 0;
_pardir_parallel[dir_LTL][dir_TLT] = 0;
_pardir_parallel[dir_LTL][dir_TRT] = 0;
_pardir_parallel[dir_LTL][dir_LTL] = 1;
_pardir_parallel[dir_LTL][dir_RTT] = 1;
_pardir_parallel[dir_RTT][dir_TLT] = 0;
_pardir_parallel[dir_RTT][dir_TRT] = 0;
_pardir_parallel[dir_RTT][dir_LTL] = 1;
_pardir_parallel[dir_RTT][dir_RTT] = 1;
*/


#  define pardir_parallel(a,b) (((a == dir_TLT || a == dir_TRT)&&(b == dir_TLT || b == dir_TRT)) || \
			      ((a == dir_LTL || a == dir_RTT)&&(b == dir_LTL || b == dir_RTT)))


/* inv(primary) == primary */
/*
boolean _pardir_opposite[dir_array_size][dir_array_size];
_pardir_opposite[dir_TLT][dir_TLT] = 0;
_pardir_opposite[dir_TLT][dir_TRT] = 0;
_pardir_opposite[dir_TLT][dir_LTL] = 0;
_pardir_opposite[dir_TLT][dir_RTT] = 0;
_pardir_opposite[dir_TRT][dir_TLT] = 0;
_pardir_opposite[dir_TRT][dir_TRT] = 0;
_pardir_opposite[dir_TRT][dir_LTL] = 0;
_pardir_opposite[dir_TRT][dir_RTT] = 0;
_pardir_opposite[dir_LTL][dir_TLT] = 0;
_pardir_opposite[dir_LTL][dir_TRT] = 0;
_pardir_opposite[dir_LTL][dir_LTL] = 0;
_pardir_opposite[dir_LTL][dir_RTT] = 1;
_pardir_opposite[dir_RTT][dir_TLT] = 0;
_pardir_opposite[dir_RTT][dir_TRT] = 0;
_pardir_opposite[dir_RTT][dir_LTL] = 1;
_pardir_opposite[dir_RTT][dir_RTT] = 0;
*/

#  define pardir_opposite(a,b) ((a == dir_LTL && b == dir_RTT)||(a == dir_RTT && b == dir_LTL))


/* inv(secondary) == secondary */
/*
boolean _textdir_opposite[dir_array_size][dir_array_size];
_textdir_opposite[dir_TLT][dir_TLT] = 0;
_textdir_opposite[dir_TLT][dir_TRT] = 1;
_textdir_opposite[dir_TLT][dir_LTL] = 0;
_textdir_opposite[dir_TLT][dir_RTT] = 0;
_textdir_opposite[dir_TRT][dir_TLT] = 1;
_textdir_opposite[dir_TRT][dir_TRT] = 0;
_textdir_opposite[dir_TRT][dir_LTL] = 0;
_textdir_opposite[dir_TRT][dir_RTT] = 0;
_textdir_opposite[dir_LTL][dir_TLT] = 0;
_textdir_opposite[dir_LTL][dir_TRT] = 0;
_textdir_opposite[dir_LTL][dir_LTL] = 0;
_textdir_opposite[dir_LTL][dir_RTT] = 0;
_textdir_opposite[dir_RTT][dir_TLT] = 0;
_textdir_opposite[dir_RTT][dir_TRT] = 0;
_textdir_opposite[dir_RTT][dir_LTL] = 0;
_textdir_opposite[dir_RTT][dir_RTT] = 0;
*/

#  define textdir_opposite(a,b) ((a == dir_TLT && b == dir_TRT)||(a == dir_TRT && b == dir_TLT))


/* inv(tertiary) == tertiary */
/*
boolean _glyphdir_opposite[dir_array_size][dir_array_size];
_glyphdir_opposite[dir_TLT][dir_TLT] = 0;
_glyphdir_opposite[dir_TLT][dir_TRT] = 0;
_glyphdir_opposite[dir_TLT][dir_LTL] = 0;
_glyphdir_opposite[dir_TLT][dir_RTT] = 0;
_glyphdir_opposite[dir_TRT][dir_TLT] = 0;
_glyphdir_opposite[dir_TRT][dir_TRT] = 0;
_glyphdir_opposite[dir_TRT][dir_LTL] = 0;
_glyphdir_opposite[dir_TRT][dir_RTT] = 0;
_glyphdir_opposite[dir_LTL][dir_TLT] = 0;
_glyphdir_opposite[dir_LTL][dir_TRT] = 0;
_glyphdir_opposite[dir_LTL][dir_LTL] = 0;
_glyphdir_opposite[dir_LTL][dir_RTT] = 0;
_glyphdir_opposite[dir_RTT][dir_TLT] = 0;
_glyphdir_opposite[dir_RTT][dir_TRT] = 0;
_glyphdir_opposite[dir_RTT][dir_LTL] = 0;
_glyphdir_opposite[dir_RTT][dir_RTT] = 0;
*/

#  define glyphdir_opposite(a,b) 0


/* primary == primary */
/*
boolean _pardir_eq[dir_array_size][dir_array_size];
_pardir_eq[dir_TLT][dir_TLT] = 1;
_pardir_eq[dir_TLT][dir_TRT] = 1;
_pardir_eq[dir_TLT][dir_LTL] = 0;
_pardir_eq[dir_TLT][dir_RTT] = 0;
_pardir_eq[dir_TRT][dir_TLT] = 1;
_pardir_eq[dir_TRT][dir_TRT] = 1;
_pardir_eq[dir_TRT][dir_LTL] = 0;
_pardir_eq[dir_TRT][dir_RTT] = 0;
_pardir_eq[dir_LTL][dir_TLT] = 0;
_pardir_eq[dir_LTL][dir_TRT] = 0;
_pardir_eq[dir_LTL][dir_LTL] = 1;
_pardir_eq[dir_LTL][dir_RTT] = 0;
_pardir_eq[dir_RTT][dir_TLT] = 0;
_pardir_eq[dir_RTT][dir_TRT] = 0;
_pardir_eq[dir_RTT][dir_LTL] = 0;
_pardir_eq[dir_RTT][dir_RTT] = 1;
*/

#  define pardir_eq(a,b) (((a == dir_TLT || a == dir_TRT)&&(b == dir_TLT || b == dir_TRT))|| \
			(a == dir_LTL && b == dir_LTL) ||		\
			(a == dir_RTT && b == dir_RTT))

/* secondary == secondary */
/*
boolean _textdir_eq[dir_array_size][dir_array_size];
_textdir_eq[dir_TLT][dir_TLT] = 1;
_textdir_eq[dir_TLT][dir_TRT] = 0;
_textdir_eq[dir_TLT][dir_LTL] = 0;
_textdir_eq[dir_TLT][dir_RTT] = 0;
_textdir_eq[dir_TRT][dir_TLT] = 0;
_textdir_eq[dir_TRT][dir_TRT] = 1;
_textdir_eq[dir_TRT][dir_LTL] = 0;
_textdir_eq[dir_TRT][dir_RTT] = 0;
_textdir_eq[dir_LTL][dir_TLT] = 0;
_textdir_eq[dir_LTL][dir_TRT] = 0;
_textdir_eq[dir_LTL][dir_LTL] = 1;
_textdir_eq[dir_LTL][dir_RTT] = 1;
_textdir_eq[dir_RTT][dir_TLT] = 0;
_textdir_eq[dir_RTT][dir_TRT] = 0;
_textdir_eq[dir_RTT][dir_LTL] = 1;
_textdir_eq[dir_RTT][dir_RTT] = 1;
*/

#  define textdir_eq(a,b) ((a == dir_TLT && b == dir_TLT) || \
			 (a == dir_TRT && b == dir_TRT) || \
			 (a == dir_LTL && (b == dir_LTL || b == dir_RTT)) || \
			 (a == dir_RTT && (b == dir_LTL || b == dir_RTT))


/* tertiary == tertiary */
/*
boolean _glyphdir_eq[dir_array_size][dir_array_size];
_glyphdir_eq[dir_TLT][dir_TLT] = 1;
_glyphdir_eq[dir_TLT][dir_TRT] = 1;
_glyphdir_eq[dir_TLT][dir_LTL] = 0;
_glyphdir_eq[dir_TLT][dir_RTT] = 1;
_glyphdir_eq[dir_TRT][dir_TLT] = 1;
_glyphdir_eq[dir_TRT][dir_TRT] = 1;
_glyphdir_eq[dir_TRT][dir_LTL] = 0;
_glyphdir_eq[dir_TRT][dir_RTT] = 1;
_glyphdir_eq[dir_LTL][dir_TLT] = 0;
_glyphdir_eq[dir_LTL][dir_TRT] = 0;
_glyphdir_eq[dir_LTL][dir_LTL] = 1;
_glyphdir_eq[dir_LTL][dir_RTT] = 0;
_glyphdir_eq[dir_RTT][dir_TLT] = 1;
_glyphdir_eq[dir_RTT][dir_TRT] = 1;
_glyphdir_eq[dir_RTT][dir_LTL] = 0;
_glyphdir_eq[dir_RTT][dir_RTT] = 1;
*/

#  define glyphdir_eq(a,b) ((a != dir_LTL && b != dir_LTL) || \
			  (a == dir_LTL && b == dir_LTL))


/* primary == secondary */
/*
boolean _partextdir_eq[dir_array_size][dir_array_size];
_partextdir_eq[dir_TLT][dir_TLT] = 0;
_partextdir_eq[dir_TLT][dir_TRT] = 0;
_partextdir_eq[dir_TLT][dir_LTL] = 1;
_partextdir_eq[dir_TLT][dir_RTT] = 1;
_partextdir_eq[dir_TRT][dir_TLT] = 0;
_partextdir_eq[dir_TRT][dir_TRT] = 0;
_partextdir_eq[dir_TRT][dir_LTL] = 1;
_partextdir_eq[dir_TRT][dir_RTT] = 1;
_partextdir_eq[dir_LTL][dir_TLT] = 1;
_partextdir_eq[dir_LTL][dir_TRT] = 0;
_partextdir_eq[dir_LTL][dir_LTL] = 0;
_partextdir_eq[dir_LTL][dir_RTT] = 0;
_partextdir_eq[dir_RTT][dir_TLT] = 0;
_partextdir_eq[dir_RTT][dir_TRT] = 1;
_partextdir_eq[dir_RTT][dir_LTL] = 0;
_partextdir_eq[dir_RTT][dir_RTT] = 0;
*/

#  define partextdir_eq(a,b) (((a == dir_TLT || a == dir_TRT)&&(b == dir_LTL || b == dir_RTT)) || \
			    (a == dir_LTL && b == dir_TLT) ||		\
			    (a == dir_RTT && b == dir_TRT))


/* secondary != tertiary */
/*
boolean _textglyphdir_orthogonal[dir_array_size]
_textglyphdir_orthogonal[dir_TLT] = 1;
_textglyphdir_orthogonal[dir_TRT] = 1;
_textglyphdir_orthogonal[dir_LTL] = 1;
_textglyphdir_orthogonal[dir_RTT] = 0;
*/

#  define textglyphdir_orthogonal(a) (a != dir_RTT)

/* secondary == L */
/*
boolean _textdir_is[dir_array_size];
_textdir_is[dir_TLT] = 1;
_textdir_is[dir_TRT] = 1;
_textdir_is[dir_LTL] = 1;
_textdir_is[dir_RTT] = 0;
*/

#  define textdir_is_L(a) (a == dir_TLT)

#  define push_dir(a)                           \
   { halfword dir_tmp=new_dir((a));             \
       vlink(dir_tmp)=dir_ptr;                  \
       dir_ptr=dir_tmp;                         \
   }

#  define push_dir_node(a)                  \
   { halfword dir_tmp=copy_node((a));		\
       vlink(dir_tmp)=dir_ptr;              \
       dir_ptr=dir_tmp;                     \
   }

#  define pop_dir_node()                        \
   { halfword dir_tmp=dir_ptr;                  \
       dir_ptr=vlink(dir_tmp);                  \
       flush_node(dir_tmp);                     \
   }

extern halfword dir_ptr;

extern halfword text_dir_ptr;

extern void initialize_directions(void);
extern halfword new_dir(int s);

extern const char *string_dir(int d);
extern void print_dir(int d);

extern void scan_direction(void);

extern halfword do_push_dir_node(halfword p, halfword a);
extern halfword do_pop_dir_node(halfword p);

scaled pack_width(int curdir, int pdir, halfword p, boolean isglyph);
scaled_whd pack_width_height_depth(int curdir, int pdir, halfword p,
                                   boolean isglyph);

void update_text_dir_ptr(int val);

#endif