~ubuntu-branches/ubuntu/trusty/texlive-bin/trusty

« back to all changes in this revision

Viewing changes to texk/cjkutils/cjkutils-4.8.3/hbf2gf/hbf2gf.c

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2012-05-16 14:05:23 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20120516140523-airve5118gm9w68n
Tags: 2012.20120516-1
* new upstream snapshot based on TL2012 tlpretest
* remove outdated and not needed patches
* remove traces of debian internal mupdmap, we use the one that is now
  shipped by default in TeX Live
* patch shipped updmap for correct perl module search path
* move patches from debian/patches to debian/quilt, add quilt as 
  build dep, and include quilt patching in debian/rules
  this gets us rid of the "strange" parts of the 3.0 format
  (see quilt vs dpkg-source fuzzyness acceptance). 
  Thanks to an unnamed dev who gave me the hint!
* disable build-wovp2ovf patch, included upstream
* (re)install cnf.h into libkpathsea-dev (Closes: #673016)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define banner  \
 
2
"hbf2gf (CJK ver. 4.8.3)" \
 
3
 \
 
4
 
 
5
#define TRUE 1
 
6
#define FALSE 0 \
 
7
 
 
8
#define STRING_LENGTH 255 \
 
9
 
 
10
#define FILE_NAME_LENGTH 1024 \
 
11
 \
 
12
 
 
13
#define VERSION  \
 
14
"\n" \
 
15
"Copyright (C) 1996-1999 Werner Lemberg.\n" \
 
16
"There is NO warranty.  You may redistribute this software\n" \
 
17
"under the terms of the GNU General Public License\n" \
 
18
"and the HBF library copyright.\n" \
 
19
"\n" \
 
20
"For more information about these matters, see the files\n" \
 
21
"named COPYING and hbf.c.\n" \
 
22
"\n" \
 
23
 
 
24
#define USAGE  \
 
25
"\n" \
 
26
"Usage: hbf2gf [-q] configuration_file[.cfg]\n" \
 
27
"       hbf2gf [options] font_name x_resolution [y_scale | y_resolution]\n" \
 
28
"       hbf2gf -t [-q] font_name\n" \
 
29
"\n" \
 
30
"  Convert a font in HBF format to TeX's GF resp. PK format.\n" \
 
31
"\n" \
 
32
"         -q             be silent\n" \
 
33
"         -p             don't produce a PL file\n" \
 
34
"         -g             don't produce a GF file\n" \
 
35
"         -n             use no resolution in extension (only `.gf')\n" \
 
36
"         -t             test for font_name (returns 0 on success)\n" \
 
37
"         --help         print this message and exit\n" \
 
38
"         --version      print version number and exit\n" \
 
39
"\n" \
 
40
 
 
41
#define GF_ID 131
 
42
#define PRE 247 \
 
43
 
 
44
#define header " hbf2gf output " \
 
45
 
 
46
#define BOC 67
 
47
#define BOC1 68
 
48
#define EOC 69 \
 
49
 
 
50
#define _2_16 65536.0
 
51
#define _2_20 1048576.0 \
 
52
 
 
53
#define XXX1 239
 
54
#define XXX2 240
 
55
#define XXX3 241
 
56
#define XXX4 242 \
 
57
 
 
58
#define YYY 243 \
 
59
 
 
60
#define POST 248 \
 
61
 
 
62
#define CHAR_LOC 245
 
63
#define CHAR_LOC0 246 \
 
64
 
 
65
#define POSTPOST 249
 
66
#define POSTPOST_ID 223 \
 
67
 
 
68
#define BLACK 1
 
69
#define WHITE 0 \
 
70
 
 
71
#define PIXEL_MAXVAL 255
 
72
#define SCALE 4096
 
73
#define HALFSCALE 2048 \
 
74
 
 
75
#define MAX_CHAR_SIZE 1023 \
 
76
 
 
77
#define PAINT_(x) (x) 
 
78
#define PAINT1 64
 
79
#define PAINT2 65
 
80
#define PAINT3 66 \
 
81
 
 
82
#define SKIP0 70
 
83
#define SKIP1 71
 
84
#define SKIP2 72
 
85
#define SKIP3 73 \
 
86
 
 
87
#define NEW_ROW_(x) ((x) +74)  \
 
88
 
 
89
#define NOOP 244 \
 
90
 
 
91
#define EXTENSION_LENGTH 8 \
 
92
 
 
93
#define GFTOPK_NAME "gftopk"
 
94
#define PLTOTF_NAME "pltotf"
 
95
#define OVP2OVF_NAME "ovp2ovf" \
 
96
 
 
97
#define PRINTER_MIN_RES_X 50
 
98
#define PRINTER_MIN_RES_Y 50 \
 
99
 
 
100
#define VALID_SUBCODE 1 \
 
101
 
 
102
/*4:*/
 
103
#line 191 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
104
 
 
105
/*10:*/
 
106
#line 408 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
107
 
 
108
#ifdef HAVE_CONFIG_H
 
109
#include <c-auto.h> 
 
110
#endif
 
111
#include <ctype.h> 
 
112
#include <stdio.h> 
 
113
#include <stdlib.h> 
 
114
#include <string.h> 
 
115
#include <time.h> 
 
116
#ifdef TM_IN_SYS_TIME
 
117
#include <sys/time.h> 
 
118
#endif
 
119
#include "hbf.h"
 
120
 
 
121
 
 
122
 
 
123
/*:10*//*69:*/
 
124
#line 2469 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
125
 
 
126
#if defined(HAVE_LIBKPATHSEA)
 
127
#include "kpathsea/kpathsea.h"
 
128
 
 
129
#elif defined(HAVE_EMTEXDIR)
 
130
#include "emtexdir.h"
 
131
 
 
132
#elif defined(HAVE_MIKTEX)
 
133
#include "miktex.h"
 
134
#endif
 
135
 
 
136
/*:69*/
 
137
#line 192 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
138
 
 
139
/*11:*/
 
140
#line 429 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
141
 
 
142
void write_file(void);
 
143
 
 
144
 
 
145
/*:11*//*13:*/
 
146
#line 491 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
147
 
 
148
void write_pre(void);
 
149
 
 
150
 
 
151
/*:13*//*16:*/
 
152
#line 579 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
153
 
 
154
void write_data(void);
 
155
 
 
156
 
 
157
/*:16*//*20:*/
 
158
#line 690 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
159
 
 
160
void write_post(void);
 
161
 
 
162
 
 
163
/*:20*//*25:*/
 
164
#line 834 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
165
 
 
166
void fputl(long,FILE*);
 
167
 
 
168
 
 
169
/*:25*//*29:*/
 
170
#line 994 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
171
 
 
172
void make_pixel_array(void);
 
173
 
 
174
 
 
175
/*:29*//*36:*/
 
176
#line 1222 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
177
 
 
178
#ifdef __GNUC__
 
179
__inline__
 
180
#endif
 
181
void read_row(unsigned char*);
 
182
 
 
183
 
 
184
/*:36*//*39:*/
 
185
#line 1272 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
186
 
 
187
#ifdef __GNUC__
 
188
__inline__
 
189
#endif
 
190
void write_row(unsigned char*);
 
191
 
 
192
 
 
193
/*:39*//*41:*/
 
194
#line 1325 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
195
 
 
196
void write_coding(void);
 
197
 
 
198
 
 
199
/*:41*//*45:*/
 
200
#line 1486 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
201
 
 
202
void write_pl(void);
 
203
 
 
204
 
 
205
/*:45*//*47:*/
 
206
#line 1583 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
207
 
 
208
void write_ovp(void);
 
209
 
 
210
 
 
211
/*:47*//*50:*/
 
212
#line 1728 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
213
 
 
214
void write_job(void);
 
215
 
 
216
 
 
217
/*:50*//*54:*/
 
218
#line 1977 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
219
 
 
220
void read_config(void);
 
221
 
 
222
 
 
223
/*:54*//*64:*/
 
224
#line 2308 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
225
 
 
226
int fsearch(const char*);
 
227
 
 
228
 
 
229
/*:64*//*67:*/
 
230
#line 2447 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
231
 
 
232
void config_error(const char*);
 
233
 
 
234
 
 
235
/*:67*//*71:*/
 
236
#line 2490 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
237
 
 
238
const char*TeX_search_version(void);
 
239
 
 
240
 
 
241
/*:71*//*74:*/
 
242
#line 2525 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
243
 
 
244
#ifdef HAVE_EMTEXDIR
 
245
extern int setup_list(struct emtex_dir*,char*,const char*,unsigned);
 
246
int dir_setup(struct emtex_dir*,const char*,const char*,unsigned);
 
247
char*file_find(char*,struct emtex_dir*);
 
248
#endif
 
249
 
 
250
 
 
251
/*:74*//*79:*/
 
252
#line 2613 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
253
 
 
254
char*TeX_search_cfg_file(char*);
 
255
char*TeX_search_hbf_file(char*);
 
256
 
 
257
 
 
258
/*:79*/
 
259
#line 193 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
260
 
 
261
/*2:*/
 
262
#line 127 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
263
 
 
264
int nmb_files= -1;
 
265
int unicode= FALSE;
 
266
 
 
267
int testing= FALSE;
 
268
 
 
269
int mf_like= FALSE;
 
270
int file_number= 0;
 
271
 
 
272
double x_resolution= 0.0;
 
273
double y_scale= 1.0;
 
274
 
 
275
int pk_files= TRUE;
 
276
int tfm_files= TRUE;
 
277
int long_extension= TRUE;
 
278
int quiet= FALSE;
 
279
 
 
280
char config_file[FILE_NAME_LENGTH+4+1];
 
281
 
 
282
char output_name[STRING_LENGTH+1];
 
283
 
 
284
FILE*config,*out;
 
285
HBF*hbf;
 
286
 
 
287
#ifdef msdos 
 
288
#define WRITE_BIN   "wb"
 
289
#define WRITE_TXT   "wt"
 
290
#define READ_BIN    "rb"
 
291
#define READ_TXT    "rt"
 
292
#else
 
293
#define WRITE_BIN   "w"
 
294
#define WRITE_TXT   "w"
 
295
#define READ_BIN    "r"
 
296
#define READ_TXT    "r"
 
297
#endif
 
298
 
 
299
int end_of_file= FALSE;
 
300
 
 
301
 
 
302
/*:2*//*15:*/
 
303
#line 538 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
304
 
 
305
long char_adr[256];
 
306
long*char_adr_p;
 
307
 
 
308
int pk_offset_x;
 
309
 
 
310
 
 
311
double tfm_offset_x;
 
312
int pk_offset_y;
 
313
 
 
314
double tfm_offset_y;
 
315
 
 
316
int input_size_x;
 
317
int input_size_y;
 
318
const char*font_encoding;
 
319
int pk_width;
 
320
int pk_output_size_x;
 
321
 
 
322
double tfm_output_size_x;
 
323
int pk_output_size_y;
 
324
double tfm_output_size_y;
 
325
 
 
326
double design_size= 10.0;
 
327
double target_size_x;
 
328
double target_size_y;
 
329
double magstep_x;
 
330
double magstep_y;
 
331
double slant;
 
332
int rotation;
 
333
 
 
334
double mag_x;
 
335
double mag_y;
 
336
 
 
337
int empty_char;
 
338
int last_char;
 
339
 
 
340
int dot_count;
 
341
 
 
342
 
 
343
 
 
344
/*:15*//*19:*/
 
345
#line 667 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
346
 
 
347
char coding[STRING_LENGTH+1];
 
348
char comment[STRING_LENGTH+1];
 
349
 
 
350
unsigned long checksum;
 
351
 
 
352
long pk_total_min_x;
 
353
long pk_total_max_x;
 
354
long pk_total_min_y;
 
355
long pk_total_max_y;
 
356
 
 
357
int dpi_x;
 
358
int dpi_y;
 
359
double ppp_x;
 
360
double ppp_y;
 
361
 
 
362
 
 
363
/*:19*//*27:*/
 
364
#line 871 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
365
 
 
366
HBF_CHAR code;
 
367
const unsigned char*bitmap;
 
368
 
 
369
const unsigned char*bP;
 
370
 
 
371
unsigned char out_char[MAX_CHAR_SIZE*MAX_CHAR_SIZE+1];
 
372
 
 
373
unsigned char*out_char_p;
 
374
 
 
375
unsigned char pixelrow[MAX_CHAR_SIZE];
 
376
unsigned char temp_pixelrow[MAX_CHAR_SIZE];
 
377
unsigned char new_pixelrow[MAX_CHAR_SIZE+1];
 
378
 
 
379
int curr_row;
 
380
 
 
381
long grayrow[MAX_CHAR_SIZE];
 
382
 
 
383
long s_mag_x,s_mag_y,s_slant;
 
384
 
 
385
 
 
386
/*:27*//*38:*/
 
387
#line 1267 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
388
 
 
389
int threshold= 128;
 
390
 
 
391
 
 
392
/*:38*//*49:*/
 
393
#line 1717 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
394
 
 
395
char job_extension[EXTENSION_LENGTH+1];
 
396
char rm_command[STRING_LENGTH+1];
 
397
char cp_command[STRING_LENGTH+1];
 
398
char pk_directory[STRING_LENGTH+1];
 
399
char tfm_directory[STRING_LENGTH+1];
 
400
 
 
401
int ofm_file= FALSE;
 
402
 
 
403
 
 
404
/*:49*//*53:*/
 
405
#line 1972 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
406
 
 
407
char Buffer[STRING_LENGTH+1];
 
408
 
 
409
 
 
410
/*:53*//*58:*/
 
411
#line 2090 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
412
 
 
413
int offset_x;
 
414
int offset_y;
 
415
 
 
416
HBF_CHAR user_min_char;
 
417
int have_min_char= FALSE;
 
418
 
 
419
/*:58*//*60:*/
 
420
#line 2247 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
421
 
 
422
HBF_CHAR min_char,max_char;
 
423
 
 
424
 
 
425
/*:60*//*62:*/
 
426
#line 2274 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
427
 
 
428
char b2_codes[256];
 
429
unsigned char min_2_byte,max_2_byte;
 
430
int nmb_2_bytes= 0;
 
431
 
 
432
 
 
433
/*:62*//*70:*/
 
434
#line 2481 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
435
 
 
436
#if defined(HAVE_EMTEXDIR)
 
437
char emtex_version_string[]= "emTeXdir";
 
438
#elif !defined(HAVE_MIKTEX)
 
439
char no_version_string[]= "no search library";
 
440
#endif
 
441
 
 
442
 
 
443
/*:70*//*73:*/
 
444
#line 2518 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
445
 
 
446
#ifdef HAVE_EMTEXDIR
 
447
struct emtex_dir cfg_path,hbf_path;
 
448
#endif
 
449
 
 
450
 
 
451
/*:73*//*76:*/
 
452
#line 2564 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
453
 
 
454
char name_buffer[FILE_NAME_LENGTH+1];
 
455
 
 
456
 
 
457
/*:76*/
 
458
#line 194 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
459
 
 
460
 
 
461
 
 
462
int main(int argc,char*argv[])
 
463
{char*p;
 
464
 
 
465
/*78:*/
 
466
#line 2586 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
467
 
 
468
#if defined(HAVE_LIBKPATHSEA)
 
469
kpse_set_program_name(argv[0],"hbf2gf");
 
470
kpse_init_prog("HBF2GF",300,"cx","cmr10");
 
471
 
 
472
#elif defined(HAVE_EMTEXDIR)
 
473
if(!dir_setup(&cfg_path,"HBFCFG",NULL,EDS_BANG))
 
474
{fprintf(stderr,
 
475
"Couldn't setup search path for configuration files\n");
 
476
exit(1);
 
477
}
 
478
if(!dir_setup(&hbf_path,"HBFONTS",NULL,EDS_BANG))
 
479
{fprintf(stderr,
 
480
"Couldn't setup search path for HBF header files\n");
 
481
exit(1);
 
482
}
 
483
#endif
 
484
 
 
485
 
 
486
/*:78*/
 
487
#line 200 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
488
 
 
489
 
 
490
/*7:*/
 
491
#line 307 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
492
 
 
493
if(argc==2)
 
494
{if(strcmp(argv[1],"--help")==0)
 
495
/*6:*/
 
496
#line 288 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
497
 
 
498
{printf(USAGE);
 
499
exit(0);
 
500
}
 
501
 
 
502
 
 
503
/*:6*/
 
504
#line 310 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
505
 
 
506
else if(strcmp(argv[1],"--version")==0)
 
507
/*5:*/
 
508
#line 261 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
509
 
 
510
{printf("\n");
 
511
printf(banner);
 
512
printf(" (%s)\n",TeX_search_version());
 
513
printf(VERSION);
 
514
exit(0);
 
515
}
 
516
 
 
517
 
 
518
/*:5*/
 
519
#line 312 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
520
 
 
521
}
 
522
 
 
523
while(argc> 1)
 
524
{p= argv[1];
 
525
if(p[0]!='-')
 
526
break;
 
527
if(p[1]=='p')
 
528
tfm_files= FALSE;
 
529
else if(p[1]=='g')
 
530
pk_files= FALSE;
 
531
else if(p[1]=='n')
 
532
long_extension= FALSE;
 
533
else if(p[1]=='q')
 
534
quiet= TRUE;
 
535
else if(p[1]=='t')
 
536
testing= TRUE;
 
537
 
 
538
argv++;
 
539
argc--;
 
540
}
 
541
 
 
542
if(testing)
 
543
{if(argc!=2)
 
544
{fprintf(stderr,"Need exactly one parameter for `-t' option.\n");
 
545
fprintf(stderr,"Try `hbf2gf --help' for more information.\n");
 
546
exit(1);
 
547
}
 
548
}
 
549
else if(argc<2||argc> 4)
 
550
{fprintf(stderr,"Invalid number of parameters.\n");
 
551
fprintf(stderr,"Try `hbf2gf --help' for more information.\n");
 
552
exit(1);
 
553
}
 
554
 
 
555
 
 
556
/*:7*/
 
557
#line 202 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
558
 
 
559
 
 
560
if(!quiet)
 
561
printf("\n%s\n\n",banner);
 
562
 
 
563
strncpy(config_file,argv[1],FILE_NAME_LENGTH);
 
564
config_file[FILE_NAME_LENGTH]= '\0';
 
565
 
 
566
if(argc> 2||testing)
 
567
{int l= strlen(config_file);
 
568
 
 
569
if(l> 2)
 
570
config_file[l-2]= '\0';
 
571
 
 
572
else
 
573
{if(!quiet)
 
574
printf("`%s' can't be a subfont created by hbf2gf\n",
 
575
config_file);
 
576
exit(2);
 
577
}
 
578
 
 
579
mf_like= TRUE;
 
580
}
 
581
 
 
582
read_config();
 
583
 
 
584
if(mf_like)
 
585
/*8:*/
 
586
#line 352 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
587
 
 
588
{if(unicode)
 
589
file_number= (int)strtol(&argv[1][strlen(argv[1])-2],
 
590
(char**)NULL,16);
 
591
else
 
592
file_number= atoi(&argv[1][strlen(argv[1])-2]);
 
593
 
 
594
x_resolution= atof(argv[2]);
 
595
if(x_resolution<PRINTER_MIN_RES_X)
 
596
{fprintf(stderr,"Invalid horizontal resolution\n");
 
597
exit(1);
 
598
}
 
599
 
 
600
if(argc> 3)
 
601
{y_scale= atof(argv[3]);
 
602
if(y_scale<0.01)
 
603
{fprintf(stderr,
 
604
"Invalid vertical scaling factor or resolution\n");
 
605
exit(1);
 
606
}
 
607
if(y_scale> 10.0)
 
608
y_scale= (double)x_resolution/y_scale;
 
609
}
 
610
}
 
611
 
 
612
 
 
613
/*:8*/
 
614
#line 229 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
615
 
 
616
 
 
617
/*28:*/
 
618
#line 903 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
619
 
 
620
{int col,offset;
 
621
 
 
622
if(rotation)
 
623
{int tmp;
 
624
 
 
625
 
 
626
tmp= input_size_x;
 
627
input_size_x= input_size_y;
 
628
input_size_y= tmp;
 
629
}
 
630
 
 
631
if(mf_like)
 
632
{target_size_x= design_size*(x_resolution/dpi_x);
 
633
target_size_y= design_size*(x_resolution*y_scale/dpi_y);
 
634
}
 
635
else
 
636
target_size_x= target_size_y= design_size;
 
637
magstep_x= target_size_x/design_size;
 
638
magstep_y= target_size_y/design_size;
 
639
 
 
640
pk_offset_x= offset_x*magstep_x+0.5;
 
641
pk_offset_y= offset_y*magstep_y+0.5;
 
642
tfm_offset_x= offset_x/(dpi_x/72.27)/design_size;
 
643
tfm_offset_y= offset_y/(dpi_y/72.27)/design_size;
 
644
 
 
645
pk_width= input_size_x*mag_x*magstep_x+0.5;
 
646
pk_output_size_x= input_size_x*mag_x*magstep_x+
 
647
input_size_y*mag_y*magstep_y*slant+0.5;
 
648
pk_output_size_y= input_size_y*mag_y*magstep_y+0.5;
 
649
tfm_output_size_x= input_size_x*mag_x/
 
650
(dpi_x/72.27)/design_size;
 
651
tfm_output_size_y= input_size_y*mag_y/
 
652
(dpi_y/72.27)/design_size;
 
653
if(pk_output_size_x> MAX_CHAR_SIZE)
 
654
{fprintf(stderr,"Output character box width too big\n");
 
655
exit(1);
 
656
}
 
657
if(pk_output_size_y> MAX_CHAR_SIZE)
 
658
{fprintf(stderr,"Output character box height too big\n");
 
659
exit(1);
 
660
}
 
661
 
 
662
for(col= 0;col<input_size_x;++col)
 
663
grayrow[col]= HALFSCALE;
 
664
 
 
665
if(!mf_like)
 
666
code= (min_char&0xFF00)+min_2_byte;
 
667
else
 
668
{if((file_number<(unicode?0:1))||(file_number>=0x100))
 
669
{fprintf(stderr,"Invalid subfile number\n");
 
670
exit(1);
 
671
}
 
672
 
 
673
if(unicode)
 
674
{offset= 0;
 
675
code= file_number*0x100;
 
676
}
 
677
else
 
678
{offset= (file_number-1)*256%nmb_2_bytes;
 
679
code= (min_char&0xFF00)+min_2_byte+
 
680
(file_number-1)*256/nmb_2_bytes*0x100;
 
681
}
 
682
 
 
683
while(offset--)
 
684
while(!b2_codes[code++&0xFF])
 
685
 
 
686
;
 
687
 
 
688
if(code> max_char)
 
689
{fprintf(stderr,"Invalid subfile number\n");
 
690
exit(1);
 
691
}
 
692
}
 
693
 
 
694
s_mag_x= mag_x*magstep_x*SCALE;
 
695
s_mag_y= mag_y*magstep_y*SCALE;
 
696
s_slant= slant*SCALE;
 
697
}
 
698
 
 
699
 
 
700
/*:28*/
 
701
#line 231 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
702
 
 
703
 
 
704
/*9:*/
 
705
#line 387 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
706
 
 
707
{int j,max_numb;
 
708
 
 
709
if(!mf_like)
 
710
{file_number= (unicode==TRUE?(min_char>>8):1);
 
711
if(nmb_files==-1)
 
712
max_numb= (unicode==TRUE?0x100:100);
 
713
else
 
714
max_numb= nmb_files;
 
715
}
 
716
else
 
717
max_numb= 1;
 
718
 
 
719
for(j= 0;(j<max_numb)&&!end_of_file;file_number++,j++)
 
720
write_file();
 
721
 
 
722
nmb_files= j;
 
723
}
 
724
 
 
725
 
 
726
/*:9*/
 
727
#line 233 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
728
 
 
729
 
 
730
if(tfm_files)
 
731
write_pl();
 
732
if(ofm_file)
 
733
write_ovp();
 
734
if(!mf_like)
 
735
write_job();
 
736
 
 
737
hbfClose(hbf);
 
738
 
 
739
exit(0);
 
740
return 0;
 
741
}
 
742
 
 
743
 
 
744
/*:4*//*12:*/
 
745
#line 437 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
746
 
 
747
void write_file(void)
 
748
{char output_file[FILE_NAME_LENGTH+1];
 
749
 
 
750
 
 
751
if(pk_files)
 
752
{if(mf_like)
 
753
{if(unicode)
 
754
sprintf(output_file,"%s%02x.%.0igf",
 
755
output_name,file_number,
 
756
long_extension?(int)(x_resolution+0.5):0);
 
757
else
 
758
sprintf(output_file,"%s%02i.%.0igf",
 
759
output_name,file_number,
 
760
long_extension?(int)(x_resolution+0.5):0);
 
761
}
 
762
else
 
763
{if(unicode)
 
764
sprintf(output_file,"%s%02x.gf",output_name,file_number);
 
765
else
 
766
sprintf(output_file,"%s%02i.gf",output_name,file_number);
 
767
}
 
768
if(!(out= fopen(output_file,WRITE_BIN)))
 
769
{fprintf(stderr,"Couldn't open `%s'\n",output_file);
 
770
exit(1);
 
771
}
 
772
if(!quiet)
 
773
printf("Writing `%s' ",output_file);
 
774
 
 
775
write_pre();
 
776
write_data();
 
777
write_post();
 
778
fclose(out);
 
779
 
 
780
if(!quiet)
 
781
printf("\n");
 
782
}
 
783
else
 
784
write_data();
 
785
}
 
786
 
 
787
 
 
788
/*:12*//*14:*/
 
789
#line 498 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
790
 
 
791
void write_pre(void)
 
792
{char out_s[40],s[20];
 
793
time_t secs_now;
 
794
struct tm*time_now;
 
795
 
 
796
 
 
797
strcpy(out_s,header);
 
798
 
 
799
secs_now= time(NULL);
 
800
time_now= localtime(&secs_now);
 
801
strftime(s,20,"%Y.%m.%d:%H.%M",time_now);
 
802
strcat(out_s,s);
 
803
 
 
804
fputc(PRE,out);
 
805
fputc(GF_ID,out);
 
806
fputc(strlen(out_s),out);
 
807
fputs(out_s,out);
 
808
}
 
809
 
 
810
 
 
811
/*:14*//*17:*/
 
812
#line 584 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
813
 
 
814
void write_data(void)
 
815
{dot_count= 0;
 
816
char_adr_p= char_adr;
 
817
 
 
818
for(last_char= 0;(last_char<256)&&!end_of_file;last_char++)
 
819
/*18:*/
 
820
#line 609 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
821
 
 
822
{if(dot_count++%10==0)
 
823
if(pk_files&&!quiet)
 
824
{printf(".");
 
825
fflush(stdout);
 
826
}
 
827
 
 
828
empty_char= FALSE;
 
829
make_pixel_array();
 
830
if(end_of_file)
 
831
return;
 
832
 
 
833
if(pk_files)
 
834
{*char_adr_p= ftell(out);
 
835
char_adr_p++;
 
836
 
 
837
if(empty_char)
 
838
{fputc(BOC1,out);
 
839
fputc((unsigned char)last_char,out);
 
840
fputc(0,out);
 
841
fputc(0,out);
 
842
fputc(0,out);
 
843
fputc(0,out);
 
844
fputc(EOC,out);
 
845
}
 
846
else
 
847
{fputc(BOC,out);
 
848
fputl(last_char,out);
 
849
fputl(-1L,out);
 
850
fputl(pk_offset_x,out);
 
851
fputl(pk_output_size_x+pk_offset_x,out);
 
852
fputl(pk_offset_y,out);
 
853
fputl(pk_output_size_y+pk_offset_y,out);
 
854
 
 
855
write_coding();
 
856
 
 
857
fputc(EOC,out);
 
858
}
 
859
}
 
860
}
 
861
 
 
862
 
 
863
/*:18*/
 
864
#line 590 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
865
 
 
866
}
 
867
 
 
868
 
 
869
/*:17*//*21:*/
 
870
#line 695 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
871
 
 
872
void write_post(void)
 
873
{long special_adr;
 
874
long post_adr;
 
875
 
 
876
long designsize= design_size*_2_20;
 
877
 
 
878
int pk_dx;
 
879
long tfm_width;
 
880
 
 
881
int i;
 
882
long temp;
 
883
 
 
884
 
 
885
ppp_x= dpi_x/72.27*magstep_x;
 
886
ppp_y= dpi_y/72.27*magstep_y;
 
887
 
 
888
pk_total_min_x= pk_offset_x;
 
889
pk_total_max_x= pk_output_size_x+2*pk_offset_x;
 
890
pk_total_min_y= pk_offset_y;
 
891
pk_total_max_y= pk_output_size_y+pk_offset_y;
 
892
 
 
893
pk_dx= pk_width+2*pk_offset_x;
 
894
tfm_width= (tfm_output_size_x+2*tfm_offset_x)*_2_20;
 
895
 
 
896
 
 
897
/*22:*/
 
898
#line 741 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
899
 
 
900
special_adr= ftell(out);
 
901
 
 
902
if(*coding)
 
903
{fputc(XXX1,out);
 
904
fputc(strlen(coding),out);
 
905
fputs(coding,out);
 
906
}
 
907
 
 
908
if(*comment)
 
909
{fputc(XXX1,out);
 
910
fputc(strlen(comment),out);
 
911
fputs(comment,out);
 
912
}
 
913
 
 
914
 
 
915
/*:22*/
 
916
#line 721 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
917
 
 
918
/*23:*/
 
919
#line 770 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
920
 
 
921
post_adr= ftell(out);
 
922
fputc(POST,out);
 
923
fputl(special_adr,out);
 
924
 
 
925
fputl(designsize,out);
 
926
fputl(checksum,out);
 
927
fputl(ppp_x*_2_16,out);
 
928
fputl(ppp_y*_2_16,out);
 
929
fputl(pk_total_min_x,out);
 
930
fputl(pk_total_max_x,out);
 
931
fputl(pk_total_min_y,out);
 
932
fputl(pk_total_max_y,out);
 
933
 
 
934
char_adr_p= char_adr;
 
935
 
 
936
if(pk_dx<256)
 
937
{for(i= 0;i<last_char;i++)
 
938
{fputc(CHAR_LOC0,out);
 
939
fputc(i,out);
 
940
fputc(pk_dx,out);
 
941
fputl(tfm_width,out);
 
942
fputl(*char_adr_p++,out);
 
943
}
 
944
}
 
945
else
 
946
{for(i= 0;i<last_char;i++)
 
947
{fputc(CHAR_LOC,out);
 
948
fputc(i,out);
 
949
fputl(pk_dx*_2_16,out);
 
950
fputl(0,out);
 
951
fputl(tfm_width,out);
 
952
fputl(*char_adr_p++,out);
 
953
}
 
954
}
 
955
 
 
956
 
 
957
/*:23*/
 
958
#line 722 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
959
 
 
960
/*24:*/
 
961
#line 821 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
962
 
 
963
fputc(POSTPOST,out);
 
964
fputl(post_adr,out);
 
965
fputc(GF_ID,out);
 
966
temp= ftell(out);
 
967
i= (int)(temp%4)+4;
 
968
while(i--)
 
969
fputc(POSTPOST_ID,out);
 
970
 
 
971
 
 
972
/*:24*/
 
973
#line 723 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
974
 
 
975
}
 
976
 
 
977
 
 
978
/*:21*//*26:*/
 
979
#line 839 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
980
 
 
981
void fputl(long num,FILE*f)
 
982
{fputc(num>>24,f);
 
983
fputc(num>>16,f);
 
984
fputc(num>>8,f);
 
985
fputc(num,f);
 
986
}
 
987
 
 
988
 
 
989
/*:26*//*30:*/
 
990
#line 999 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
991
 
 
992
void make_pixel_array(void)
 
993
{unsigned char*prP;
 
994
unsigned char*temp_prP;
 
995
unsigned char*new_prP;
 
996
long*grP;
 
997
 
 
998
register unsigned char*xP;
 
999
register unsigned char*nxP;
 
1000
 
 
1001
register int row,col;
 
1002
int rows_read= 0;
 
1003
register int need_to_read_row= 1;
 
1004
 
 
1005
long frac_row_to_fill= SCALE;
 
1006
long frac_row_left= s_mag_y;
 
1007
 
 
1008
int no_code= FALSE;
 
1009
 
 
1010
 
 
1011
prP= pixelrow;
 
1012
temp_prP= temp_pixelrow;
 
1013
new_prP= new_pixelrow;
 
1014
grP= grayrow;
 
1015
out_char_p= out_char;
 
1016
 
 
1017
again:
 
1018
if(b2_codes[code&0xFF])
 
1019
{if(pk_files)
 
1020
{bitmap= hbfGetBitmap(hbf,code);
 
1021
bP= bitmap;
 
1022
 
 
1023
 
 
1024
if(!bitmap)
 
1025
empty_char= TRUE;
 
1026
else
 
1027
/*31:*/
 
1028
#line 1058 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1029
 
 
1030
{if(pk_output_size_y==input_size_y)
 
1031
temp_prP= prP;
 
1032
 
 
1033
curr_row= input_size_y-1;
 
1034
for(row= 0;row<pk_output_size_y;++row)
 
1035
{/*32:*/
 
1036
#line 1072 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1037
 
 
1038
if(pk_output_size_y==input_size_y)
 
1039
 
 
1040
read_row(prP);
 
1041
else
 
1042
{while(frac_row_left<frac_row_to_fill)
 
1043
{if(need_to_read_row)
 
1044
if(rows_read<input_size_y)
 
1045
{read_row(prP);
 
1046
++rows_read;
 
1047
}
 
1048
 
 
1049
for(col= 0,xP= prP;col<input_size_x;++col,++xP)
 
1050
grP[col]+= frac_row_left*(*xP);
 
1051
 
 
1052
frac_row_to_fill-= frac_row_left;
 
1053
frac_row_left= s_mag_y;
 
1054
need_to_read_row= 1;
 
1055
}
 
1056
 
 
1057
/*33:*/
 
1058
#line 1099 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1059
 
 
1060
if(need_to_read_row)
 
1061
if(rows_read<input_size_y)
 
1062
{read_row(prP);
 
1063
++rows_read;
 
1064
need_to_read_row= 0;
 
1065
}
 
1066
 
 
1067
for(col= 0,xP= prP,nxP= temp_prP;
 
1068
col<input_size_x;++col,++xP,++nxP)
 
1069
{register long g;
 
1070
 
 
1071
 
 
1072
g= grP[col]+frac_row_to_fill*(*xP);
 
1073
g/= SCALE;
 
1074
if(g> PIXEL_MAXVAL)
 
1075
g= PIXEL_MAXVAL;
 
1076
 
 
1077
*nxP= g;
 
1078
grP[col]= HALFSCALE;
 
1079
}
 
1080
 
 
1081
frac_row_left-= frac_row_to_fill;
 
1082
if(frac_row_left==0)
 
1083
{frac_row_left= s_mag_y;
 
1084
need_to_read_row= 1;
 
1085
}
 
1086
frac_row_to_fill= SCALE;
 
1087
 
 
1088
 
 
1089
/*:33*/
 
1090
#line 1092 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1091
 
 
1092
}
 
1093
 
 
1094
 
 
1095
/*:32*/
 
1096
#line 1064 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1097
 
 
1098
/*34:*/
 
1099
#line 1140 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1100
 
 
1101
if(pk_width==input_size_x&&s_slant==0)
 
1102
 
 
1103
write_row(temp_prP);
 
1104
else
 
1105
{register long g= HALFSCALE;
 
1106
register long frac_col_to_fill= SCALE;
 
1107
register long frac_col_left;
 
1108
register int need_col= 0;
 
1109
 
 
1110
 
 
1111
nxP= new_prP;
 
1112
 
 
1113
frac_col_left= (pk_output_size_y-row)*s_slant;
 
1114
while(frac_col_left>=frac_col_to_fill)
 
1115
{*(nxP++)= 0;
 
1116
frac_col_left-= frac_col_to_fill;
 
1117
}
 
1118
 
 
1119
if(frac_col_left> 0)
 
1120
frac_col_to_fill-= frac_col_left;
 
1121
 
 
1122
for(col= 0,xP= temp_prP;col<input_size_x;++col,++xP)
 
1123
{frac_col_left= s_mag_x;
 
1124
while(frac_col_left>=frac_col_to_fill)
 
1125
{if(need_col)
 
1126
{++nxP;
 
1127
g= HALFSCALE;
 
1128
}
 
1129
 
 
1130
g+= frac_col_to_fill*(*xP);
 
1131
g/= SCALE;
 
1132
if(g> PIXEL_MAXVAL)
 
1133
g= PIXEL_MAXVAL;
 
1134
 
 
1135
*nxP= g;
 
1136
frac_col_left-= frac_col_to_fill;
 
1137
frac_col_to_fill= SCALE;
 
1138
need_col= 1;
 
1139
}
 
1140
 
 
1141
if(frac_col_left> 0)
 
1142
{if(need_col)
 
1143
{++nxP;
 
1144
g= HALFSCALE;
 
1145
need_col= 0;
 
1146
}
 
1147
 
 
1148
g+= frac_col_left*(*xP);
 
1149
frac_col_to_fill-= frac_col_left;
 
1150
}
 
1151
}
 
1152
 
 
1153
/*35:*/
 
1154
#line 1198 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1155
 
 
1156
if(frac_col_to_fill> 0)
 
1157
{--xP;
 
1158
g+= frac_col_to_fill*(*xP);
 
1159
}
 
1160
 
 
1161
if(!need_col)
 
1162
{g/= SCALE;
 
1163
if(g> PIXEL_MAXVAL)
 
1164
g= PIXEL_MAXVAL;
 
1165
*nxP= g;
 
1166
}
 
1167
 
 
1168
*(++nxP)= 0;
 
1169
 
 
1170
write_row(new_prP);
 
1171
 
 
1172
 
 
1173
/*:35*/
 
1174
#line 1193 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1175
 
 
1176
}
 
1177
 
 
1178
 
 
1179
/*:34*/
 
1180
#line 1066 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1181
 
 
1182
}
 
1183
}
 
1184
 
 
1185
 
 
1186
/*:31*/
 
1187
#line 1035 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1188
 
 
1189
}
 
1190
}
 
1191
else
 
1192
no_code= TRUE;
 
1193
 
 
1194
if((code&0xFF)==max_2_byte)
 
1195
code+= 0xFF-(max_2_byte-min_2_byte);
 
1196
if(code>=max_char)
 
1197
{end_of_file= TRUE;
 
1198
return;
 
1199
}
 
1200
 
 
1201
code++;
 
1202
 
 
1203
if(no_code)
 
1204
{no_code= FALSE;
 
1205
goto again;
 
1206
}
 
1207
}
 
1208
 
 
1209
 
 
1210
/*:30*//*37:*/
 
1211
#line 1230 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1212
 
 
1213
#ifdef __GNUC__
 
1214
__inline__
 
1215
#endif
 
1216
void read_row(unsigned char*pixelrow)
 
1217
{register int col,bitshift,offset;
 
1218
register unsigned char*xP;
 
1219
register unsigned char item= 0;
 
1220
 
 
1221
if(rotation)
 
1222
{bitshift= 7-(curr_row%8);
 
1223
offset= (input_size_y+7)/8;
 
1224
bP= bitmap+curr_row/8;
 
1225
for(col= 0,xP= pixelrow;col<input_size_x;++col,++xP)
 
1226
{*xP= ((*bP>>bitshift)&1)==1?PIXEL_MAXVAL:0;
 
1227
bP+= offset;
 
1228
}
 
1229
curr_row--;
 
1230
}
 
1231
else
 
1232
{bitshift= -1;
 
1233
for(col= 0,xP= pixelrow;col<input_size_x;++col,++xP)
 
1234
{if(bitshift==-1)
 
1235
{item= *(bP++);
 
1236
bitshift= 7;
 
1237
}
 
1238
*xP= ((item>>bitshift)&1)==1?PIXEL_MAXVAL:0;
 
1239
--bitshift;
 
1240
}
 
1241
}
 
1242
}
 
1243
 
 
1244
 
 
1245
/*:37*//*40:*/
 
1246
#line 1280 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1247
 
 
1248
#ifdef __GNUC__
 
1249
__inline__
 
1250
#endif
 
1251
void write_row(unsigned char*pixelrow)
 
1252
{register int col;
 
1253
register unsigned char*xP;
 
1254
 
 
1255
for(col= 0,xP= pixelrow;col<pk_output_size_x;++col,++xP)
 
1256
*(out_char_p++)= (*xP>=threshold)?1:0;
 
1257
 
 
1258
}
 
1259
 
 
1260
 
 
1261
/*:40*//*42:*/
 
1262
#line 1333 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1263
 
 
1264
void write_coding(void)
 
1265
{register int count,skip;
 
1266
register unsigned char paint;
 
1267
register int x,y;
 
1268
register unsigned char*cp;
 
1269
 
 
1270
x= 0;
 
1271
y= 0;
 
1272
cp= out_char+y*pk_output_size_x+x;
 
1273
count= skip= 0;
 
1274
paint= WHITE;
 
1275
goto start;
 
1276
 
 
1277
while(y<pk_output_size_y)
 
1278
{/*43:*/
 
1279
#line 1357 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1280
 
 
1281
count= 0;
 
1282
x= 0;
 
1283
cp= out_char+y*pk_output_size_x+x;
 
1284
 
 
1285
while(x<pk_output_size_x)
 
1286
{if(*cp==paint)
 
1287
count++;
 
1288
else
 
1289
{if(skip==0)
 
1290
{if(count<=164)
 
1291
fputc(NEW_ROW_(count),out);
 
1292
else
 
1293
{fputc(SKIP0,out);
 
1294
 
 
1295
if(count<256)
 
1296
{fputc(PAINT1,out);
 
1297
fputc(count,out);
 
1298
}
 
1299
else
 
1300
{fputc(PAINT2,out);
 
1301
fputc(count>>8,out);
 
1302
fputc(count&0xFF,out);
 
1303
}
 
1304
}
 
1305
}
 
1306
else
 
1307
{if(skip==1)
 
1308
fputc(SKIP0,out);
 
1309
else
 
1310
{if(skip<256)
 
1311
{fputc(SKIP1,out);
 
1312
fputc(skip,out);
 
1313
}
 
1314
else
 
1315
{fputc(SKIP2,out);
 
1316
fputc(skip>>8,out);
 
1317
fputc(skip&0xFF,out);
 
1318
}
 
1319
}
 
1320
skip= 0;
 
1321
if(count<64)
 
1322
fputc(PAINT_(count),out);
 
1323
else if(count<256)
 
1324
{fputc(PAINT1,out);
 
1325
fputc(count,out);
 
1326
}
 
1327
else
 
1328
{fputc(PAINT2,out);
 
1329
fputc(count>>8,out);
 
1330
fputc(count&0xFF,out);
 
1331
}
 
1332
}
 
1333
count= 0;
 
1334
paint= BLACK;
 
1335
break;
 
1336
}
 
1337
x++;
 
1338
cp++;
 
1339
}
 
1340
if(x>=pk_output_size_x)
 
1341
{skip++;
 
1342
y++;
 
1343
continue;
 
1344
}
 
1345
 
 
1346
 
 
1347
/*:43*/
 
1348
#line 1348 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1349
 
 
1350
start:
 
1351
/*44:*/
 
1352
#line 1425 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1353
 
 
1354
while(x<pk_output_size_x)
 
1355
{if(*cp==paint)
 
1356
count++;
 
1357
else
 
1358
{if(count<64)
 
1359
fputc(PAINT_(count),out);
 
1360
else if(count<256)
 
1361
{fputc(PAINT1,out);
 
1362
fputc(count,out);
 
1363
}
 
1364
else
 
1365
{fputc(PAINT2,out);
 
1366
fputc(count>>8,out);
 
1367
fputc(count&0xFF,out);
 
1368
}
 
1369
count= 1;
 
1370
paint= BLACK-paint;
 
1371
}
 
1372
x++;
 
1373
cp++;
 
1374
}
 
1375
if(paint==BLACK)
 
1376
{if(count<64)
 
1377
fputc(PAINT_(count),out);
 
1378
else if(count<256)
 
1379
{fputc(PAINT1,out);
 
1380
fputc(count,out);
 
1381
}
 
1382
else
 
1383
{fputc(PAINT2,out);
 
1384
fputc(count>>8,out);
 
1385
fputc(count&0xFF,out);
 
1386
}
 
1387
paint= WHITE;
 
1388
}
 
1389
 
 
1390
 
 
1391
 
 
1392
/*:44*/
 
1393
#line 1350 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1394
 
 
1395
y++;
 
1396
}
 
1397
}
 
1398
 
 
1399
 
 
1400
/*:42*//*46:*/
 
1401
#line 1491 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1402
 
 
1403
void write_pl(void)
 
1404
{int i,pos;
 
1405
char output_file[FILE_NAME_LENGTH+1];
 
1406
long t,sc;
 
1407
char*s;
 
1408
char tfm_header[]= "Created by hbf2gf";
 
1409
 
 
1410
file_number--;
 
1411
 
 
1412
if(mf_like)
 
1413
{if(unicode)
 
1414
sprintf(output_file,"%s%02x.pl",output_name,file_number);
 
1415
else
 
1416
sprintf(output_file,"%s%02i.pl",output_name,file_number);
 
1417
}
 
1418
else
 
1419
sprintf(output_file,"%s.pl",output_name);
 
1420
 
 
1421
if(!(out= fopen(output_file,WRITE_TXT)))
 
1422
{fprintf(stderr,"Couldn't open `%s'\n",output_file);
 
1423
exit(1);
 
1424
}
 
1425
if(!quiet)
 
1426
printf("\nWriting `%s'\n",output_file);
 
1427
 
 
1428
fprintf(out,
 
1429
"\n(FAMILY %s%d)"
 
1430
"\n(CODINGSCHEME CJK-%s)",
 
1431
output_name,file_number,font_encoding);
 
1432
 
 
1433
fprintf(out,
 
1434
"\n(DESIGNSIZE R %.6f)"
 
1435
"\n(COMMENT DESIGNSIZE IS IN POINTS)"
 
1436
"\n(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)"
 
1437
"\n(CHECKSUM O %lo)"
 
1438
"\n(FONTDIMEN"
 
1439
"\n   (SLANT R %.6f)"
 
1440
"\n   (SPACE R 0.0)"
 
1441
"\n   (STRETCH R 0.0)"
 
1442
"\n   (SHRINK R 0.0)"
 
1443
"\n   (XHEIGHT R 1.0)"
 
1444
"\n   (QUAD R 1.0)"
 
1445
"\n   (EXTRASPACE R 0.0)"
 
1446
"\n   )",design_size,checksum,slant);
 
1447
 
 
1448
s= tfm_header;
 
1449
i= strlen(s);
 
1450
t= ((long)i)<<24;
 
1451
sc= 16;
 
1452
pos= 18;
 
1453
 
 
1454
fprintf(out,"\n");
 
1455
while(i> 0)
 
1456
{t|= ((long)(*(unsigned char*)s++))<<sc;
 
1457
sc-= 8;
 
1458
if(sc<0)
 
1459
{fprintf(out,"\n(HEADER D %d O %lo)",pos,t);
 
1460
t= 0;
 
1461
sc= 24;
 
1462
pos++;
 
1463
}
 
1464
i--;
 
1465
}
 
1466
if(t)
 
1467
fprintf(out,"\n(HEADER D %d O %lo)",pos,t);
 
1468
fprintf(out,"\n");
 
1469
 
 
1470
for(i= 0;i<256;i++)
 
1471
{fprintf(out,
 
1472
"\n(CHARACTER O %o"
 
1473
"\n   (CHARWD R %.6f)"
 
1474
"\n   (CHARHT R %.6f)"
 
1475
"\n   (CHARDP R %.6f)"
 
1476
"\n   (CHARIC R %.6f)"
 
1477
"\n   )",
 
1478
i,
 
1479
tfm_output_size_x+2*tfm_offset_x,
 
1480
tfm_output_size_y+tfm_offset_y,
 
1481
-tfm_offset_y,
 
1482
slant*(tfm_output_size_y+tfm_offset_y));
 
1483
}
 
1484
 
 
1485
fclose(out);
 
1486
}
 
1487
 
 
1488
 
 
1489
 
 
1490
/*:46*//*48:*/
 
1491
#line 1588 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1492
 
 
1493
void write_ovp(void)
 
1494
{int c,i,nmb_subfonts,remainder,count,pos;
 
1495
char output_file[FILE_NAME_LENGTH+1];
 
1496
long t,sc;
 
1497
char*s;
 
1498
char ofm_header[]= "Created by hbf2gf";
 
1499
 
 
1500
nmb_subfonts= ((max_char-(min_char&0xFF00))/256*nmb_2_bytes)
 
1501
/256+1;
 
1502
remainder= ((max_char-(min_char&0xFF00))/256*nmb_2_bytes)
 
1503
%256;
 
1504
 
 
1505
 
 
1506
for(count= 0;count<(max_char&0xFF);count++)
 
1507
if(b2_codes[count])
 
1508
remainder++;
 
1509
if(remainder>=256)
 
1510
nmb_subfonts++;
 
1511
 
 
1512
sprintf(output_file,"%s.ovp",output_name);
 
1513
 
 
1514
if(!(out= fopen(output_file,WRITE_TXT)))
 
1515
{fprintf(stderr,"Couldn't open `%s'\n",output_file);
 
1516
exit(1);
 
1517
}
 
1518
if(!quiet)
 
1519
printf("\nWriting `%s'\n",output_file);
 
1520
 
 
1521
fprintf(out,
 
1522
"\n(VTITLE Omega virtual font created by hbf2gf)"
 
1523
"\n(DESIGNSIZE R %.6f)"
 
1524
"\n(COMMENT DESIGNSIZE IS IN POINTS)"
 
1525
"\n(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)"
 
1526
"\n(CHECKSUM O %lo)"
 
1527
"\n(FONTDIMEN"
 
1528
"\n   (SLANT R %.6f)"
 
1529
"\n   (SPACE R 0.0)"
 
1530
"\n   (STRETCH R 0.0)"
 
1531
"\n   (SHRINK R 0.0)"
 
1532
"\n   (XHEIGHT R 1.0)"
 
1533
"\n   (QUAD R 1.0)"
 
1534
"\n   (EXTRASPACE R 0.0)"
 
1535
"\n   )",design_size,checksum,slant);
 
1536
 
 
1537
s= ofm_header;
 
1538
i= strlen(s);
 
1539
t= ((long)i)<<24;
 
1540
sc= 16;
 
1541
pos= 18;
 
1542
 
 
1543
fprintf(out,"\n");
 
1544
while(i> 0)
 
1545
{t|= ((long)(*(unsigned char*)s++))<<sc;
 
1546
sc-= 8;
 
1547
if(sc<0)
 
1548
{fprintf(out,"\n(HEADER D %d O %lo)",pos,t);
 
1549
t= 0;
 
1550
sc= 24;
 
1551
pos++;
 
1552
}
 
1553
i--;
 
1554
}
 
1555
if(t)
 
1556
fprintf(out,"\n(HEADER D %d O %lo)",pos,t);
 
1557
fprintf(out,"\n");
 
1558
 
 
1559
for(i= 0;i<nmb_subfonts;i++)
 
1560
{fprintf(out,
 
1561
"\n(MAPFONT D %i"
 
1562
"\n   (FONTNAME %s%02i)"
 
1563
"\n   (FONTCHECKSUM O %lo)"
 
1564
"\n   (FONTAT R 1.0)"
 
1565
"\n   (FONTDSIZE R %.6f)"
 
1566
"\n   )",i,output_name,i+1,checksum,design_size);
 
1567
}
 
1568
 
 
1569
for(c= min_char,i= 0,count= 0;c<=max_char;c++)
 
1570
{if(b2_codes[c&0xFF]==VALID_SUBCODE)
 
1571
{fprintf(out,
 
1572
"\n(CHARACTER O %o"
 
1573
"\n   (CHARWD R %.6f)"
 
1574
"\n   (CHARHT R %.6f)"
 
1575
"\n   (CHARDP R %.6f)"
 
1576
"\n   (CHARIC R %.6f)"
 
1577
"\n   (MAP"
 
1578
"\n      (SELECTFONT D %i)"
 
1579
"\n      (SETCHAR O %o)"
 
1580
"\n      )"
 
1581
"\n   )",
 
1582
c,
 
1583
tfm_output_size_x+2*tfm_offset_x,
 
1584
tfm_output_size_y+tfm_offset_y,
 
1585
-tfm_offset_y,
 
1586
slant*(tfm_output_size_y+tfm_offset_y),
 
1587
i,
 
1588
count);
 
1589
 
 
1590
count++;
 
1591
if(count==256)
 
1592
{count= 0;
 
1593
i++;
 
1594
}
 
1595
}
 
1596
else
 
1597
continue;
 
1598
}
 
1599
 
 
1600
fclose(out);
 
1601
}
 
1602
 
 
1603
 
 
1604
 
 
1605
/*:48*//*51:*/
 
1606
#line 1733 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1607
 
 
1608
void write_job(void)
 
1609
{FILE*out;
 
1610
int i,j;
 
1611
char buffer[FILE_NAME_LENGTH+1];
 
1612
 
 
1613
 
 
1614
strcpy(buffer,output_name);
 
1615
strcat(buffer,job_extension);
 
1616
if(!(out= fopen(buffer,WRITE_TXT)))
 
1617
{fprintf(stderr,"Couldn't open `%s'\n",buffer);
 
1618
exit(1);
 
1619
}
 
1620
if(!quiet)
 
1621
printf("\nWriting `%s'\n",buffer);
 
1622
 
 
1623
if(pk_files)
 
1624
{if(unicode)
 
1625
{for(i= (min_char>>8),j= 0;j<nmb_files;i++,j++)
 
1626
fprintf(out,
 
1627
"%s %s%02x.gf %s%s%02x.%.0ipk\n"
 
1628
"%s %s%02x.gf\n",
 
1629
GFTOPK_NAME,output_name,i,
 
1630
pk_directory,output_name,i,
 
1631
long_extension?(int)(dpi_x*magstep_x+0.5):0,
 
1632
rm_command,output_name,i);
 
1633
}
 
1634
else
 
1635
{for(i= 1;i<=nmb_files;i++)
 
1636
fprintf(out,
 
1637
"%s %s%02i.gf %s%s%02i.%.0ipk\n"
 
1638
"%s %s%02i.gf\n",
 
1639
GFTOPK_NAME,output_name,i,
 
1640
pk_directory,output_name,i,
 
1641
long_extension?(int)(dpi_x*magstep_x+0.5):0,
 
1642
rm_command,output_name,i);
 
1643
}
 
1644
}
 
1645
 
 
1646
if(tfm_files)
 
1647
{fprintf(out,
 
1648
"\n"
 
1649
"%s %s.pl %s.tfm\n"
 
1650
"%s %s.pl\n"
 
1651
"\n",
 
1652
PLTOTF_NAME,output_name,output_name,
 
1653
rm_command,output_name);
 
1654
 
 
1655
if(unicode)
 
1656
{for(i= (min_char>>8),j= 0;j<nmb_files;i++,j++)
 
1657
fprintf(out,
 
1658
"%s %s.tfm %s%s%02x.tfm\n",
 
1659
cp_command,output_name,
 
1660
tfm_directory,output_name,i);
 
1661
}
 
1662
else
 
1663
{for(i= 1;i<=nmb_files;i++)
 
1664
fprintf(out,
 
1665
"%s %s.tfm %s%s%02i.tfm\n",
 
1666
cp_command,output_name,
 
1667
tfm_directory,output_name,i);
 
1668
}
 
1669
 
 
1670
fprintf(out,
 
1671
"\n"
 
1672
"%s %s.tfm",
 
1673
rm_command,output_name);
 
1674
}
 
1675
 
 
1676
if(ofm_file)
 
1677
{fprintf(out,
 
1678
"\n"
 
1679
"%s %s.ovp %s.ovf %s.ofm\n"
 
1680
"%s %s.ovp\n"
 
1681
"\n",
 
1682
OVP2OVF_NAME,output_name,output_name,output_name,
 
1683
rm_command,output_name);
 
1684
}
 
1685
 
 
1686
fclose(out);
 
1687
}
 
1688
 
 
1689
 
 
1690
 
 
1691
/*:51*//*55:*/
 
1692
#line 1985 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1693
 
 
1694
void read_config(void)
 
1695
{HBF_BBOX*boxp;
 
1696
char*real_config_file;
 
1697
 
 
1698
 
 
1699
/*56:*/
 
1700
#line 2037 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1701
 
 
1702
{int i,lastext= -1;
 
1703
 
 
1704
for(i= 0;config_file[i];i++)
 
1705
if(config_file[i]=='.')
 
1706
lastext= i;
 
1707
else if(config_file[i]=='/'||
 
1708
config_file[i]==':'||
 
1709
config_file[i]=='\\')
 
1710
lastext= -1;
 
1711
 
 
1712
if(lastext==-1)
 
1713
strcat(config_file,".cfg");
 
1714
}
 
1715
 
 
1716
 
 
1717
/*:56*/
 
1718
#line 1991 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1719
 
 
1720
 
 
1721
real_config_file= TeX_search_cfg_file(config_file);
 
1722
if(!real_config_file)
 
1723
{if(mf_like)
 
1724
{if(!quiet)
 
1725
printf("Couldn't find `%s'\n",config_file);
 
1726
exit(2);
 
1727
}
 
1728
else
 
1729
{fprintf(stderr,"Couldn't find `%s'\n",config_file);
 
1730
exit(1);
 
1731
}
 
1732
}
 
1733
 
 
1734
if(!(config= fopen(real_config_file,READ_TXT)))
 
1735
{if(!testing)
 
1736
{fprintf(stderr,"Couldn't open `%s'\n",config_file);
 
1737
exit(1);
 
1738
}
 
1739
else
 
1740
{if(!quiet)
 
1741
fprintf(stderr,"Couldn't find or open `%s'\n",config_file);
 
1742
exit(2);
 
1743
}
 
1744
}
 
1745
 
 
1746
if(testing)
 
1747
{if(!quiet)
 
1748
printf("%s\n",real_config_file);
 
1749
exit(0);
 
1750
}
 
1751
 
 
1752
/*57:*/
 
1753
#line 2054 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1754
 
 
1755
{char hbf_header[STRING_LENGTH+1];
 
1756
char*real_hbf_header;
 
1757
 
 
1758
if(!fsearch("hbf_header"))
 
1759
config_error("hbf_header");
 
1760
else
 
1761
strcpy(hbf_header,Buffer);
 
1762
 
 
1763
real_hbf_header= TeX_search_hbf_file(hbf_header);
 
1764
if(!real_hbf_header)
 
1765
{fprintf(stderr,"Couldn't find `%s'\n",hbf_header);
 
1766
exit(1);
 
1767
}
 
1768
 
 
1769
hbfDebug= 1;
 
1770
 
 
1771
 
 
1772
if(!(hbf= hbfOpen(real_hbf_header)))
 
1773
exit(1);
 
1774
 
 
1775
hbfDebug= 0;
 
1776
 
 
1777
boxp= hbfBitmapBBox(hbf);
 
1778
input_size_x= boxp->hbf_height;
 
1779
input_size_y= boxp->hbf_width;
 
1780
font_encoding= hbfProperty(hbf,"HBF_CODE_SCHEME");
 
1781
 
 
1782
if(!fsearch("output_name"))
 
1783
config_error("output_name");
 
1784
else
 
1785
strcpy(output_name,Buffer);
 
1786
}
 
1787
 
 
1788
 
 
1789
/*:57*/
 
1790
#line 2024 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1791
 
 
1792
/*59:*/
 
1793
#line 2098 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1794
 
 
1795
{if(fsearch("nmb_files"))
 
1796
nmb_files= atoi(Buffer);
 
1797
if(fsearch("unicode"))
 
1798
if(Buffer[0]=='y'||Buffer[0]=='Y')
 
1799
unicode= TRUE;
 
1800
if(fsearch("min_char"))
 
1801
{user_min_char= strtoul(Buffer,(char**)NULL,0);
 
1802
have_min_char= TRUE;
 
1803
}
 
1804
 
 
1805
if(!mf_like)
 
1806
{if(fsearch("pk_files"))
 
1807
if(Buffer[0]=='n'||Buffer[0]=='N')
 
1808
pk_files= FALSE;
 
1809
if(fsearch("tfm_files"))
 
1810
if(Buffer[0]=='n'||Buffer[0]=='N')
 
1811
tfm_files= FALSE;
 
1812
if(fsearch("ofm_file"))
 
1813
if(Buffer[0]=='y'||Buffer[0]=='Y')
 
1814
ofm_file= TRUE;
 
1815
if(fsearch("long_extension"))
 
1816
if(Buffer[0]=='n'||Buffer[0]=='N')
 
1817
long_extension= FALSE;
 
1818
}
 
1819
 
 
1820
if(fsearch("slant"))
 
1821
slant= atof(Buffer);
 
1822
if(slant<0.0||slant> 1.0)
 
1823
{fprintf(stderr,"Invalid slant\n");
 
1824
exit(1);
 
1825
}
 
1826
if(fsearch("rotation"))
 
1827
if(Buffer[0]=='y'||Buffer[0]=='Y')
 
1828
rotation= TRUE;
 
1829
 
 
1830
if(fsearch("mag_x"))
 
1831
mag_x= atof(Buffer);
 
1832
if(fsearch("mag_y"))
 
1833
mag_y= atof(Buffer);
 
1834
if(!mag_x&&!mag_y)
 
1835
{mag_x= 1.0;
 
1836
mag_y= 1.0;
 
1837
}
 
1838
if(mag_x&&!mag_y)
 
1839
mag_y= mag_x;
 
1840
if(mag_y&&!mag_x)
 
1841
mag_x= mag_y;
 
1842
if(mag_x<=0.0)
 
1843
{fprintf(stderr,"Invalid horizontal magnification\n");
 
1844
exit(1);
 
1845
}
 
1846
if(mag_y<=0.0)
 
1847
{fprintf(stderr,"Invalid vertical magnification\n");
 
1848
exit(1);
 
1849
}
 
1850
 
 
1851
if(fsearch("dpi_x"))
 
1852
dpi_x= atoi(Buffer);
 
1853
if(fsearch("dpi_y"))
 
1854
dpi_y= atoi(Buffer);
 
1855
if(!dpi_x&&!dpi_y)
 
1856
{dpi_x= 300;
 
1857
dpi_y= 300;
 
1858
}
 
1859
if(dpi_x&&!dpi_y)
 
1860
dpi_y= dpi_x;
 
1861
if(dpi_y&&!dpi_x)
 
1862
dpi_x= dpi_y;
 
1863
if(dpi_x<=PRINTER_MIN_RES_X)
 
1864
{fprintf(stderr,"Invalid horizontal printer resolution\n");
 
1865
exit(1);
 
1866
}
 
1867
if(dpi_y<=PRINTER_MIN_RES_Y)
 
1868
{fprintf(stderr,"Invalid vertical printer resolution\n");
 
1869
exit(1);
 
1870
}
 
1871
 
 
1872
if(fsearch("design_size"))
 
1873
design_size= atof(Buffer);
 
1874
 
 
1875
if(fsearch("x_offset"))
 
1876
offset_x= atoi(Buffer);
 
1877
else
 
1878
offset_x= rotation?0:(boxp->hbf_xDisplacement*mag_x+0.5);
 
1879
if(fsearch("y_offset"))
 
1880
offset_y= atoi(Buffer);
 
1881
else
 
1882
offset_y= rotation?0:(boxp->hbf_yDisplacement*mag_y+0.5);
 
1883
if(!fsearch("comment"))
 
1884
comment[0]= '\0';
 
1885
else
 
1886
strcpy(comment,Buffer);
 
1887
 
 
1888
if(fsearch("threshold"))
 
1889
threshold= atoi(Buffer);
 
1890
if(threshold<=0||threshold>=255)
 
1891
{fprintf(stderr,"Invalid threshold\n");
 
1892
exit(1);
 
1893
}
 
1894
 
 
1895
if(!fsearch("checksum"))
 
1896
checksum= 0;
 
1897
else
 
1898
checksum= strtoul(Buffer,(char**)NULL,0);
 
1899
 
 
1900
if(!fsearch("coding"))
 
1901
coding[0]= '\0';
 
1902
else
 
1903
strcpy(coding,Buffer);
 
1904
 
 
1905
if(!fsearch("pk_directory"))
 
1906
pk_directory[0]= '\0';
 
1907
else
 
1908
strcpy(pk_directory,Buffer);
 
1909
 
 
1910
if(!fsearch("tfm_directory"))
 
1911
tfm_directory[0]= '\0';
 
1912
else
 
1913
strcpy(tfm_directory,Buffer);
 
1914
 
 
1915
if(fsearch("rm_command"))
 
1916
strcpy(rm_command,Buffer);
 
1917
else
 
1918
strcpy(rm_command,"rm");
 
1919
 
 
1920
if(fsearch("cp_command"))
 
1921
strcpy(cp_command,Buffer);
 
1922
else
 
1923
strcpy(cp_command,"cp");
 
1924
 
 
1925
if(!fsearch("job_extension"))
 
1926
job_extension[0]= '\0';
 
1927
else
 
1928
{strncpy(job_extension,Buffer,EXTENSION_LENGTH);
 
1929
job_extension[EXTENSION_LENGTH]= '\0';
 
1930
}
 
1931
}
 
1932
 
 
1933
 
 
1934
/*:59*/
 
1935
#line 2025 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1936
 
 
1937
 
 
1938
/*61:*/
 
1939
#line 2252 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1940
 
 
1941
{const void*cp;
 
1942
HBF_CHAR dummy;
 
1943
 
 
1944
cp= hbfGetCodeRange(hbf,NULL,&min_char,&max_char);
 
1945
for(;cp!=NULL;cp= hbfGetCodeRange(hbf,cp,&dummy,&max_char))
 
1946
;
 
1947
 
 
1948
if(have_min_char)
 
1949
min_char= user_min_char;
 
1950
}
 
1951
 
 
1952
 
 
1953
/*:61*/
 
1954
#line 2027 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1955
 
 
1956
/*63:*/
 
1957
#line 2281 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1958
 
 
1959
{const void*b2r;
 
1960
unsigned char dummy;
 
1961
int i;
 
1962
 
 
1963
for(i= 0;i<256;i++)
 
1964
b2_codes[i]= 0;
 
1965
 
 
1966
b2r= hbfGetByte2Range(hbf,NULL,&min_2_byte,&max_2_byte);
 
1967
dummy= min_2_byte;
 
1968
for(;b2r!=NULL;b2r= hbfGetByte2Range(hbf,b2r,&dummy,&max_2_byte))
 
1969
{for(i= dummy;i<=max_2_byte;i++)
 
1970
b2_codes[i]= VALID_SUBCODE;
 
1971
}
 
1972
 
 
1973
for(i= 0;i<256;i++)
 
1974
if(b2_codes[i]==VALID_SUBCODE)
 
1975
nmb_2_bytes++;
 
1976
}
 
1977
 
 
1978
 
 
1979
/*:63*/
 
1980
#line 2028 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1981
 
 
1982
 
 
1983
fclose(config);
 
1984
}
 
1985
 
 
1986
 
 
1987
/*:55*//*65:*/
 
1988
#line 2313 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
1989
 
 
1990
int fsearch(const char*search_string)
 
1991
{char*P,p;
 
1992
const char*Q;
 
1993
char temp_buffer[STRING_LENGTH+1];
 
1994
char env_name[STRING_LENGTH+1];
 
1995
char*env_p;
 
1996
char*env_value;
 
1997
char*Buf_p;
 
1998
int Ch,ch,old_ch= '\n';
 
1999
int count= STRING_LENGTH;
 
2000
 
 
2001
rewind(config);
 
2002
 
 
2003
do
 
2004
{Q= search_string;
 
2005
p= tolower(*Q);
 
2006
Ch= fgetc(config);
 
2007
ch= tolower(Ch);
 
2008
while(!(ch==p&&old_ch=='\n')&&Ch!=EOF)
 
2009
 
 
2010
 
 
2011
{old_ch= ch;
 
2012
Ch= fgetc(config);
 
2013
ch= tolower(Ch);
 
2014
}
 
2015
 
 
2016
for(;;)
 
2017
{if(*(++Q)=='\0')
 
2018
if((Ch= fgetc(config))==' '||Ch=='\t')
 
2019
 
 
2020
goto success;
 
2021
Ch= fgetc(config);
 
2022
if(tolower(Ch)!=tolower(*Q))
 
2023
break;
 
2024
}
 
2025
}
 
2026
while(Ch!=EOF);
 
2027
 
 
2028
return 0;
 
2029
 
 
2030
success:
 
2031
P= temp_buffer;
 
2032
 
 
2033
while((Ch= fgetc(config))==' '||Ch=='\t')
 
2034
 
 
2035
;
 
2036
while(Ch!='\n'&&--count> 0&&Ch!=EOF)
 
2037
{*P++= Ch;
 
2038
Ch= fgetc(config);
 
2039
}
 
2040
*P= '\0';
 
2041
 
 
2042
if(*temp_buffer)
 
2043
/*66:*/
 
2044
#line 2392 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
2045
 
 
2046
{P= temp_buffer;
 
2047
Buf_p= Buffer;
 
2048
count= STRING_LENGTH-1;
 
2049
 
 
2050
while(*P&&count> 0)
 
2051
{env_p= env_name;
 
2052
 
 
2053
if(*P=='$')
 
2054
{P++;
 
2055
if(*P=='$')
 
2056
{*(Buf_p++)= *(P++);
 
2057
count--;
 
2058
continue;
 
2059
}
 
2060
while(*P=='{')
 
2061
P++;
 
2062
if(!(isalpha(*P)||*P=='_'))
 
2063
{fprintf(stderr,
 
2064
"Invalid environment variable name in configuration file\n");
 
2065
exit(1);
 
2066
}
 
2067
*(env_p++)= *(P++);
 
2068
while(*P)
 
2069
{if(isalnum(*P)||*P=='_')
 
2070
*(env_p++)= *(P++);
 
2071
else
 
2072
{while(*P=='}')
 
2073
P++;
 
2074
*env_p= '\0';
 
2075
break;
 
2076
}
 
2077
}
 
2078
 
 
2079
env_value= getenv(env_name);
 
2080
if(env_value)
 
2081
{while(*env_value&&count> 0)
 
2082
{*(Buf_p++)= *(env_value++);
 
2083
count--;
 
2084
}
 
2085
}
 
2086
}
 
2087
else
 
2088
{*(Buf_p++)= *(P++);
 
2089
count--;
 
2090
}
 
2091
}
 
2092
*Buf_p= '\0';
 
2093
}
 
2094
 
 
2095
 
 
2096
/*:66*/
 
2097
#line 2367 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
2098
 
 
2099
else
 
2100
*Buffer= '\0';
 
2101
 
 
2102
return(*Buffer)?1:0;
 
2103
}
 
2104
 
 
2105
 
 
2106
/*:65*//*68:*/
 
2107
#line 2452 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
2108
 
 
2109
void config_error(const char*message)
 
2110
{fprintf(stderr,"Couldn't find `%s' entry in configuration file\n",
 
2111
message);
 
2112
exit(1);
 
2113
}
 
2114
 
 
2115
 
 
2116
 
 
2117
/*:68*//*72:*/
 
2118
#line 2495 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
2119
 
 
2120
const char*TeX_search_version(void)
 
2121
{
 
2122
#if defined(HAVE_LIBKPATHSEA)
 
2123
return kpathsea_version_string;
 
2124
#elif defined(HAVE_EMTEXDIR)
 
2125
return emtex_version_string;
 
2126
#elif defined(HAVE_MIKTEX)
 
2127
char buf[200];
 
2128
 
 
2129
strcpy(buf,"MiKTeX ");
 
2130
miktex_get_miktex_version_string_ex(buf+7,sizeof(buf)-7);
 
2131
 
 
2132
return buf;
 
2133
#else
 
2134
return no_version_string;
 
2135
#endif
 
2136
}
 
2137
 
 
2138
 
 
2139
/*:72*//*75:*/
 
2140
#line 2537 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
2141
 
 
2142
#ifdef HAVE_EMTEXDIR
 
2143
int dir_setup(ed,env,dir,flags)
 
2144
struct emtex_dir*ed;
 
2145
const char*env;
 
2146
const char*dir;
 
2147
unsigned flags;
 
2148
 
 
2149
{const char*val;
 
2150
char path[260];
 
2151
 
 
2152
ed->alloc= 0;
 
2153
ed->used= 0;
 
2154
ed->list= NULL;
 
2155
 
 
2156
if(env!=NULL&&(val= getenv(env))!=NULL)
 
2157
return setup_list(ed,path,val,flags);
 
2158
else
 
2159
fprintf(stderr,
 
2160
"Environment variable `%s' not set; use current directory\n",
 
2161
env);
 
2162
 
 
2163
return TRUE;
 
2164
}
 
2165
 
 
2166
 
 
2167
/*:75*//*77:*/
 
2168
#line 2569 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
2169
 
 
2170
char*file_find(name,list)
 
2171
char*name;
 
2172
struct emtex_dir*list;
 
2173
 
 
2174
{if(emtex_dir_find(name_buffer,sizeof(name_buffer),list,name,EDF_CWD))
 
2175
return name_buffer;
 
2176
 
 
2177
return NULL;
 
2178
}
 
2179
#endif
 
2180
 
 
2181
 
 
2182
/*:77*//*80:*/
 
2183
#line 2619 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
 
2184
 
 
2185
#if defined(HAVE_LIBKPATHSEA)
 
2186
char*TeX_search_cfg_file(char*name)
 
2187
{
 
2188
return kpse_find_file(name,kpse_program_text_format,TRUE);
 
2189
}
 
2190
 
 
2191
 
 
2192
char*TeX_search_hbf_file(char*name)
 
2193
{
 
2194
return kpse_find_file(name,kpse_miscfonts_format,TRUE);
 
2195
}
 
2196
 
 
2197
 
 
2198
#elif defined(HAVE_EMTEXDIR)
 
2199
char*TeX_search_cfg_file(char*name)
 
2200
{return file_find(name,&cfg_path);
 
2201
}
 
2202
 
 
2203
 
 
2204
char*TeX_search_hbf_file(char*name)
 
2205
{return file_find(name,&hbf_path);
 
2206
}
 
2207
 
 
2208
 
 
2209
#elif defined(HAVE_MIKTEX)
 
2210
char*TeX_search_cfg_file(char*name)
 
2211
{char result[_MAX_PATH];
 
2212
 
 
2213
if(!miktex_find_input_file("hbf2gf",*name,result))
 
2214
return 0;
 
2215
return strdup(result);
 
2216
}
 
2217
 
 
2218
 
 
2219
char*TeX_search_hbf_file(char*name)
 
2220
{char result[_MAX_PATH];
 
2221
 
 
2222
 
 
2223
if(!miktex_find_miscfont_file(*name,result))
 
2224
return 0;
 
2225
return strdup(result);
 
2226
}
 
2227
 
 
2228
 
 
2229
#else
 
2230
char*TeX_search_cfg_file(char*name)
 
2231
{return name;
 
2232
}
 
2233
 
 
2234
 
 
2235
char*TeX_search_hbf_file(char*name)
 
2236
{return name;
 
2237
}
 
2238
#endif
 
2239
 
 
2240
 
 
2241
 
 
2242
/*:80*/