w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

out_routines.c
Go to the documentation of this file.
1 /* out_routines.c: Low-level routines for outputting OPL and OVP files.
2 
3 This file is part of Omega,
4 which is based on the web2c distribution of TeX,
5 
6 Copyright 1994--2018 John Plaice and Yannis Haralambous
7 
8 Omega is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12 
13 Omega is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Omega; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21 
22 */
23 
24 #include "cpascal.h"
25 #include "list_routines.h"
26 #include "manifests.h"
27 #include "omfonts.h"
28 #include "out_routines.h"
29 #include "error_routines.h"
30 #include "header_routines.h"
31 #include "char_routines.h"
32 
33 /* Character measures */
34 
36  { "CHARWD", "CHARHT", "CHARDP", "CHARIC",
37  "SECWD", "SECHT", "SECDP", "SECIC",
38  "PRIMTOPAXIS", "PRIMTOPAXISBIS", "PRIMBOTAXIS", "PRIMBOTAXISBIS",
39  "PRIMMIDHOR", "PRIMMIDVERT", "PRIMBASESLANT", NULL,
40  "SECTOPAXIS", "SECTOPAXISBIS", "SECBOTAXIS", "SECBOTAXISBIS",
41  "SECMIDHOR", "SECMIDVERT", "SECBASESLANT", NULL};
42 
43 void
44 out_character_measure(unsigned measure)
45 {
46  if ((measure < C_MIN) || (measure > C_MAX) ||
47  (character_measures[measure]==NULL)) {
48  internal_error_1("out_character_measure (measure=%d)", measure);
49  }
50  out(character_measures[measure]);
51 }
52 
53 /* Extensible pieces */
54 
56  { "TOP", "MID", "BOT", "REP", NULL };
57 
58 void
59 out_extensible_piece(unsigned piece)
60 {
61  if ((piece < E_MIN) || (piece > E_MAX)) {
62  internal_error_1("out_extensible_piece (piece=%d)", piece);
63  }
64  out(extensible_pieces[piece]);
65 }
66 
67 /* Ligature commands */
68 
70  { "LIG", "LIG/", "/LIG", "/LIG/", NULL,
71  "LIG/>", "/LIG>", "/LIG/>", NULL, NULL,
72  NULL, "/LIG/>>", NULL };
73 
74 void
76 {
77  if ((command < L_MIN) || (command > L_MAX) ||
79  internal_error_1("out_ligature_command (command=%d)", command);
80  }
82 }
83 
84 /* Xerox faces */
85 
87  { "MRR", "MIR", "BRR", "BIR", "LRR", "LIR",
88  "MRC", "MIC", "BRC", "BIC", "LRC", "LIC",
89  "MRE", "MIE", "BRE", "BIE", "LRE", "LIE", NULL };
90 
91 void
93 {
94  if ((face < F_MIN) || (face > F_MAX)) {
95  internal_error_1("print_xerox_face (face=%d)", face);
96  }
97  out("F "); out(xerox_faces[face]);
98 }
99 
100 /* Named parameters */
101 
103  { NULL, "SLANT", "SPACE", "STRETCH", "SHRINK", "XHEIGHT",
104  "QUAD", "EXTRASPACE", NULL };
105 
106 void
108 {
109  if ((parameter < P_MIN) || (parameter > P_MAX)) {
110  internal_error_1("out_named_parameter (parameter = %d)", parameter);
111  }
113 }
114 
115 /* Named math symbol parameters */
116 
118  { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
119  "NUM1", "NUM2", "NUM3", "DENOM1",
120  "DENOM2", "SUP1", "SUP2", "SUP3", "SUB1", "SUB2",
121  "SUPDROP", "SUBDROP", "DELIM1", "DELIM2", "AXISHEIGHT", NULL };
122 
123 void
125 {
126  if ((parameter < P_MATHSY_MIN) || (parameter > P_MATHSY_MAX) ||
128  internal_error_1("out_named_mathsy_parameter (parameter=%d)",parameter);
129  }
131 }
132 
133 /* Named math extension parameters */
134 
136  { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
137  "DEFAULTRULETHICKNESS", "BIGOPSPACING1",
138  "BIGOPSPACING2", "BIGOPSPACING3",
139  "BIGOPSPACING4", "BIGOPSPACING5", NULL };
140 
141 void
143 {
144  if ((parameter < P_MATHEX_MIN) || (parameter > P_MATHEX_MAX) ||
146  internal_error_1("out_named_mathex_parameter (parameter=%d)",parameter);
147  }
149 }
150 
151 /* Typesetting directions */
152 
154  { "FONTDIR", "NATURALFONTDIR", NULL };
155 
157  { "TL", "LT", "TR", "RT", "LB", "BL", "BR", "RB", NULL };
158 
159 void
161 {
162  if ((direction < DIR_MIN) || (direction > DIR_MAX)) {
163  internal_error_1("out_type_direction (direction=%d)", direction);
164  }
165  out(type_directions[direction/8]); out(" ");
167 }
168 
169 /* Kinds of accents */
170 
172  { NULL, "TOPACCENT", "MIDACCENT", "BOTACCENT", NULL };
173 
174 void
176 {
177  if ((kind < ACC_TOP) || (kind > ACC_BOT)) {
178  internal_error_1("out_accent_kind (kind=%d)", kind);
179  }
181 }
182 
183 /* Move directions */
184 
186  { "MOVERIGHT", "MOVELEFT", "MOVEUP", "MOVEDOWN", NULL };
187 
188 void
190 {
191  if ((direction < M_MIN) || (direction > M_MAX)) {
192  internal_error_1("out_move_direction (direction=%d)", direction);
193  }
195 }
196 
197 /* Rule measures */
198 
200  { "RULEWD", "RULEHT", "RULEDP", NULL };
201 
202 void
203 out_rule_measure(unsigned measure)
204 {
205  if ((measure < RULE_MIN) || (measure > RULE_MAX)) {
206  internal_error_1("out_rule_measure (measure=%d)", measure);
207  }
208  out(rule_measures[measure]);
209 }
210 
211 /* Glue shrink or stretch */
212 
214  { "GLUESHRINK", "GLUESTRETCH", NULL };
215 
216 void
217 out_shrink_stretch(unsigned shrink_stretch)
218 {
219  if ((shrink_stretch < GLUE_MIN) || (shrink_stretch > GLUE_MAX)) {
220  internal_error_1("out_shrink_stretch (shrink_stretch=%d)",
221  shrink_stretch);
222  }
223  out(glue_shrink_stretch[shrink_stretch]);
224 }
225 
226 /* Glue orders */
227 
229  { "UNIT", "FI", "FIL", "FILL", "FILLL", NULL };
230 
231 void
232 out_glue_order(unsigned order)
233 {
234  if ((order < O_MIN) || (order > O_MAX)) {
235  internal_error_1("out_glue_order (order=%d)", order);
236  }
237  out(glue_orders[order]);
238 }
239 
240 /* Glue kinds */
241 
243  { "NORMAL", "ALEADERS", "CLEADERS", "ALEADERS", "XLEADERS", NULL };
244 
245 void
247 {
248  if ((kind < K_MIN) || (kind > K_MAX)) {
249  internal_error_1("out_glue_kind (kind=%d)", kind);
250  }
251  out(glue_kinds[kind]);
252 }
253 
254 unsigned parenthesis_level=0;
255 unsigned digits[12];
256 
257 /* Basic routines used by everyone */
258 
259 void
260 out_ln(void)
261 {
262  unsigned i;
263  out("\n");
264  for (i = 0; i < parenthesis_level; i++) out(" ");
265 }
266 
267 void
268 left(void)
269 {
270  parenthesis_level++; out("(");
271 }
272 
273 void
274 right(void)
275 {
276  if (parenthesis_level==0) internal_error_0("right");
277  parenthesis_level--; out(")"); out_ln();
278 }
279 
280 void
281 out_char(unsigned val)
282 {
284  else if (font_type!=FT_VANILLA) out_num(val);
285  else if (((val>='0') && (val<='9')) ||
286  ((val>='A') && (val<='Z')) ||
287  ((val>='a') && (val<='z')))
288  fprintf(file_output, "C %c", val);
289  else out_num(val);
290 }
291 
292 void
293 out_num(unsigned val)
294 {
296  else out_int(val, 16);
297 }
298 
299 static void out_digits(unsigned);
300 
301 void
302 out_int(unsigned val, unsigned base)
303 {
304  register unsigned j=0, acc=val;
305  if (val < 0) internal_error_1("out_int (val=%d)", val);
306  if (base==16) out("H ");
307  else if (base==10) out("D ");
308  else if (base==8) out("O ");
309  else internal_error_1("out_int (base=%d)", base);
310  do {
311  digits[j] = acc % base;
312  j++;
313  acc = acc / base;
314  } while (acc > 0);
315 /*
316  if ((base==16) && (ec>=0x100)) {
317  while (j<4) { digits[j] = 0; j++; }
318  }
319 */
320  out_digits(j);
321 }
322 
323 void
325 {
326  register int a = (fval & 0xfff00000) >> 20, f = fval & 0xfffff, j=0;
327  register int delta;
328 
329  out("R ");
330  if (a>0x7ff) {
331  out("-"); a = 0x1000 - a;
332  if (f>0) {
333  f = 0x100000 - f; a--;
334  }
335  }
336  do {
337  digits[j] = a % 10;
338  j++;
339  a = a / 10;
340  } while (a > 0);
341  out_digits(j);
342  out(".");
343  f = 10*f + 5; delta = 10;
344  do {
345  if (delta>0x100000) f = f + 0x80000 - (delta / 2);
346  fprintf(file_output, "%c", (f / 0x100000) + '0');
347  f = 10 * (f % 0x100000); delta = delta*10;
348  } while (f>delta);
349 }
350 
351 void
352 out_hex(unsigned char c)
353 {
354  fprintf(file_output, "%02X", c);
355 }
356 
357 static void
359 {
360  register unsigned j=counter, c;
361  while (j>0) {
362  c = digits[--j];
363  if (c<10) fprintf(file_output, "%c", c+'0');
364  else fprintf(file_output, "%c", c+'A'-10);
365  }
366 }
367 
368 void
370 {
371  fprintf(file_output, "%s", sval);
372 }
void internal_error_0(const_string fmt)
void internal_error_1(const_string fmt, int item)
mpz_t * f
Definition: gen-fib.c:34
#define c(n)
Definition: gpos-common.c:150
#define a(n)
Definition: gpos-common.c:148
int base
Definition: gsftopk.c:1502
int kind
Definition: image.c:8980
@ parameter
Definition: inputstack.h:292
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
FT_Face face
Definition: cffdrivr.c:659
const char * const_string
Definition: simpletypes.h:59
int acc
Definition: exvar.h:3
#define fprintf
Definition: mendex.h:64
int fix
Definition: list_routines.h:24
#define L_MIN
Definition: manifests.h:69
#define P_MATHEX_MIN
Definition: manifests.h:150
#define DIR_MIN
Definition: manifests.h:163
#define O_MAX
Definition: manifests.h:226
#define P_MATHEX_MAX
Definition: manifests.h:159
#define RULE_MIN
Definition: manifests.h:199
#define RULE_MAX
Definition: manifests.h:205
#define E_MAX
Definition: manifests.h:65
#define P_MATHSY_MAX
Definition: manifests.h:146
#define C_MAX
Definition: manifests.h:54
#define DIR_MAX
Definition: manifests.h:177
#define M_MAX
Definition: manifests.h:195
#define K_MAX
Definition: manifests.h:238
#define ACC_BOT
Definition: manifests.h:184
#define O_MIN
Definition: manifests.h:218
#define FT_VANILLA
Definition: manifests.h:245
#define P_MAX
Definition: manifests.h:124
#define F_MAX
Definition: manifests.h:110
#define GLUE_MAX
Definition: manifests.h:214
#define C_MIN
Definition: manifests.h:26
#define F_MIN
Definition: manifests.h:89
#define M_MIN
Definition: manifests.h:188
#define E_MIN
Definition: manifests.h:58
#define K_MIN
Definition: manifests.h:231
#define L_MAX
Definition: manifests.h:80
#define P_MIN
Definition: manifests.h:114
#define ACC_TOP
Definition: manifests.h:182
#define GLUE_MIN
Definition: manifests.h:209
#define P_MATHSY_MIN
Definition: manifests.h:128
int char_format
Definition: omfonts.c:54
int num_format
Definition: omfonts.c:55
FILE * file_output
Definition: omfonts.c:69
#define CHAR_CODE_NUM
Definition: omfonts.h:24
#define NUM_CODE_OCTAL
Definition: omfonts.h:27
void out_glue_order(unsigned order)
Definition: out_routines.c:232
void out_hex(unsigned char c)
Definition: out_routines.c:352
const_string named_mathex_parameters[]
Definition: out_routines.c:135
const_string named_parameters[]
Definition: out_routines.c:102
const_string accent_kinds[]
Definition: out_routines.c:171
unsigned digits[12]
Definition: out_routines.c:255
void out(const_string sval)
Definition: out_routines.c:369
void out_extensible_piece(unsigned piece)
Definition: out_routines.c:59
void out_type_direction(unsigned direction)
Definition: out_routines.c:160
const_string glue_kinds[]
Definition: out_routines.c:242
void out_ln(void)
Definition: out_routines.c:260
void out_ligature_command(unsigned command)
Definition: out_routines.c:75
const_string actual_directions[]
Definition: out_routines.c:156
void print_xerox_face(int face)
Definition: out_routines.c:92
const_string xerox_faces[]
Definition: out_routines.c:86
void out_shrink_stretch(unsigned shrink_stretch)
Definition: out_routines.c:217
const_string ligature_commands[]
Definition: out_routines.c:69
const_string move_directions[]
Definition: out_routines.c:185
void out_named_parameter(unsigned parameter)
Definition: out_routines.c:107
const_string named_mathsy_parameters[]
Definition: out_routines.c:117
void out_named_mathsy_parameter(unsigned parameter)
Definition: out_routines.c:124
const_string type_directions[]
Definition: out_routines.c:153
void out_num(unsigned val)
Definition: out_routines.c:293
const_string glue_shrink_stretch[]
Definition: out_routines.c:213
void out_accent_kind(unsigned kind)
Definition: out_routines.c:175
const_string character_measures[]
Definition: out_routines.c:35
void out_glue_kind(unsigned kind)
Definition: out_routines.c:246
void out_char(unsigned val)
Definition: out_routines.c:281
void out_move_direction(unsigned direction)
Definition: out_routines.c:189
void out_fix(fix fval)
Definition: out_routines.c:324
void out_character_measure(unsigned measure)
Definition: out_routines.c:44
const_string rule_measures[]
Definition: out_routines.c:199
void out_named_mathex_parameter(unsigned parameter)
Definition: out_routines.c:142
const_string extensible_pieces[]
Definition: out_routines.c:55
void right(void)
Definition: out_routines.c:274
unsigned parenthesis_level
Definition: out_routines.c:254
void left(void)
Definition: out_routines.c:268
static void out_digits(unsigned)
Definition: out_routines.c:358
void out_int(unsigned val, unsigned base)
Definition: out_routines.c:302
void out_rule_measure(unsigned measure)
Definition: out_routines.c:203
static int delta
Definition: pbmtolj.c:36
#define direction(p, c)
Definition: sh12.c:109
Definition: strexpr.c:21
int j
Definition: t4ht.c:1589
val
Definition: tex4ht.c:3227
static struct count_rec * counter
Definition: tex4ht.c:1052
#define font_type(a)
Definition: texfont.h:287
glue_orders
Definition: texnodes.h:1104