45
46
static integer font_arr_max = 0;
46
47
static integer font_id_maxval = 0;
48
static void grow_font_table (integer id) {
50
if (id>=font_arr_max) {
51
font_bytes += (font_arr_max-id+8)*sizeof(texfont *);
52
font_tables = xrealloc(font_tables,(id+8)*sizeof(texfont *));
55
font_tables[id+j] = NULL;
64
for (i=0;i<font_arr_max;i++) {
65
if (font_tables[i]==NULL) {
49
static void grow_font_table(integer id)
52
if (id >= font_arr_max) {
53
font_bytes += (font_arr_max - id + 8) * sizeof(texfont *);
54
font_tables = xrealloc(font_tables, (id + 8) * sizeof(texfont *));
57
font_tables[id + j] = NULL;
59
font_arr_max = id + 8;
63
integer new_font_id(void)
66
for (i = 0; i < font_arr_max; i++) {
67
if (font_tables[i] == NULL) {
71
if (i >= font_arr_max)
73
if (i > font_id_maxval)
78
integer max_font_id(void)
80
return font_id_maxval;
83
void set_max_font_id(integer i)
72
85
font_id_maxval = i;
78
return font_id_maxval;
82
set_max_font_id (integer i) {
92
font_bytes += sizeof(texfont);
93
/* most stuff is zero */
94
font_tables[id] = xcalloc(1,sizeof(texfont));
95
font_tables[id]->_font_name = NULL;
96
font_tables[id]->_font_area = NULL;
97
font_tables[id]->_font_filename = NULL;
98
font_tables[id]->_font_fullname = NULL;
99
font_tables[id]->_font_encodingname = NULL;
100
font_tables[id]->_font_cidregistry = NULL;
101
font_tables[id]->_font_cidordering = NULL;
102
font_tables[id]->_left_boundary = NULL;
103
font_tables[id]->_right_boundary = NULL;
104
font_tables[id]->_param_base = NULL;
106
set_font_bc(id, 1); /* ec = 0 */
107
set_hyphen_char(id,'-');
108
set_skew_char(id,-1);
110
/* allocate eight values including 0 */
111
set_font_params(id,7);
113
set_font_param(id,k,0);
115
/* character info zero is reserved for notdef */
116
font_tables[id]->characters = new_sa_tree(1, 0); /* stack size 1, default item value 0 */
118
ci = xcalloc(1,sizeof(charinfo));
119
set_charinfo_name(ci,xstrdup(".notdef"));
120
font_tables[id]->charinfo = ci;
121
font_tables[id]->charinfo_cache = NULL;
88
integer new_font(void)
94
font_bytes += sizeof(texfont);
95
/* most stuff is zero */
96
font_tables[id] = xcalloc(1, sizeof(texfont));
97
font_tables[id]->_font_name = NULL;
98
font_tables[id]->_font_area = NULL;
99
font_tables[id]->_font_filename = NULL;
100
font_tables[id]->_font_fullname = NULL;
101
font_tables[id]->_font_encodingname = NULL;
102
font_tables[id]->_font_cidregistry = NULL;
103
font_tables[id]->_font_cidordering = NULL;
104
font_tables[id]->_left_boundary = NULL;
105
font_tables[id]->_right_boundary = NULL;
106
font_tables[id]->_param_base = NULL;
108
set_font_bc(id, 1); /* ec = 0 */
109
set_hyphen_char(id, '-');
110
set_skew_char(id, -1);
112
/* allocate eight values including 0 */
113
set_font_params(id, 7);
114
for (k = 0; k <= 7; k++) {
115
set_font_param(id, k, 0);
117
/* character info zero is reserved for notdef */
118
font_tables[id]->characters = new_sa_tree(1, 0); /* stack size 1, default item value 0 */
120
ci = xcalloc(1, sizeof(charinfo));
121
set_charinfo_name(ci, xstrdup(".notdef"));
122
font_tables[id]->charinfo = ci;
123
font_tables[id]->charinfo_cache = NULL;
126
128
#define Charinfo_count(a) font_tables[a]->charinfo_count
127
129
#define Charinfo_size(a) font_tables[a]->charinfo_size
128
130
#define Characters(a) font_tables[a]->characters
131
get_charinfo (internal_font_number f, integer c) {
134
if (proper_char_index(c)) {
135
glyph = get_sa_item(Characters(f), c);
137
/* this could be optimized using controlled growth */
138
font_bytes += sizeof(charinfo);
139
glyph = ++font_tables[f]->charinfo_count;
140
do_realloc(font_tables[f]->charinfo, (glyph+1), charinfo);
141
memset (&(font_tables[f]->charinfo[glyph]),0,sizeof(charinfo));
142
font_tables[f]->charinfo[glyph].ef = 1000; /* init */
143
font_tables[f]->charinfo_size = glyph;
144
set_sa_item(font_tables[f]->characters, c, glyph, 1); /* 1= global */
146
return &(font_tables[f]->charinfo[glyph]);
147
} else if (c == left_boundarychar) {
148
if (left_boundary(f)==NULL) {
149
ci = xcalloc(1,sizeof(charinfo));
150
font_bytes += sizeof(charinfo);
151
set_left_boundary(f,ci);
153
return left_boundary(f);
154
} else if (c == right_boundarychar) {
155
if (right_boundary(f)==NULL) {
156
ci = xcalloc(1,sizeof(charinfo));
157
font_bytes += sizeof(charinfo);
158
set_right_boundary(f,ci);
160
return right_boundary(f);
162
return &(font_tables[f]->charinfo[0]);
166
set_charinfo (internal_font_number f, integer c, charinfo *ci) {
168
if (proper_char_index(c)) {
169
glyph = get_sa_item(Characters(f), c);
171
font_tables[f]->charinfo[glyph] = *ci;
173
pdftex_fail("font: %s","character insertion failed");
175
} else if (c == left_boundarychar) {
176
set_left_boundary(f,ci);
177
} else if (c == right_boundarychar) {
178
set_right_boundary(f,ci);
185
copy_charinfo (charinfo *ci) {
189
real_eight_bits *packet;
193
co = xmalloc(sizeof(charinfo));
194
memcpy(co,ci,sizeof(charinfo));
195
set_charinfo_used(co,false);
197
co->tounicode = NULL;
199
co->ligatures = NULL;
201
co->extensible = NULL;
202
if (ci->name!=NULL) {
203
co->name = xstrdup(ci->name);
205
if (ci->tounicode!=NULL) {
206
co->tounicode = xstrdup(ci->tounicode);
209
if ((kern = get_charinfo_kerns(ci)) != NULL) {
211
while (!kern_end(kern[x])) { x++; } x++;
212
co->kerns = xmalloc (x*sizeof(kerninfo));
213
memcpy(co->kerns,ci->kerns,(x*sizeof(kerninfo)));
216
if ((lig = get_charinfo_ligatures(ci)) != NULL) {
218
while (!lig_end(lig[x])) { x++; } x++;
219
co->ligatures = xmalloc (x*sizeof(liginfo));
220
memcpy(co->ligatures,ci->ligatures,(x*sizeof(liginfo)));
223
if ((packet = get_charinfo_packets(ci)) != NULL) {
224
x = vf_packet_bytes(ci);
225
co->packets = xmalloc (x);
226
memcpy(co->packets,ci->packets,x);
228
if (get_charinfo_tag(ci)==ext_tag) {
229
int top, bot, rep, mid;
230
top = get_charinfo_extensible(ci,EXT_TOP);
231
bot = get_charinfo_extensible(ci,EXT_BOT);
232
mid = get_charinfo_extensible(ci,EXT_MID);
233
rep = get_charinfo_extensible(ci,EXT_REP);
234
set_charinfo_extensible(co,top,bot,mid,rep);
132
charinfo *get_charinfo(internal_font_number f, integer c)
136
if (proper_char_index(c)) {
137
glyph = get_sa_item(Characters(f), c);
139
/* this could be optimized using controlled growth */
140
font_bytes += sizeof(charinfo);
141
glyph = ++font_tables[f]->charinfo_count;
142
do_realloc(font_tables[f]->charinfo, (glyph + 1), charinfo);
143
memset(&(font_tables[f]->charinfo[glyph]), 0, sizeof(charinfo));
144
font_tables[f]->charinfo[glyph].ef = 1000; /* init */
145
font_tables[f]->charinfo_size = glyph;
146
set_sa_item(font_tables[f]->characters, c, glyph, 1); /* 1= global */
148
return &(font_tables[f]->charinfo[glyph]);
149
} else if (c == left_boundarychar) {
150
if (left_boundary(f) == NULL) {
151
ci = xcalloc(1, sizeof(charinfo));
152
font_bytes += sizeof(charinfo);
153
set_left_boundary(f, ci);
155
return left_boundary(f);
156
} else if (c == right_boundarychar) {
157
if (right_boundary(f) == NULL) {
158
ci = xcalloc(1, sizeof(charinfo));
159
font_bytes += sizeof(charinfo);
160
set_right_boundary(f, ci);
162
return right_boundary(f);
164
return &(font_tables[f]->charinfo[0]);
167
void set_charinfo(internal_font_number f, integer c, charinfo * ci)
170
if (proper_char_index(c)) {
171
glyph = get_sa_item(Characters(f), c);
173
font_tables[f]->charinfo[glyph] = *ci;
175
pdftex_fail("font: %s", "character insertion failed");
177
} else if (c == left_boundarychar) {
178
set_left_boundary(f, ci);
179
} else if (c == right_boundarychar) {
180
set_right_boundary(f, ci);
186
charinfo *copy_charinfo(charinfo * ci)
191
real_eight_bits *packet;
195
co = xmalloc(sizeof(charinfo));
196
memcpy(co, ci, sizeof(charinfo));
197
set_charinfo_used(co, false);
199
co->tounicode = NULL;
201
co->ligatures = NULL;
203
co->extensible = NULL;
204
if (ci->name != NULL) {
205
co->name = xstrdup(ci->name);
207
if (ci->tounicode != NULL) {
208
co->tounicode = xstrdup(ci->tounicode);
211
if ((kern = get_charinfo_kerns(ci)) != NULL) {
213
while (!kern_end(kern[x])) {
217
co->kerns = xmalloc(x * sizeof(kerninfo));
218
memcpy(co->kerns, ci->kerns, (x * sizeof(kerninfo)));
221
if ((lig = get_charinfo_ligatures(ci)) != NULL) {
223
while (!lig_end(lig[x])) {
227
co->ligatures = xmalloc(x * sizeof(liginfo));
228
memcpy(co->ligatures, ci->ligatures, (x * sizeof(liginfo)));
231
if ((packet = get_charinfo_packets(ci)) != NULL) {
232
x = vf_packet_bytes(ci);
233
co->packets = xmalloc(x);
234
memcpy(co->packets, ci->packets, x);
236
if (get_charinfo_tag(ci) == ext_tag) {
237
int top, bot, rep, mid;
238
top = get_charinfo_extensible(ci, EXT_TOP);
239
bot = get_charinfo_extensible(ci, EXT_BOT);
240
mid = get_charinfo_extensible(ci, EXT_MID);
241
rep = get_charinfo_extensible(ci, EXT_REP);
242
set_charinfo_extensible(co, top, bot, mid, rep);
241
find_charinfo_id (internal_font_number f, integer c) {
243
if (font_tables[f]->charinfo_cache==NULL) {
244
int i = (font_ec(f)+1)*sizeof(int);
245
font_tables[f]->charinfo_cache = xmalloc(i);
246
memset(font_tables[f]->charinfo_cache,0,i);
248
g = font_tables[f]->charinfo_cache[c];
251
g = get_sa_item(font_tables[f]->characters, c);
252
font_tables[f]->charinfo_cache[c] = g;
248
int find_charinfo_id(internal_font_number f, integer c)
251
if (font_tables[f]->charinfo_cache == NULL) {
252
int i = (font_ec(f) + 1) * sizeof(int);
253
font_tables[f]->charinfo_cache = xmalloc(i);
254
memset(font_tables[f]->charinfo_cache, 0, i);
256
g = font_tables[f]->charinfo_cache[c];
259
g = get_sa_item(font_tables[f]->characters, c);
260
font_tables[f]->charinfo_cache[c] = g;
257
#define find_charinfo_id(f,c) get_sa_item(font_tables[f]->characters,c)
265
# define find_charinfo_id(f,c) get_sa_item(font_tables[f]->characters,c)
262
char_info (internal_font_number f, integer c) {
263
if (f>font_id_maxval)
265
if (proper_char_index(c)) {
266
register int glyph = find_charinfo_id(f,c);
267
return &(font_tables[f]->charinfo[glyph]);
268
} else if (c == left_boundarychar && left_boundary(f)!=NULL) {
269
return left_boundary(f);
270
} else if (c == right_boundarychar && right_boundary(f)!=NULL) {
271
return right_boundary(f);
273
return &(font_tables[f]->charinfo[0]);
277
char_info_short (internal_font_number f, integer c) {
288
char_exists (internal_font_number f, integer c) {
289
if (f>font_id_maxval)
291
if (proper_char_index(c)) {
292
return find_charinfo_id(f,c);
293
} else if ((c == left_boundarychar) && has_left_boundary(f)) {
295
} else if ((c == right_boundarychar) && has_right_boundary(f)) {
302
lua_char_exists_callback (internal_font_number f, integer c) {
303
integer callback_id ;
304
lua_State *L = Luas[0];
306
callback_id = callback_defined(char_exists_callback);
307
if (callback_id!=0) {
308
lua_rawgeti(L,LUA_REGISTRYINDEX,callback_callbacks_id);
309
lua_rawgeti(L,-1, callback_id);
310
if (!lua_isfunction(L,-1)) {
316
if (lua_pcall(L,2,1,0) != 0) { /* two args, 1 result */
317
fprintf(stdout,"error: %s\n",lua_tostring(L,-1));
321
ret = lua_toboolean(L,-1);
328
void set_charinfo_width (charinfo *ci, scaled val) { ci->width = val; }
329
void set_charinfo_height (charinfo *ci, scaled val) { ci->height = val; }
330
void set_charinfo_depth (charinfo *ci, scaled val) { ci->depth = val; }
331
void set_charinfo_italic (charinfo *ci, scaled val) { ci->italic = val; }
332
void set_charinfo_tag (charinfo *ci, scaled val) { ci->tag = val; }
333
void set_charinfo_remainder (charinfo *ci, scaled val) { ci->remainder = val; }
334
void set_charinfo_used (charinfo *ci, scaled val) { ci->used = val; }
335
void set_charinfo_index (charinfo *ci, scaled val) { ci->index = val; }
336
void set_charinfo_name (charinfo *ci, char *val) { dxfree(ci->name,val); }
337
void set_charinfo_tounicode (charinfo *ci, char *val) { dxfree(ci->tounicode,val); }
338
void set_charinfo_ligatures (charinfo *ci, liginfo *val) { dxfree(ci->ligatures,val); }
339
void set_charinfo_kerns (charinfo *ci, kerninfo *val) { dxfree(ci->kerns,val); }
340
void set_charinfo_packets (charinfo *ci, real_eight_bits *val){ dxfree(ci->packets,val); }
341
void set_charinfo_ef (charinfo *ci, scaled val) { ci->ef = val; }
342
void set_charinfo_lp (charinfo *ci, scaled val) { ci->lp = val; }
343
void set_charinfo_rp (charinfo *ci, scaled val) { ci->rp = val; }
347
void set_charinfo_extensible (charinfo *ci, int top, int bot, int mid, int rep) {
348
if (top == 0 && bot == 0 && mid == 0 && rep == 0) {
349
if (ci->extensible != NULL) {
350
free(ci->extensible);
351
ci->extensible = NULL;
354
if (ci->extensible == NULL) {
355
ci->extensible = xmalloc(4*sizeof(integer));
357
ci->extensible[EXT_TOP] = top;
358
ci->extensible[EXT_BOT] = bot;
359
ci->extensible[EXT_MID] = mid;
360
ci->extensible[EXT_REP] = rep;
364
scaled get_charinfo_width (charinfo *ci) { return ci->width; }
365
scaled get_charinfo_height (charinfo *ci) { return ci->height; }
366
scaled get_charinfo_depth (charinfo *ci) { return ci->depth; }
367
scaled get_charinfo_italic (charinfo *ci) { return ci->italic; }
368
char get_charinfo_tag (charinfo *ci) { return ci->tag; }
369
integer get_charinfo_remainder (charinfo *ci) { return ci->remainder; }
370
char get_charinfo_used (charinfo *ci) { return ci->used; }
371
integer get_charinfo_index (charinfo *ci) { return ci->index; }
372
char *get_charinfo_name (charinfo *ci) { return ci->name; }
373
char *get_charinfo_tounicode (charinfo *ci) { return ci->tounicode; }
374
liginfo *get_charinfo_ligatures (charinfo *ci) { return ci->ligatures; }
375
kerninfo *get_charinfo_kerns (charinfo *ci) { return ci->kerns; }
376
real_eight_bits *get_charinfo_packets (charinfo *ci) { return ci->packets; }
377
integer get_charinfo_ef (charinfo *ci) { return ci->ef; }
378
integer get_charinfo_rp (charinfo *ci) { return ci->rp; }
379
integer get_charinfo_lp (charinfo *ci) { return ci->lp; }
381
integer get_charinfo_extensible (charinfo *ci, int whch) {
383
if (ci->extensible != NULL)
384
w = ci->extensible[whch];
388
integer ext_top (internal_font_number f, integer c) {
389
charinfo *ci = char_info(f,c);
390
integer w = get_charinfo_extensible(ci,EXT_TOP);
391
/* fprintf(stdout,"top of char 0x%4x in font %s: %i\n",c,font_name(f),w);*/
395
integer ext_bot (internal_font_number f, integer c) {
396
charinfo *ci = char_info(f,c);
397
integer w = get_charinfo_extensible(ci,EXT_BOT);
398
/*fprintf(stdout,"bot of char 0x%4x in font %s: %i\n",c,font_name(f),w);*/
401
integer ext_mid (internal_font_number f, integer c) {
402
charinfo *ci = char_info(f,c);
403
integer w = get_charinfo_extensible(ci,EXT_MID);
404
/*fprintf(stdout,"mid of char 0x%4x in font %s: %i\n",c,font_name(f),w);*/
407
integer ext_rep (internal_font_number f, integer c) {
408
charinfo *ci = char_info(f,c);
409
integer w = get_charinfo_extensible(ci,EXT_REP);
410
/*fprintf(stdout,"rep of char 0x%4x in font %s: %i\n",c,font_name(f),w);*/
414
scaled char_width (internal_font_number f, integer c) {
415
charinfo *ci = char_info(f,c);
416
scaled w = get_charinfo_width(ci);
417
/*fprintf(stdout,"width of char 0x%x in font %s: %i\n",c,font_name(f),w);*/
421
scaled char_depth (internal_font_number f, integer c) {
422
charinfo *ci = char_info(f,c);
423
scaled w = get_charinfo_depth(ci);
424
/*fprintf(stdout,"depth of char 0x%x in font %s: %i\n",c,font_name(f),w);*/
428
scaled char_height (internal_font_number f, integer c) {
429
charinfo *ci = char_info(f,c);
430
scaled w = get_charinfo_height(ci);
431
/*fprintf(stdout,"height of char 0x%x in font %s: %i\n",c,font_name(f),w);*/
435
scaled char_italic (internal_font_number f, integer c) {
436
charinfo *ci = char_info(f,c);
437
return get_charinfo_italic(ci);
440
integer char_remainder (internal_font_number f, integer c) {
441
charinfo *ci = char_info(f,c);
442
return get_charinfo_remainder(ci);
445
char char_tag (internal_font_number f, integer c) {
446
charinfo *ci = char_info(f,c);
447
return get_charinfo_tag(ci);
450
char char_used (internal_font_number f, integer c) {
451
charinfo *ci = char_info(f,c);
452
return get_charinfo_used(ci);
455
char *char_name (internal_font_number f, integer c) {
456
charinfo *ci = char_info(f,c);
457
return get_charinfo_name(ci);
460
integer char_index (internal_font_number f, integer c) {
461
charinfo *ci = char_info(f,c);
462
return get_charinfo_index(ci);
465
liginfo * char_ligatures (internal_font_number f, integer c) {
466
charinfo *ci = char_info(f,c);
467
return get_charinfo_ligatures(ci);
470
kerninfo * char_kerns (internal_font_number f, integer c) {
471
charinfo *ci = char_info(f,c);
472
return get_charinfo_kerns(ci);
475
real_eight_bits * char_packets (internal_font_number f, integer c) {
476
charinfo *ci = char_info(f,c);
477
return get_charinfo_packets(ci);
482
set_font_params(internal_font_number f, int b) {
486
font_bytes += (b-font_params(f))*sizeof(scaled);
487
do_realloc(param_base(f), (b+1), integer);
492
set_font_param(f,i,0);
500
copy_font (integer f) {
503
integer k = new_font();
504
memcpy(font_tables[k],font_tables[f],sizeof(texfont));
506
set_font_cache_id(k,0);
508
set_font_touched(k,0);
510
font_tables[k]->_font_name = NULL;
511
font_tables[k]->_font_filename = NULL;
512
font_tables[k]->_font_fullname = NULL;
513
font_tables[k]->_font_encodingname = NULL;
514
font_tables[k]->_font_area = NULL;
515
font_tables[k]->_font_cidregistry = NULL;
516
font_tables[k]->_font_cidordering = NULL;
517
font_tables[k]->_left_boundary = NULL;
518
font_tables[k]->_right_boundary = NULL;
520
set_font_name(k,xstrdup(font_name(f)));
521
if (font_filename(f)!= NULL)
522
set_font_filename(k,xstrdup(font_filename(f)));
523
if (font_fullname(f)!= NULL)
524
set_font_fullname(k,xstrdup(font_fullname(f)));
525
if (font_encodingname(f)!= NULL)
526
set_font_encodingname(k,xstrdup(font_encodingname(f)));
527
if (font_area(f)!= NULL)
528
set_font_area(k,xstrdup(font_area(f)));
529
if (font_cidregistry(f)!= NULL)
530
set_font_cidregistry(k,xstrdup(font_cidregistry(f)));
531
if (font_cidordering(f)!= NULL)
532
set_font_cidordering(k,xstrdup(font_cidordering(f)));
534
i = sizeof(*param_base(f))*font_params(f);
536
param_base(k) = xmalloc (i);
537
memcpy(param_base(k),param_base(f), i);
539
i = sizeof(charinfo)*(Charinfo_size(f)+1);
541
font_tables[k]->charinfo = xmalloc(i);
542
memset(font_tables[k]->charinfo,0,i);
543
for(i=0;i<=Charinfo_size(k);i++) {
544
ci = copy_charinfo(&font_tables[f]->charinfo[i]);
545
font_tables[k]->charinfo[i] = *ci;
548
if (left_boundary(f)!= NULL ) {
549
ci = copy_charinfo(left_boundary(f));
550
set_charinfo(k,left_boundarychar,ci);
553
if (right_boundary(f)!= NULL ) {
554
ci = copy_charinfo(right_boundary(f));
555
set_charinfo(k,right_boundarychar,ci);
560
void delete_font (integer f) {
564
if (font_tables[f]!=NULL) {
565
set_font_name(f,NULL);
566
set_font_filename(f,NULL);
567
set_font_fullname(f,NULL);
568
set_font_encodingname(f,NULL);
569
set_font_area(f,NULL);
570
set_font_cidregistry(f,NULL);
571
set_font_cidordering(f,NULL);
572
set_left_boundary(f,NULL);
573
set_right_boundary(f,NULL);
575
for(i=font_bc(f); i<=font_ec(f); i++) {
576
if (char_exists(f,i)) {
578
set_charinfo_name(co,NULL);
579
set_charinfo_tounicode(co,NULL);
580
set_charinfo_packets(co,NULL);
581
set_charinfo_ligatures(co,NULL);
582
set_charinfo_kerns(co,NULL);
583
set_charinfo_extensible(co,0,0,0,0);
587
set_charinfo_name(font_tables[f]->charinfo+0,NULL);
588
free(font_tables[f]->charinfo);
589
destroy_sa_tree(font_tables[f]->characters);
592
free(font_tables[f]);
593
font_tables[f] = NULL;
595
if (font_id_maxval==f) {
602
create_null_font (void) {
605
set_font_name(i,xstrdup("nullfont"));
606
set_font_area(i,xstrdup(""));
607
set_font_touched(i,1);
611
is_valid_font (integer id) {
613
if (id>=0 && id<=font_id_maxval && font_tables[id]!=NULL)
269
charinfo *char_info(internal_font_number f, integer c)
271
if (f > font_id_maxval)
273
if (proper_char_index(c)) {
274
register int glyph = find_charinfo_id(f, c);
275
return &(font_tables[f]->charinfo[glyph]);
276
} else if (c == left_boundarychar && left_boundary(f) != NULL) {
277
return left_boundary(f);
278
} else if (c == right_boundarychar && right_boundary(f) != NULL) {
279
return right_boundary(f);
281
return &(font_tables[f]->charinfo[0]);
284
charinfo_short char_info_short(internal_font_number f, integer c)
295
integer char_exists(internal_font_number f, integer c)
297
if (f > font_id_maxval)
299
if (proper_char_index(c)) {
300
return find_charinfo_id(f, c);
301
} else if ((c == left_boundarychar) && has_left_boundary(f)) {
303
} else if ((c == right_boundarychar) && has_right_boundary(f)) {
309
int lua_char_exists_callback(internal_font_number f, integer c)
312
lua_State *L = Luas[0];
314
callback_id = callback_defined(char_exists_callback);
315
if (callback_id != 0) {
316
lua_rawgeti(L, LUA_REGISTRYINDEX, callback_callbacks_id);
317
lua_rawgeti(L, -1, callback_id);
318
if (!lua_isfunction(L, -1)) {
322
lua_pushnumber(L, f);
323
lua_pushnumber(L, c);
324
if (lua_pcall(L, 2, 1, 0) != 0) { /* two args, 1 result */
325
fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
329
ret = lua_toboolean(L, -1);
336
void set_charinfo_width(charinfo * ci, scaled val)
341
void set_charinfo_height(charinfo * ci, scaled val)
346
void set_charinfo_depth(charinfo * ci, scaled val)
351
void set_charinfo_italic(charinfo * ci, scaled val)
356
void set_charinfo_tag(charinfo * ci, scaled val)
361
void set_charinfo_remainder(charinfo * ci, scaled val)
366
void set_charinfo_used(charinfo * ci, scaled val)
371
void set_charinfo_index(charinfo * ci, scaled val)
375
void set_charinfo_name(charinfo * ci, char *val)
377
dxfree(ci->name, val);
379
void set_charinfo_tounicode(charinfo * ci, char *val)
381
dxfree(ci->tounicode, val);
384
void set_charinfo_ligatures(charinfo * ci, liginfo * val)
386
dxfree(ci->ligatures, val);
389
void set_charinfo_kerns(charinfo * ci, kerninfo * val)
391
dxfree(ci->kerns, val);
394
void set_charinfo_packets(charinfo * ci, real_eight_bits * val)
396
dxfree(ci->packets, val);
399
void set_charinfo_ef(charinfo * ci, scaled val)
404
void set_charinfo_lp(charinfo * ci, scaled val)
409
void set_charinfo_rp(charinfo * ci, scaled val)
416
void set_charinfo_extensible(charinfo * ci, int top, int bot, int mid, int rep)
418
if (top == 0 && bot == 0 && mid == 0 && rep == 0) {
419
if (ci->extensible != NULL) {
420
free(ci->extensible);
421
ci->extensible = NULL;
424
if (ci->extensible == NULL) {
425
ci->extensible = xmalloc(4 * sizeof(integer));
427
ci->extensible[EXT_TOP] = top;
428
ci->extensible[EXT_BOT] = bot;
429
ci->extensible[EXT_MID] = mid;
430
ci->extensible[EXT_REP] = rep;
434
scaled get_charinfo_width(charinfo * ci)
439
scaled get_charinfo_height(charinfo * ci)
444
scaled get_charinfo_depth(charinfo * ci)
449
scaled get_charinfo_italic(charinfo * ci)
454
char get_charinfo_tag(charinfo * ci)
459
integer get_charinfo_remainder(charinfo * ci)
461
return ci->remainder;
464
char get_charinfo_used(charinfo * ci)
469
integer get_charinfo_index(charinfo * ci)
474
char *get_charinfo_name(charinfo * ci)
479
char *get_charinfo_tounicode(charinfo * ci)
481
return ci->tounicode;
484
liginfo *get_charinfo_ligatures(charinfo * ci)
486
return ci->ligatures;
489
kerninfo *get_charinfo_kerns(charinfo * ci)
494
real_eight_bits *get_charinfo_packets(charinfo * ci)
499
integer get_charinfo_ef(charinfo * ci)
504
integer get_charinfo_rp(charinfo * ci)
509
integer get_charinfo_lp(charinfo * ci)
514
integer get_charinfo_extensible(charinfo * ci, int whch)
517
if (ci->extensible != NULL)
518
w = ci->extensible[whch];
522
integer ext_top(internal_font_number f, integer c)
524
charinfo *ci = char_info(f, c);
525
integer w = get_charinfo_extensible(ci, EXT_TOP);
526
/* fprintf(stdout,"top of char 0x%4x in font %s: %i\n",c,font_name(f),w); */
530
integer ext_bot(internal_font_number f, integer c)
532
charinfo *ci = char_info(f, c);
533
integer w = get_charinfo_extensible(ci, EXT_BOT);
534
/*fprintf(stdout,"bot of char 0x%4x in font %s: %i\n",c,font_name(f),w); */
538
integer ext_mid(internal_font_number f, integer c)
540
charinfo *ci = char_info(f, c);
541
integer w = get_charinfo_extensible(ci, EXT_MID);
542
/*fprintf(stdout,"mid of char 0x%4x in font %s: %i\n",c,font_name(f),w); */
546
integer ext_rep(internal_font_number f, integer c)
548
charinfo *ci = char_info(f, c);
549
integer w = get_charinfo_extensible(ci, EXT_REP);
550
/*fprintf(stdout,"rep of char 0x%4x in font %s: %i\n",c,font_name(f),w); */
554
scaled char_width(internal_font_number f, integer c)
556
charinfo *ci = char_info(f, c);
557
scaled w = get_charinfo_width(ci);
558
/*fprintf(stdout,"width of char 0x%x in font %s: %i\n",c,font_name(f),w); */
562
scaled char_depth(internal_font_number f, integer c)
564
charinfo *ci = char_info(f, c);
565
scaled w = get_charinfo_depth(ci);
566
/*fprintf(stdout,"depth of char 0x%x in font %s: %i\n",c,font_name(f),w); */
570
scaled char_height(internal_font_number f, integer c)
572
charinfo *ci = char_info(f, c);
573
scaled w = get_charinfo_height(ci);
574
/*fprintf(stdout,"height of char 0x%x in font %s: %i\n",c,font_name(f),w); */
578
scaled char_italic(internal_font_number f, integer c)
580
charinfo *ci = char_info(f, c);
581
return get_charinfo_italic(ci);
584
integer char_remainder(internal_font_number f, integer c)
586
charinfo *ci = char_info(f, c);
587
return get_charinfo_remainder(ci);
590
char char_tag(internal_font_number f, integer c)
592
charinfo *ci = char_info(f, c);
593
return get_charinfo_tag(ci);
596
char char_used(internal_font_number f, integer c)
598
charinfo *ci = char_info(f, c);
599
return get_charinfo_used(ci);
602
char *char_name(internal_font_number f, integer c)
604
charinfo *ci = char_info(f, c);
605
return get_charinfo_name(ci);
608
integer char_index(internal_font_number f, integer c)
610
charinfo *ci = char_info(f, c);
611
return get_charinfo_index(ci);
614
liginfo *char_ligatures(internal_font_number f, integer c)
616
charinfo *ci = char_info(f, c);
617
return get_charinfo_ligatures(ci);
620
kerninfo *char_kerns(internal_font_number f, integer c)
622
charinfo *ci = char_info(f, c);
623
return get_charinfo_kerns(ci);
626
real_eight_bits *char_packets(internal_font_number f, integer c)
628
charinfo *ci = char_info(f, c);
629
return get_charinfo_packets(ci);
633
void set_font_params(internal_font_number f, int b)
638
font_bytes += (b - font_params(f) + 1) * sizeof(scaled);
639
do_realloc(param_base(f), (b + 2), integer);
644
set_font_param(f, i, 0);
651
integer copy_font(integer f)
655
integer k = new_font();
656
memcpy(font_tables[k], font_tables[f], sizeof(texfont));
658
set_font_cache_id(k, 0);
660
set_font_touched(k, 0);
662
font_tables[k]->_font_name = NULL;
663
font_tables[k]->_font_filename = NULL;
664
font_tables[k]->_font_fullname = NULL;
665
font_tables[k]->_font_encodingname = NULL;
666
font_tables[k]->_font_area = NULL;
667
font_tables[k]->_font_cidregistry = NULL;
668
font_tables[k]->_font_cidordering = NULL;
669
font_tables[k]->_left_boundary = NULL;
670
font_tables[k]->_right_boundary = NULL;
672
set_font_name(k, xstrdup(font_name(f)));
673
if (font_filename(f) != NULL)
674
set_font_filename(k, xstrdup(font_filename(f)));
675
if (font_fullname(f) != NULL)
676
set_font_fullname(k, xstrdup(font_fullname(f)));
677
if (font_encodingname(f) != NULL)
678
set_font_encodingname(k, xstrdup(font_encodingname(f)));
679
if (font_area(f) != NULL)
680
set_font_area(k, xstrdup(font_area(f)));
681
if (font_cidregistry(f) != NULL)
682
set_font_cidregistry(k, xstrdup(font_cidregistry(f)));
683
if (font_cidordering(f) != NULL)
684
set_font_cidordering(k, xstrdup(font_cidordering(f)));
686
i = sizeof(*param_base(f)) * font_params(f);
688
param_base(k) = xmalloc(i);
689
memcpy(param_base(k), param_base(f), i);
691
i = sizeof(charinfo) * (Charinfo_size(f) + 1);
693
font_tables[k]->charinfo = xmalloc(i);
694
memset(font_tables[k]->charinfo, 0, i);
695
for (i = 0; i <= Charinfo_size(k); i++) {
696
ci = copy_charinfo(&font_tables[f]->charinfo[i]);
697
font_tables[k]->charinfo[i] = *ci;
700
if (left_boundary(f) != NULL) {
701
ci = copy_charinfo(left_boundary(f));
702
set_charinfo(k, left_boundarychar, ci);
705
if (right_boundary(f) != NULL) {
706
ci = copy_charinfo(right_boundary(f));
707
set_charinfo(k, right_boundarychar, ci);
712
void delete_font(integer f)
717
if (font_tables[f] != NULL) {
718
set_font_name(f, NULL);
719
set_font_filename(f, NULL);
720
set_font_fullname(f, NULL);
721
set_font_encodingname(f, NULL);
722
set_font_area(f, NULL);
723
set_font_cidregistry(f, NULL);
724
set_font_cidordering(f, NULL);
725
set_left_boundary(f, NULL);
726
set_right_boundary(f, NULL);
728
for (i = font_bc(f); i <= font_ec(f); i++) {
729
if (char_exists(f, i)) {
730
co = char_info(f, i);
731
set_charinfo_name(co, NULL);
732
set_charinfo_tounicode(co, NULL);
733
set_charinfo_packets(co, NULL);
734
set_charinfo_ligatures(co, NULL);
735
set_charinfo_kerns(co, NULL);
736
set_charinfo_extensible(co, 0, 0, 0, 0);
740
set_charinfo_name(font_tables[f]->charinfo + 0, NULL);
741
free(font_tables[f]->charinfo);
742
destroy_sa_tree(font_tables[f]->characters);
745
free(font_tables[f]);
746
font_tables[f] = NULL;
748
if (font_id_maxval == f) {
754
void create_null_font(void)
758
set_font_name(i, xstrdup("nullfont"));
759
set_font_area(i, xstrdup(""));
760
set_font_touched(i, 1);
763
boolean is_valid_font(integer id)
766
if (id >= 0 && id <= font_id_maxval && font_tables[id] != NULL)
618
771
/* return 1 == identical */
620
cmp_font_name (integer id, strnumber t) {
622
if (!is_valid_font(id))
626
if (tt == NULL && tid == NULL)
628
if (tt == NULL || tid == NULL || strcmp(tid,tt)!=0)
634
cmp_font_area (integer id, strnumber t) {
636
char *tid = font_area(id);
638
if (tid == NULL || strlen(tid)==0)
644
if ((tt == NULL || strlen(tt)==0) && (tid == NULL || strlen(tid)==0))
646
if (tt == NULL || strcmp(tid,tt)!=0)
653
same_font_name (integer id, integer t) {
655
if (font_name(t) == NULL ||
656
font_name(id) == NULL ||
657
strcmp(font_name(t),font_name(id))!=0) {
666
font_shareable (internal_font_number f, internal_font_number k) {
668
if (font_cidregistry(f) == NULL) {
669
if ( hasfmentry ( k )
670
&& ( font_map ( k ) == font_map ( f ) )
671
&& ( same_font_name ( k , f )
673
( pdf_font_auto_expand (f)
674
&& ( pdf_font_blink (f) != 0 ) /* 0 = nullfont */
675
&& same_font_name ( k , pdf_font_blink (f) ) ) ) ) {
679
if ((font_filename(k) != NULL && font_filename(f) != NULL &&
680
strcmp(font_filename(k),font_filename(f)) == 0)
682
( pdf_font_auto_expand (f)
683
&& ( pdf_font_blink (f) != 0 ) /* 0 = nullfont */
684
&& same_font_name ( k , pdf_font_blink (f) ) ) ) {
692
test_no_ligatures (internal_font_number f) {
694
for (c=font_bc(f);c<=font_ec(f);c++) {
695
if (has_lig(f,c)) /* char_exists(f,c) */
702
get_tag_code (internal_font_number f, integer c) {
704
if (char_exists(f,c)) {
706
if (i==lig_tag) return 1;
707
else if (i==list_tag) return 2;
708
else if (i==ext_tag) return 4;
715
get_lp_code (internal_font_number f, integer c) {
716
charinfo *ci = char_info(f,c);
717
return get_charinfo_lp(ci);
721
get_rp_code (internal_font_number f, integer c) {
722
charinfo *ci = char_info(f,c);
723
return get_charinfo_rp(ci);
727
get_ef_code (internal_font_number f, integer c) {
728
charinfo *ci = char_info(f,c);
729
return get_charinfo_ef(ci);
733
set_tag_code (internal_font_number f, integer c, integer i) {
736
if (char_exists(f,c)) {
737
/* abs(fix_int(i-7,0)) */
738
fixedi = - (i<-7 ? -7 : (i>0 ? 0 : i )) ;
741
if (char_tag(f,c) == ext_tag)
742
set_charinfo_tag(co,(char_tag(f,c)- ext_tag));
746
if (char_tag(f,c) == list_tag)
747
set_charinfo_tag(co,(char_tag(f,c)- list_tag));
752
set_charinfo_ligatures(co,NULL);
754
set_charinfo_kerns(co,NULL);
761
set_lp_code(internal_font_number f, integer c, integer i) {
763
if (char_exists(f,c)) {
765
set_charinfo_lp(co,i);
770
set_rp_code(internal_font_number f, integer c, integer i) {
772
if (char_exists(f,c)) {
774
set_charinfo_rp(co,i);
779
set_ef_code(internal_font_number f, integer c, integer i) {
781
if (char_exists(f,c)) {
783
set_charinfo_ef(co,i);
788
set_no_ligatures (internal_font_number f) {
792
if (font_tables[f]->ligatures_disabled)
795
co = char_info(f,left_boundarychar);
796
set_charinfo_ligatures(co,NULL);
797
co = char_info(f,right_boundarychar); /* this is weird */
798
set_charinfo_ligatures(co,NULL);
799
for (c=0;c<font_tables[f]->charinfo_count;c++) {
800
co = font_tables[f]->charinfo+c;
801
set_charinfo_ligatures(co,NULL);
803
font_tables[f]->ligatures_disabled =1;
807
get_ligature (internal_font_number f, integer lc, integer rc) {
813
if (lc == non_boundarychar || rc == non_boundarychar || (!has_lig(f,lc)) )
772
boolean cmp_font_name(integer id, strnumber t)
775
if (!is_valid_font(id))
779
if (tt == NULL && tid == NULL)
781
if (tt == NULL || tid == NULL || strcmp(tid, tt) != 0)
786
boolean cmp_font_area(integer id, strnumber t)
789
char *tid = font_area(id);
791
if (tid == NULL || strlen(tid) == 0)
797
if ((tt == NULL || strlen(tt) == 0) && (tid == NULL || strlen(tid) == 0))
799
if (tt == NULL || strcmp(tid, tt) != 0)
805
static boolean same_font_name(integer id, integer t)
808
if (font_name(t) == NULL ||
809
font_name(id) == NULL || strcmp(font_name(t), font_name(id)) != 0) {
817
boolean font_shareable(internal_font_number f, internal_font_number k)
820
if (font_cidregistry(f) == NULL) {
822
&& (font_map(k) == font_map(f))
823
&& (same_font_name(k, f)
824
|| (pdf_font_auto_expand(f)
825
&& (pdf_font_blink(f) != 0) /* 0 = nullfont */
826
&&same_font_name(k, pdf_font_blink(f))))) {
830
if ((font_filename(k) != NULL && font_filename(f) != NULL &&
831
strcmp(font_filename(k), font_filename(f)) == 0)
832
|| (pdf_font_auto_expand(f)
833
&& (pdf_font_blink(f) != 0) /* 0 = nullfont */
834
&&same_font_name(k, pdf_font_blink(f)))) {
841
integer test_no_ligatures(internal_font_number f)
844
for (c = font_bc(f); c <= font_ec(f); c++) {
845
if (has_lig(f, c)) /* char_exists(f,c) */
851
integer get_tag_code(internal_font_number f, integer c)
854
if (char_exists(f, c)) {
858
else if (i == list_tag)
860
else if (i == ext_tag)
868
integer get_lp_code(internal_font_number f, integer c)
870
charinfo *ci = char_info(f, c);
871
return get_charinfo_lp(ci);
874
integer get_rp_code(internal_font_number f, integer c)
876
charinfo *ci = char_info(f, c);
877
return get_charinfo_rp(ci);
880
integer get_ef_code(internal_font_number f, integer c)
882
charinfo *ci = char_info(f, c);
883
return get_charinfo_ef(ci);
886
void set_tag_code(internal_font_number f, integer c, integer i)
890
if (char_exists(f, c)) {
891
/* abs(fix_int(i-7,0)) */
892
fixedi = -(i < -7 ? -7 : (i > 0 ? 0 : i));
893
co = char_info(f, c);
895
if (char_tag(f, c) == ext_tag)
896
set_charinfo_tag(co, (char_tag(f, c) - ext_tag));
900
if (char_tag(f, c) == list_tag)
901
set_charinfo_tag(co, (char_tag(f, c) - list_tag));
906
set_charinfo_ligatures(co, NULL);
908
set_charinfo_kerns(co, NULL);
914
void set_lp_code(internal_font_number f, integer c, integer i)
917
if (char_exists(f, c)) {
918
co = char_info(f, c);
919
set_charinfo_lp(co, i);
923
void set_rp_code(internal_font_number f, integer c, integer i)
926
if (char_exists(f, c)) {
927
co = char_info(f, c);
928
set_charinfo_rp(co, i);
932
void set_ef_code(internal_font_number f, integer c, integer i)
935
if (char_exists(f, c)) {
936
co = char_info(f, c);
937
set_charinfo_ef(co, i);
941
void set_no_ligatures(internal_font_number f)
946
if (font_tables[f]->ligatures_disabled)
949
co = char_info(f, left_boundarychar);
950
set_charinfo_ligatures(co, NULL);
951
co = char_info(f, right_boundarychar); /* this is weird */
952
set_charinfo_ligatures(co, NULL);
953
for (c = 0; c < font_tables[f]->charinfo_count; c++) {
954
co = font_tables[f]->charinfo + c;
955
set_charinfo_ligatures(co, NULL);
957
font_tables[f]->ligatures_disabled = 1;
960
liginfo get_ligature(internal_font_number f, integer lc, integer rc)
967
if (lc == non_boundarychar || rc == non_boundarychar || (!has_lig(f, lc)))
970
co = char_info(f, lc);
972
u = charinfo_ligature(co, k);
975
if (lig_char(u) == rc) {
976
if (lig_disabled(u)) {
816
co = char_info(f,lc);
818
u = charinfo_ligature(co,k);
821
if (lig_char(u) == rc) {
822
if (lig_disabled(u)) {
835
get_kern(internal_font_number f, integer lc, integer rc)
988
scaled get_kern(internal_font_number f, integer lc, integer rc)
840
if (lc == non_boundarychar || rc == non_boundarychar || (!has_kern(f,lc)) )
993
if (lc == non_boundarychar || rc == non_boundarychar || (!has_kern(f, lc)))
996
co = char_info(f, lc);
998
u = charinfo_kern(co, k);
1001
if (kern_char(u) == rc) {
1002
if (kern_disabled(u))
1005
return kern_kern(u);
843
co = char_info(f,lc);
845
u = charinfo_kern(co,k);
848
if (kern_char(u) == rc) {
849
if (kern_disabled(u))
860
1013
/* dumping and undumping fonts */
862
#define dump_string(a) \
865
dump_int(x); dump_things(*a, x); \
867
x = 0; dump_int(x); \
1015
#define dump_string(a) \
1018
dump_int(x); dump_things(*a, x); \
1020
x = 0; dump_int(x); \
871
dump_charinfo (int f , int c) {
879
set_charinfo_used(co,0);
880
dump_int(get_charinfo_width(co));
881
dump_int(get_charinfo_height(co));
882
dump_int(get_charinfo_depth(co));
883
dump_int(get_charinfo_italic(co));
884
dump_int(get_charinfo_tag(co));
885
dump_int(get_charinfo_ef(co));
886
dump_int(get_charinfo_rp(co));
887
dump_int(get_charinfo_lp(co));
888
dump_int(get_charinfo_remainder(co));
889
dump_int(get_charinfo_used(co));
890
dump_int(get_charinfo_index(co));
891
dump_string(get_charinfo_name(co));
892
dump_string(get_charinfo_tounicode(co));
896
if ((lig = get_charinfo_ligatures(co)) != NULL) {
897
while (!lig_end(lig[x])) { x++; }
899
dump_int(x); dump_things(*lig, x);
1023
void dump_charinfo(int f, int c)
1031
co = char_info(f, c);
1032
set_charinfo_used(co, 0);
1033
dump_int(get_charinfo_width(co));
1034
dump_int(get_charinfo_height(co));
1035
dump_int(get_charinfo_depth(co));
1036
dump_int(get_charinfo_italic(co));
1037
dump_int(get_charinfo_tag(co));
1038
dump_int(get_charinfo_ef(co));
1039
dump_int(get_charinfo_rp(co));
1040
dump_int(get_charinfo_lp(co));
1041
dump_int(get_charinfo_remainder(co));
1042
dump_int(get_charinfo_used(co));
1043
dump_int(get_charinfo_index(co));
1044
dump_string(get_charinfo_name(co));
1045
dump_string(get_charinfo_tounicode(co));
1049
if ((lig = get_charinfo_ligatures(co)) != NULL) {
1050
while (!lig_end(lig[x])) {
1055
dump_things(*lig, x);
1061
if ((kern = get_charinfo_kerns(co)) != NULL) {
1062
while (!kern_end(kern[x])) {
1067
dump_things(*kern, x);
1072
x = vf_packet_bytes(co);
905
if ((kern = get_charinfo_kerns(co)) != NULL) {
906
while (!kern_end(kern[x])) { x++; }
908
dump_int(x); dump_things(*kern, x);
913
x= vf_packet_bytes(co);
916
dump_things(*get_charinfo_packets(co), x);
919
if (get_charinfo_tag(co)==ext_tag) {
920
x = get_charinfo_extensible(co,EXT_TOP); dump_int(x);
921
x = get_charinfo_extensible(co,EXT_BOT); dump_int(x);
922
x = get_charinfo_extensible(co,EXT_MID); dump_int(x);
923
x = get_charinfo_extensible(co,EXT_REP); dump_int(x);
932
font_tables[f]->charinfo_cache = NULL;
933
dump_things(*(font_tables[f]), 1);
934
dump_string(font_name(f));
935
dump_string(font_area(f));
936
dump_string(font_filename(f));
937
dump_string(font_fullname(f));
938
dump_string(font_encodingname(f));
939
dump_string(font_cidregistry(f));
940
dump_string(font_cidordering(f));
942
dump_things(*param_base(f),(font_params(f)+1));
944
if (has_left_boundary(f)) {
945
dump_int(1); dump_charinfo(f,left_boundarychar);
949
if (has_right_boundary(f)) {
950
dump_int(1); dump_charinfo(f,right_boundarychar);
955
for(i=font_bc(f); i<=font_ec(f); i++) {
956
if (char_exists(f,i)) {
963
undump_charinfo (int f) {
968
kerninfo *kern = NULL;
969
real_eight_bits *packet = NULL;
970
int top = 0, bot = 0, mid = 0, rep = 0;
973
co = get_charinfo(f,i);
974
undump_int(x); set_charinfo_width(co,x);
975
undump_int(x); set_charinfo_height(co,x);
976
undump_int(x); set_charinfo_depth(co,x);
977
undump_int(x); set_charinfo_italic(co,x);
978
undump_int(x); set_charinfo_tag(co,x);
979
undump_int(x); set_charinfo_ef(co,x);
980
undump_int(x); set_charinfo_rp(co,x);
981
undump_int(x); set_charinfo_lp(co,x);
982
undump_int(x); set_charinfo_remainder(co,x);
983
undump_int(x); set_charinfo_used(co,x);
984
undump_int(x); set_charinfo_index(co,x);
993
set_charinfo_name(co,s);
1000
undump_things(*s,x);
1002
set_charinfo_tounicode(co,s);
1007
font_bytes += x*sizeof(liginfo);
1008
lig = xmalloc(x*sizeof(liginfo));
1009
undump_things(*lig,x);
1011
set_charinfo_ligatures(co,lig);
1016
font_bytes += x*sizeof(kerninfo);
1017
kern = xmalloc(x*sizeof(kerninfo));
1018
undump_things(*kern,x);
1020
set_charinfo_kerns(co,kern);
1026
packet = xmalloc(x);
1027
undump_things(*packet,x);
1029
set_charinfo_packets(co,packet);
1031
if (get_charinfo_tag(co)==ext_tag) {
1036
set_charinfo_extensible(co,top,bot,mid,rep);
1041
#define undump_font_string(a) undump_int (x); \
1044
s = xmalloc(x); undump_things(*s,x); \
1075
dump_things(*get_charinfo_packets(co), x);
1078
if (get_charinfo_tag(co) == ext_tag) {
1079
x = get_charinfo_extensible(co, EXT_TOP);
1081
x = get_charinfo_extensible(co, EXT_BOT);
1083
x = get_charinfo_extensible(co, EXT_MID);
1085
x = get_charinfo_extensible(co, EXT_REP);
1090
void dump_font(int f)
1094
set_font_used(f, 0);
1095
font_tables[f]->charinfo_cache = NULL;
1096
dump_things(*(font_tables[f]), 1);
1097
dump_string(font_name(f));
1098
dump_string(font_area(f));
1099
dump_string(font_filename(f));
1100
dump_string(font_fullname(f));
1101
dump_string(font_encodingname(f));
1102
dump_string(font_cidregistry(f));
1103
dump_string(font_cidordering(f));
1105
dump_things(*param_base(f), (font_params(f) + 1));
1107
if (has_left_boundary(f)) {
1109
dump_charinfo(f, left_boundarychar);
1113
if (has_right_boundary(f)) {
1115
dump_charinfo(f, right_boundarychar);
1120
for (i = font_bc(f); i <= font_ec(f); i++) {
1121
if (char_exists(f, i)) {
1122
dump_charinfo(f, i);
1127
int undump_charinfo(int f)
1132
liginfo *lig = NULL;
1133
kerninfo *kern = NULL;
1134
real_eight_bits *packet = NULL;
1135
int top = 0, bot = 0, mid = 0, rep = 0;
1138
co = get_charinfo(f, i);
1140
set_charinfo_width(co, x);
1142
set_charinfo_height(co, x);
1144
set_charinfo_depth(co, x);
1146
set_charinfo_italic(co, x);
1148
set_charinfo_tag(co, x);
1150
set_charinfo_ef(co, x);
1152
set_charinfo_rp(co, x);
1154
set_charinfo_lp(co, x);
1156
set_charinfo_remainder(co, x);
1158
set_charinfo_used(co, x);
1160
set_charinfo_index(co, x);
1167
undump_things(*s, x);
1169
set_charinfo_name(co, s);
1176
undump_things(*s, x);
1178
set_charinfo_tounicode(co, s);
1183
font_bytes += x * sizeof(liginfo);
1184
lig = xmalloc(x * sizeof(liginfo));
1185
undump_things(*lig, x);
1187
set_charinfo_ligatures(co, lig);
1192
font_bytes += x * sizeof(kerninfo);
1193
kern = xmalloc(x * sizeof(kerninfo));
1194
undump_things(*kern, x);
1196
set_charinfo_kerns(co, kern);
1202
packet = xmalloc(x);
1203
undump_things(*packet, x);
1205
set_charinfo_packets(co, packet);
1207
if (get_charinfo_tag(co) == ext_tag) {
1212
set_charinfo_extensible(co, top, bot, mid, rep);
1217
#define undump_font_string(a) undump_int (x); \
1220
s = xmalloc(x); undump_things(*s,x); \
1224
void undump_font(int f)
1055
grow_font_table (f);
1056
font_tables[f] = NULL;
1057
font_bytes += sizeof(texfont);
1058
tt = xmalloc(sizeof(texfont));
1059
undump_things(*tt,1);
1060
font_tables[f] = tt;
1062
undump_font_string(set_font_name);
1063
undump_font_string(set_font_area);
1064
undump_font_string(set_font_filename);
1065
undump_font_string(set_font_fullname);
1066
undump_font_string(set_font_encodingname);
1067
undump_font_string(set_font_cidregistry);
1068
undump_font_string(set_font_cidordering);
1070
i = sizeof(*param_base(f))*(font_params(f)+1);
1072
param_base(f) = xmalloc (i);
1073
undump_things(*param_base(f), (font_params(f)+1));
1075
font_tables[f]->_left_boundary = NULL;
1077
if (x) { i = undump_charinfo(f); } /* left boundary */
1079
font_tables[f]->_right_boundary = NULL;
1081
if (x) { i = undump_charinfo(f); } /* right boundary */
1084
font_tables[f]->characters = new_sa_tree(1, 0); /* stack size 1, default item value 0 */
1085
ci = xcalloc(1,sizeof(charinfo));
1086
set_charinfo_name(ci,xstrdup(".notdef"));
1087
font_tables[f]->charinfo = ci;
1090
while(i<font_ec(f)) {
1091
i = undump_charinfo(f);
1231
font_tables[f] = NULL;
1232
font_bytes += sizeof(texfont);
1233
tt = xmalloc(sizeof(texfont));
1234
undump_things(*tt, 1);
1235
/* these |char *| need resetting */
1236
tt->_font_name = NULL;
1237
tt->_font_area = NULL;
1238
tt->_font_filename = NULL;
1239
tt->_font_fullname = NULL;
1240
tt->_font_encodingname = NULL;
1241
tt->_font_cidregistry = NULL;
1242
tt->_font_cidordering = NULL;
1243
font_tables[f] = tt;
1245
undump_font_string(set_font_name);
1246
undump_font_string(set_font_area);
1247
undump_font_string(set_font_filename);
1248
undump_font_string(set_font_fullname);
1249
undump_font_string(set_font_encodingname);
1250
undump_font_string(set_font_cidregistry);
1251
undump_font_string(set_font_cidordering);
1253
i = sizeof(*param_base(f)) * (font_params(f) + 1);
1255
param_base(f) = xmalloc(i);
1256
undump_things(*param_base(f), (font_params(f) + 1));
1258
font_tables[f]->_left_boundary = NULL;
1261
i = undump_charinfo(f);
1264
font_tables[f]->_right_boundary = NULL;
1267
i = undump_charinfo(f);
1270
/* right boundary */
1271
font_tables[f]->characters = new_sa_tree(1, 0); /* stack size 1, default item value 0 */
1272
ci = xcalloc(1, sizeof(charinfo));
1273
set_charinfo_name(ci, xstrdup(".notdef"));
1274
font_tables[f]->charinfo = ci;
1277
while (i < font_ec(f)) {
1278
i = undump_charinfo(f);