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)  

dimen_routines.c
Go to the documentation of this file.
1 /* dimen_routines.c: Data structures for holding widths, heights, etc.
2 
3 This file is part of Omega,
4 which is based on the web2c distribution of TeX,
5 
6 Copyright (c) 1994--2001 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 "header_routines.h"
28 #include "dimen_routines.h"
29 #include "char_routines.h"
30 #include "out_routines.h"
31 #include "error_routines.h"
32 #include "out_ofm.h"
33 #include "parse_ofm.h"
34 #include "omfonts.h"
35 
38  {255,15,15,63, 0,0,0,0,
39  0,0,0,0, 0,0,0,0,
40  0,0,0,0, 0,0,0,0};
42  {65535,255,255,255, 0,0,0,0,
43  0,0,0,0, 0,0,0,0,
44  0,0,0,0, 0,0,0,0};
46  {255,255,255,255, 256,256,256,256,
47  256,256,256,256, 256,256,256,0,
48  256,256,256,256, 256,256,256,0};
49 
53 unsigned char *measure_base[C_MAX+1];
54 
55 unsigned nw=0;
56 unsigned nh=0;
57 unsigned nd=0;
58 unsigned ni=0;
59 
60 void
62 {
63  register int i;
64  for (i=C_MIN; i<=C_MAX; i++) {
66  measure_max[i] = 0;
67  }
68 }
69 
70 void
72 {
73  in_list L1, L2, *the_list;
74 
75  if ((index < C_MIN) || (index > C_MAX)) {
76  internal_error_1("set_character_measure (index=%d)", index);
77  return;
78  }
79  if ((val == 0) && (index > C_WD) && (index <= C_IC))
80  return;
81  the_list = measure_list+index;
82  L1 = *the_list;
83  if (L1 == NULL) {
84  internal_error_0("set_character_measure (L1)");
85  } else {
86  L2 = L1->ptr;
87  while ((L2 != NULL) && (lval(L2) <= val)) {
88  L1 = L2;
89  L2 = L2->ptr;
90  }
91  if (val < lval(L1)) {
92  *the_list = in_list1(val, NULL);
93  (*the_list)->ptr = L1;
94  (*the_list)->actual = *the_list;
95  measure_max[index]++;
96  current_character->indices[index] = *the_list;
97  } else if (val == lval(L1)) {
98  current_character->indices[index] = L1;
99  } else {
100  L2 = in_list1(val, NULL);
101  L2->ptr = L1->ptr;
102  L2->actual = L2;
103  L1->ptr = L2;
104  measure_max[index]++;
105  current_character->indices[index] = L2;
106  }
107  }
108 }
109 
110 int next_d;
111 int excess;
112 
113 static int
114 min_cover(int h, int d)
115 {
116  in_list L = measure_list[h];
117  int m=0; /* the current size of the cover being generated */
118  int l; /* the least element covered by the current interval */
119 
120  m = 0; next_d = WEB_INFINITY;
121  while (lval(L) != WEB_INFINITY) {
122  m++; l = lval(L);
123  while (lval(L->ptr) <= (l+d)) L = L->ptr;
124  L = L->ptr;
125  if ((lval(L) - l) < next_d) next_d = lval(L) - l;
126  }
127  return m;
128 }
129 
130 /* finds best way to round */
131 
132 static int
133 shorten(int h, int m)
134 {
135  int d=0; /* the current trial interval length */
136  int k; /* the size of a minimum cover */
137  int M = measure_max[h];
138 
139  if (M>m) {
140  excess = M-m;
141  k = min_cover(h,0); d = next_d;
142  /* now the answer is at least d*/
143  /* first we ascend rapidly until finding the range */
144  do {
145  d = d+d; k = min_cover(h,d);
146  } while (k>m);
147  /* now we run through the feasible steps */
148  d = d/2; k=min_cover(h,d);
149  while (k>m) {
150  d = next_d; k = min_cover(h,d);
151  }
152  }
153  return d;
154 }
155 
156 /* reduces and indexes a list */
157 
158 static void
159 set_indices(int h, int d)
160 {
161  in_list L1; /* the current node of interest */
162  in_list L2; /* trails one step behind L1 */
163  int l; /* least value in the current interval */
164  int lprime; /* middle value for current interval */
165  int m; /* index number of nodes in the current interval */
166 
167 /* How to store the information for each character ? */
168  L1 = measure_list[h]; m = 0;
169  while (lval(L1) != WEB_INFINITY) {
170  L2 = L1;
171  m++; l = lval(L1);
172  while (lval(L1->ptr) <= (l+d)) {
173  L1 = L1->ptr; excess--;
174  if (excess==0) d = 0;
175  }
176  lprime = l + (lval(L1)-l) / 2;
177  lval(L1) = lprime;
178  L1->index = m;
179  while (L2 != L1) {
180  lval(L2) = lprime;
181  L2->actual = L1;
182  L2->index = m;
183  L2 = L2->ptr;
184  }
185  L1 = L1->ptr;
186  }
187  measure_max[h] = m;
188 }
189 
190 void
192 {
193  int delta;
194  in_list L1;
195  int i,j;
196 
197  switch(ofm_level) {
198  case OFM_TFM:
200  break;
201  case OFM_LEVEL0: case OFM_LEVEL1:
203  break;
204  default:
206  }
207  for (i=C_MIN; i<=C_MAX; i++) {
208  if (measure_max_entries[i] != 0) {
211  dimen_tables[i] = (int *) xmalloc((measure_max[i]+1)*sizeof(int));
212  L1 = measure_list[i];
213  j=0;
214  while (lval(L1) != WEB_INFINITY) {
215  L1 = L1->actual;
216  dimen_tables[i][j] = lval(L1);
217  L1 = L1->ptr;
218  j++;
219  }
220  }
221  }
222  nw = measure_max[C_WD];
223  nh = measure_max[C_HT];
224  nd = measure_max[C_DP];
225  ni = measure_max[C_IC];
226 }
227 
228 void
230 {
231  unsigned i, j;
232  unsigned char *k;
233 
234  measure_max[C_WD] = nw;
235  measure_max[C_HT] = nh;
236  measure_max[C_DP] = nd;
237  measure_max[C_IC] = ni;
242  for (i=C_IC+1; i<=C_MAX; i++) {
243  measure_max[i] = 0;
244  dimen_tables[i] = NULL;
245  }
246  for (i=C_MIN; i<=C_MAX; i++) {
247  dimen_tables[i] = (int *) xmalloc((measure_max[i]+1)*sizeof(int));
248  for (j=0; j<measure_max[i]; j++) {
249  k = measure_base[i]+4*j;
250  dimen_tables[i][j] = (((*k)&0xff) << 24) |
251  (((*(k+1))&0xff) << 16) |
252  (((*(k+2))&0xff) << 8) |
253  ((*(k+3))&0xff);
254  }
255  }
256 }
257 
258 void
260 {
261  int i, j;
262 
263  for (i=C_MIN; i<=C_MAX; i++) {
264  if (measure_max[i] != 0) {
265  left(); out("COMMENT"); out_ln();
266  for (j=0; j<measure_max[i]; j++) {
267  left();
268  out_character_measure(i); out("_ENTRY");
269  out(" "); out_int(j,10);
270  out(" "); out_fix(dimen_tables[i][j]);
271  right();
272  }
273  right();
274  }
275  }
276 }
277 
278 void
279 set_accent(unsigned kind)
280 {
281  if ((kind<ACC_TOP) || (kind>ACC_BOT)) {
282  warning_0("bad ACCENT value; ignored");
283  kind = ACC_NONE;
284  }
285  current_character->accent = kind;
286 }
287 
288 void
290 {
291  int i, j;
292 
293  for (i=C_WD; i<=C_IC; i++) {
294  out_ofm_4(0);
295  for (j=0; j<measure_max[i]; j++) {
297  }
298  }
299 }
char_entry * current_character
Definition: char_routines.c:78
static void set_indices(int h, int d)
void retrieve_dimen_tables(void)
void set_accent(unsigned kind)
int next_d
static int min_cover(int h, int d)
int OFM0_measure_max_entries[]
unsigned char * measure_base[22+1]
int excess
void output_ofm_dimension(void)
unsigned nw
int measure_max[22+1]
int * measure_max_entries
void build_dimen_tables(void)
int TFM_measure_max_entries[]
unsigned ni
in_list measure_list[22+1]
int OFM2_measure_max_entries[]
static int shorten(int h, int m)
unsigned nd
void set_character_measure(int index, int val)
void init_measures(void)
void print_dimen_tables(void)
int * dimen_tables[22+1]
unsigned nh
int h
Definition: dviconv.c:9
#define WEB_INFINITY
Definition: dvicore.c:395
void internal_error_0(const_string fmt)
void warning_0(const_string fmt)
void internal_error_1(const_string fmt, int item)
#define d(n)
Definition: gpos-common.c:151
FILE * out
Definition: hbf2gf.c:286
unsigned ofm_level
int kind
Definition: image.c:8980
const unsigned M
Definition: image.cpp:28
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
@ right
Definition: annotate.c:15
#define xmalloc(size)
Definition: writet1.c:33
in_list in_list1(int val, in_list N)
Definition: list_routines.c:53
#define lval(L)
Definition: list_routines.h:69
#define OFM_LEVEL0
Definition: manifests.h:283
#define OFM_TFM
Definition: manifests.h:282
#define C_DP
Definition: manifests.h:30
#define OFM_LEVEL1
Definition: manifests.h:284
#define C_MAX
Definition: manifests.h:54
#define ACC_BOT
Definition: manifests.h:184
#define C_HT
Definition: manifests.h:29
#define ACC_NONE
Definition: manifests.h:181
#define C_WD
Definition: manifests.h:28
#define C_MIN
Definition: manifests.h:26
#define C_IC
Definition: manifests.h:31
#define ACC_TOP
Definition: manifests.h:182
unsigned char * ofm
Definition: omfonts.c:71
double ** L1
Definition: opts.c:80
double ** L2
Definition: opts.h:106
int k
Definition: otp-parser.c:70
void out_ofm_4(unsigned i)
Definition: out_ofm.c:148
void out_ln(void)
Definition: out_routines.c:260
void out_fix(fix fval)
Definition: out_routines.c:324
void out_character_measure(unsigned measure)
Definition: out_routines.c:44
void out_int(unsigned val, unsigned base)
Definition: out_routines.c:302
unsigned depth_base
Definition: parse_ofm.c:52
unsigned width_base
Definition: parse_ofm.c:52
unsigned italic_base
Definition: parse_ofm.c:52
unsigned height_base
Definition: parse_ofm.c:52
static int delta
Definition: pbmtolj.c:36
#define index(s, c)
Definition: plain2.h:351
lft_cell * left
Definition: routines.h:73
Definition: mendex.h:20
Definition: strexpr.c:21
int j
Definition: t4ht.c:1589
m
Definition: tex4ht.c:3990
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)
@ L
Definition: ubidiimp.h:45