2
"hbf2gf (CJK ver. 4.8.3)" \
8
#define STRING_LENGTH 255 \
10
#define FILE_NAME_LENGTH 1024 \
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" \
20
"For more information about these matters, see the files\n" \
21
"named COPYING and hbf.c.\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" \
30
" Convert a font in HBF format to TeX's GF resp. PK format.\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" \
44
#define header " hbf2gf output " \
51
#define _2_20 1048576.0 \
63
#define CHAR_LOC0 246 \
66
#define POSTPOST_ID 223 \
71
#define PIXEL_MAXVAL 255
73
#define HALFSCALE 2048 \
75
#define MAX_CHAR_SIZE 1023 \
87
#define NEW_ROW_(x) ((x) +74) \
91
#define EXTENSION_LENGTH 8 \
93
#define GFTOPK_NAME "gftopk"
94
#define PLTOTF_NAME "pltotf"
95
#define OVP2OVF_NAME "ovp2ovf" \
97
#define PRINTER_MIN_RES_X 50
98
#define PRINTER_MIN_RES_Y 50 \
100
#define VALID_SUBCODE 1 \
103
#line 191 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
106
#line 408 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
116
#ifdef TM_IN_SYS_TIME
117
#include <sys/time.h>
124
#line 2469 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
126
#if defined(HAVE_LIBKPATHSEA)
127
#include "kpathsea/kpathsea.h"
129
#elif defined(HAVE_EMTEXDIR)
130
#include "emtexdir.h"
132
#elif defined(HAVE_MIKTEX)
137
#line 192 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
140
#line 429 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
142
void write_file(void);
146
#line 491 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
148
void write_pre(void);
152
#line 579 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
154
void write_data(void);
158
#line 690 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
160
void write_post(void);
164
#line 834 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
166
void fputl(long,FILE*);
170
#line 994 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
172
void make_pixel_array(void);
176
#line 1222 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
181
void read_row(unsigned char*);
185
#line 1272 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
190
void write_row(unsigned char*);
194
#line 1325 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
196
void write_coding(void);
200
#line 1486 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
206
#line 1583 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
208
void write_ovp(void);
212
#line 1728 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
214
void write_job(void);
218
#line 1977 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
220
void read_config(void);
224
#line 2308 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
226
int fsearch(const char*);
230
#line 2447 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
232
void config_error(const char*);
236
#line 2490 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
238
const char*TeX_search_version(void);
242
#line 2525 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
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*);
252
#line 2613 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
254
char*TeX_search_cfg_file(char*);
255
char*TeX_search_hbf_file(char*);
259
#line 193 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
262
#line 127 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
272
double x_resolution= 0.0;
277
int long_extension= TRUE;
280
char config_file[FILE_NAME_LENGTH+4+1];
282
char output_name[STRING_LENGTH+1];
288
#define WRITE_BIN "wb"
289
#define WRITE_TXT "wt"
290
#define READ_BIN "rb"
291
#define READ_TXT "rt"
293
#define WRITE_BIN "w"
294
#define WRITE_TXT "w"
299
int end_of_file= FALSE;
303
#line 538 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
318
const char*font_encoding;
320
int pk_output_size_x;
322
double tfm_output_size_x;
323
int pk_output_size_y;
324
double tfm_output_size_y;
326
double design_size= 10.0;
327
double target_size_x;
328
double target_size_y;
345
#line 667 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
347
char coding[STRING_LENGTH+1];
348
char comment[STRING_LENGTH+1];
350
unsigned long checksum;
364
#line 871 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
367
const unsigned char*bitmap;
369
const unsigned char*bP;
371
unsigned char out_char[MAX_CHAR_SIZE*MAX_CHAR_SIZE+1];
373
unsigned char*out_char_p;
375
unsigned char pixelrow[MAX_CHAR_SIZE];
376
unsigned char temp_pixelrow[MAX_CHAR_SIZE];
377
unsigned char new_pixelrow[MAX_CHAR_SIZE+1];
381
long grayrow[MAX_CHAR_SIZE];
383
long s_mag_x,s_mag_y,s_slant;
387
#line 1267 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
393
#line 1717 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
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];
405
#line 1972 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
407
char Buffer[STRING_LENGTH+1];
411
#line 2090 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
416
HBF_CHAR user_min_char;
417
int have_min_char= FALSE;
420
#line 2247 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
422
HBF_CHAR min_char,max_char;
426
#line 2274 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
429
unsigned char min_2_byte,max_2_byte;
434
#line 2481 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
436
#if defined(HAVE_EMTEXDIR)
437
char emtex_version_string[]= "emTeXdir";
438
#elif !defined(HAVE_MIKTEX)
439
char no_version_string[]= "no search library";
444
#line 2518 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
447
struct emtex_dir cfg_path,hbf_path;
452
#line 2564 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
454
char name_buffer[FILE_NAME_LENGTH+1];
458
#line 194 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
462
int main(int argc,char*argv[])
466
#line 2586 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
468
#if defined(HAVE_LIBKPATHSEA)
469
kpse_set_program_name(argv[0],"hbf2gf");
470
kpse_init_prog("HBF2GF",300,"cx","cmr10");
472
#elif defined(HAVE_EMTEXDIR)
473
if(!dir_setup(&cfg_path,"HBFCFG",NULL,EDS_BANG))
475
"Couldn't setup search path for configuration files\n");
478
if(!dir_setup(&hbf_path,"HBFONTS",NULL,EDS_BANG))
480
"Couldn't setup search path for HBF header files\n");
487
#line 200 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
491
#line 307 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
494
{if(strcmp(argv[1],"--help")==0)
496
#line 288 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
504
#line 310 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
506
else if(strcmp(argv[1],"--version")==0)
508
#line 261 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
512
printf(" (%s)\n",TeX_search_version());
519
#line 312 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
532
long_extension= FALSE;
544
{fprintf(stderr,"Need exactly one parameter for `-t' option.\n");
545
fprintf(stderr,"Try `hbf2gf --help' for more information.\n");
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");
557
#line 202 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
561
printf("\n%s\n\n",banner);
563
strncpy(config_file,argv[1],FILE_NAME_LENGTH);
564
config_file[FILE_NAME_LENGTH]= '\0';
567
{int l= strlen(config_file);
570
config_file[l-2]= '\0';
574
printf("`%s' can't be a subfont created by hbf2gf\n",
586
#line 352 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
589
file_number= (int)strtol(&argv[1][strlen(argv[1])-2],
592
file_number= atoi(&argv[1][strlen(argv[1])-2]);
594
x_resolution= atof(argv[2]);
595
if(x_resolution<PRINTER_MIN_RES_X)
596
{fprintf(stderr,"Invalid horizontal resolution\n");
601
{y_scale= atof(argv[3]);
604
"Invalid vertical scaling factor or resolution\n");
608
y_scale= (double)x_resolution/y_scale;
614
#line 229 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
618
#line 903 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
627
input_size_x= input_size_y;
632
{target_size_x= design_size*(x_resolution/dpi_x);
633
target_size_y= design_size*(x_resolution*y_scale/dpi_y);
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;
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;
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");
657
if(pk_output_size_y> MAX_CHAR_SIZE)
658
{fprintf(stderr,"Output character box height too big\n");
662
for(col= 0;col<input_size_x;++col)
663
grayrow[col]= HALFSCALE;
666
code= (min_char&0xFF00)+min_2_byte;
668
{if((file_number<(unicode?0:1))||(file_number>=0x100))
669
{fprintf(stderr,"Invalid subfile number\n");
675
code= file_number*0x100;
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;
684
while(!b2_codes[code++&0xFF])
689
{fprintf(stderr,"Invalid subfile number\n");
694
s_mag_x= mag_x*magstep_x*SCALE;
695
s_mag_y= mag_y*magstep_y*SCALE;
696
s_slant= slant*SCALE;
701
#line 231 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
705
#line 387 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
710
{file_number= (unicode==TRUE?(min_char>>8):1);
712
max_numb= (unicode==TRUE?0x100:100);
719
for(j= 0;(j<max_numb)&&!end_of_file;file_number++,j++)
727
#line 233 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
745
#line 437 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
747
void write_file(void)
748
{char output_file[FILE_NAME_LENGTH+1];
754
sprintf(output_file,"%s%02x.%.0igf",
755
output_name,file_number,
756
long_extension?(int)(x_resolution+0.5):0);
758
sprintf(output_file,"%s%02i.%.0igf",
759
output_name,file_number,
760
long_extension?(int)(x_resolution+0.5):0);
764
sprintf(output_file,"%s%02x.gf",output_name,file_number);
766
sprintf(output_file,"%s%02i.gf",output_name,file_number);
768
if(!(out= fopen(output_file,WRITE_BIN)))
769
{fprintf(stderr,"Couldn't open `%s'\n",output_file);
773
printf("Writing `%s' ",output_file);
789
#line 498 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
792
{char out_s[40],s[20];
797
strcpy(out_s,header);
799
secs_now= time(NULL);
800
time_now= localtime(&secs_now);
801
strftime(s,20,"%Y.%m.%d:%H.%M",time_now);
806
fputc(strlen(out_s),out);
812
#line 584 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
814
void write_data(void)
816
char_adr_p= char_adr;
818
for(last_char= 0;(last_char<256)&&!end_of_file;last_char++)
820
#line 609 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
822
{if(dot_count++%10==0)
834
{*char_adr_p= ftell(out);
839
fputc((unsigned char)last_char,out);
848
fputl(last_char,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);
864
#line 590 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
870
#line 695 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
872
void write_post(void)
876
long designsize= design_size*_2_20;
885
ppp_x= dpi_x/72.27*magstep_x;
886
ppp_y= dpi_y/72.27*magstep_y;
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;
893
pk_dx= pk_width+2*pk_offset_x;
894
tfm_width= (tfm_output_size_x+2*tfm_offset_x)*_2_20;
898
#line 741 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
900
special_adr= ftell(out);
904
fputc(strlen(coding),out);
910
fputc(strlen(comment),out);
916
#line 721 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
919
#line 770 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
921
post_adr= ftell(out);
923
fputl(special_adr,out);
925
fputl(designsize,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);
934
char_adr_p= char_adr;
937
{for(i= 0;i<last_char;i++)
938
{fputc(CHAR_LOC0,out);
941
fputl(tfm_width,out);
942
fputl(*char_adr_p++,out);
946
{for(i= 0;i<last_char;i++)
947
{fputc(CHAR_LOC,out);
949
fputl(pk_dx*_2_16,out);
951
fputl(tfm_width,out);
952
fputl(*char_adr_p++,out);
958
#line 722 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
961
#line 821 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
969
fputc(POSTPOST_ID,out);
973
#line 723 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
979
#line 839 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
981
void fputl(long num,FILE*f)
990
#line 999 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
992
void make_pixel_array(void)
994
unsigned char*temp_prP;
995
unsigned char*new_prP;
998
register unsigned char*xP;
999
register unsigned char*nxP;
1001
register int row,col;
1003
register int need_to_read_row= 1;
1005
long frac_row_to_fill= SCALE;
1006
long frac_row_left= s_mag_y;
1012
temp_prP= temp_pixelrow;
1013
new_prP= new_pixelrow;
1015
out_char_p= out_char;
1018
if(b2_codes[code&0xFF])
1020
{bitmap= hbfGetBitmap(hbf,code);
1028
#line 1058 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1030
{if(pk_output_size_y==input_size_y)
1033
curr_row= input_size_y-1;
1034
for(row= 0;row<pk_output_size_y;++row)
1036
#line 1072 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1038
if(pk_output_size_y==input_size_y)
1042
{while(frac_row_left<frac_row_to_fill)
1043
{if(need_to_read_row)
1044
if(rows_read<input_size_y)
1049
for(col= 0,xP= prP;col<input_size_x;++col,++xP)
1050
grP[col]+= frac_row_left*(*xP);
1052
frac_row_to_fill-= frac_row_left;
1053
frac_row_left= s_mag_y;
1054
need_to_read_row= 1;
1058
#line 1099 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1060
if(need_to_read_row)
1061
if(rows_read<input_size_y)
1064
need_to_read_row= 0;
1067
for(col= 0,xP= prP,nxP= temp_prP;
1068
col<input_size_x;++col,++xP,++nxP)
1072
g= grP[col]+frac_row_to_fill*(*xP);
1078
grP[col]= HALFSCALE;
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;
1086
frac_row_to_fill= SCALE;
1090
#line 1092 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1096
#line 1064 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1099
#line 1140 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1101
if(pk_width==input_size_x&&s_slant==0)
1103
write_row(temp_prP);
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;
1113
frac_col_left= (pk_output_size_y-row)*s_slant;
1114
while(frac_col_left>=frac_col_to_fill)
1116
frac_col_left-= frac_col_to_fill;
1119
if(frac_col_left> 0)
1120
frac_col_to_fill-= frac_col_left;
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)
1130
g+= frac_col_to_fill*(*xP);
1136
frac_col_left-= frac_col_to_fill;
1137
frac_col_to_fill= SCALE;
1141
if(frac_col_left> 0)
1148
g+= frac_col_left*(*xP);
1149
frac_col_to_fill-= frac_col_left;
1154
#line 1198 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1156
if(frac_col_to_fill> 0)
1158
g+= frac_col_to_fill*(*xP);
1174
#line 1193 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1180
#line 1066 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1187
#line 1035 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1194
if((code&0xFF)==max_2_byte)
1195
code+= 0xFF-(max_2_byte-min_2_byte);
1211
#line 1230 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1216
void read_row(unsigned char*pixelrow)
1217
{register int col,bitshift,offset;
1218
register unsigned char*xP;
1219
register unsigned char item= 0;
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;
1233
for(col= 0,xP= pixelrow;col<input_size_x;++col,++xP)
1238
*xP= ((item>>bitshift)&1)==1?PIXEL_MAXVAL:0;
1246
#line 1280 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1251
void write_row(unsigned char*pixelrow)
1253
register unsigned char*xP;
1255
for(col= 0,xP= pixelrow;col<pk_output_size_x;++col,++xP)
1256
*(out_char_p++)= (*xP>=threshold)?1:0;
1262
#line 1333 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1264
void write_coding(void)
1265
{register int count,skip;
1266
register unsigned char paint;
1268
register unsigned char*cp;
1272
cp= out_char+y*pk_output_size_x+x;
1277
while(y<pk_output_size_y)
1279
#line 1357 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1283
cp= out_char+y*pk_output_size_x+x;
1285
while(x<pk_output_size_x)
1291
fputc(NEW_ROW_(count),out);
1301
fputc(count>>8,out);
1302
fputc(count&0xFF,out);
1317
fputc(skip&0xFF,out);
1322
fputc(PAINT_(count),out);
1329
fputc(count>>8,out);
1330
fputc(count&0xFF,out);
1340
if(x>=pk_output_size_x)
1348
#line 1348 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1352
#line 1425 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1354
while(x<pk_output_size_x)
1359
fputc(PAINT_(count),out);
1366
fputc(count>>8,out);
1367
fputc(count&0xFF,out);
1377
fputc(PAINT_(count),out);
1384
fputc(count>>8,out);
1385
fputc(count&0xFF,out);
1393
#line 1350 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1401
#line 1491 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1405
char output_file[FILE_NAME_LENGTH+1];
1408
char tfm_header[]= "Created by hbf2gf";
1414
sprintf(output_file,"%s%02x.pl",output_name,file_number);
1416
sprintf(output_file,"%s%02i.pl",output_name,file_number);
1419
sprintf(output_file,"%s.pl",output_name);
1421
if(!(out= fopen(output_file,WRITE_TXT)))
1422
{fprintf(stderr,"Couldn't open `%s'\n",output_file);
1426
printf("\nWriting `%s'\n",output_file);
1430
"\n(CODINGSCHEME CJK-%s)",
1431
output_name,file_number,font_encoding);
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)"
1441
"\n (STRETCH R 0.0)"
1443
"\n (XHEIGHT R 1.0)"
1445
"\n (EXTRASPACE R 0.0)"
1446
"\n )",design_size,checksum,slant);
1456
{t|= ((long)(*(unsigned char*)s++))<<sc;
1459
{fprintf(out,"\n(HEADER D %d O %lo)",pos,t);
1467
fprintf(out,"\n(HEADER D %d O %lo)",pos,t);
1473
"\n (CHARWD R %.6f)"
1474
"\n (CHARHT R %.6f)"
1475
"\n (CHARDP R %.6f)"
1476
"\n (CHARIC R %.6f)"
1479
tfm_output_size_x+2*tfm_offset_x,
1480
tfm_output_size_y+tfm_offset_y,
1482
slant*(tfm_output_size_y+tfm_offset_y));
1491
#line 1588 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1493
void write_ovp(void)
1494
{int c,i,nmb_subfonts,remainder,count,pos;
1495
char output_file[FILE_NAME_LENGTH+1];
1498
char ofm_header[]= "Created by hbf2gf";
1500
nmb_subfonts= ((max_char-(min_char&0xFF00))/256*nmb_2_bytes)
1502
remainder= ((max_char-(min_char&0xFF00))/256*nmb_2_bytes)
1506
for(count= 0;count<(max_char&0xFF);count++)
1512
sprintf(output_file,"%s.ovp",output_name);
1514
if(!(out= fopen(output_file,WRITE_TXT)))
1515
{fprintf(stderr,"Couldn't open `%s'\n",output_file);
1519
printf("\nWriting `%s'\n",output_file);
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)"
1530
"\n (STRETCH R 0.0)"
1532
"\n (XHEIGHT R 1.0)"
1534
"\n (EXTRASPACE R 0.0)"
1535
"\n )",design_size,checksum,slant);
1545
{t|= ((long)(*(unsigned char*)s++))<<sc;
1548
{fprintf(out,"\n(HEADER D %d O %lo)",pos,t);
1556
fprintf(out,"\n(HEADER D %d O %lo)",pos,t);
1559
for(i= 0;i<nmb_subfonts;i++)
1562
"\n (FONTNAME %s%02i)"
1563
"\n (FONTCHECKSUM O %lo)"
1565
"\n (FONTDSIZE R %.6f)"
1566
"\n )",i,output_name,i+1,checksum,design_size);
1569
for(c= min_char,i= 0,count= 0;c<=max_char;c++)
1570
{if(b2_codes[c&0xFF]==VALID_SUBCODE)
1573
"\n (CHARWD R %.6f)"
1574
"\n (CHARHT R %.6f)"
1575
"\n (CHARDP R %.6f)"
1576
"\n (CHARIC R %.6f)"
1578
"\n (SELECTFONT D %i)"
1583
tfm_output_size_x+2*tfm_offset_x,
1584
tfm_output_size_y+tfm_offset_y,
1586
slant*(tfm_output_size_y+tfm_offset_y),
1606
#line 1733 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1608
void write_job(void)
1611
char buffer[FILE_NAME_LENGTH+1];
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);
1621
printf("\nWriting `%s'\n",buffer);
1625
{for(i= (min_char>>8),j= 0;j<nmb_files;i++,j++)
1627
"%s %s%02x.gf %s%s%02x.%.0ipk\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);
1635
{for(i= 1;i<=nmb_files;i++)
1637
"%s %s%02i.gf %s%s%02i.%.0ipk\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);
1652
PLTOTF_NAME,output_name,output_name,
1653
rm_command,output_name);
1656
{for(i= (min_char>>8),j= 0;j<nmb_files;i++,j++)
1658
"%s %s.tfm %s%s%02x.tfm\n",
1659
cp_command,output_name,
1660
tfm_directory,output_name,i);
1663
{for(i= 1;i<=nmb_files;i++)
1665
"%s %s.tfm %s%s%02i.tfm\n",
1666
cp_command,output_name,
1667
tfm_directory,output_name,i);
1673
rm_command,output_name);
1679
"%s %s.ovp %s.ovf %s.ofm\n"
1682
OVP2OVF_NAME,output_name,output_name,output_name,
1683
rm_command,output_name);
1692
#line 1985 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1694
void read_config(void)
1696
char*real_config_file;
1700
#line 2037 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1704
for(i= 0;config_file[i];i++)
1705
if(config_file[i]=='.')
1707
else if(config_file[i]=='/'||
1708
config_file[i]==':'||
1709
config_file[i]=='\\')
1713
strcat(config_file,".cfg");
1718
#line 1991 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1721
real_config_file= TeX_search_cfg_file(config_file);
1722
if(!real_config_file)
1725
printf("Couldn't find `%s'\n",config_file);
1729
{fprintf(stderr,"Couldn't find `%s'\n",config_file);
1734
if(!(config= fopen(real_config_file,READ_TXT)))
1736
{fprintf(stderr,"Couldn't open `%s'\n",config_file);
1741
fprintf(stderr,"Couldn't find or open `%s'\n",config_file);
1748
printf("%s\n",real_config_file);
1753
#line 2054 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1755
{char hbf_header[STRING_LENGTH+1];
1756
char*real_hbf_header;
1758
if(!fsearch("hbf_header"))
1759
config_error("hbf_header");
1761
strcpy(hbf_header,Buffer);
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);
1772
if(!(hbf= hbfOpen(real_hbf_header)))
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");
1782
if(!fsearch("output_name"))
1783
config_error("output_name");
1785
strcpy(output_name,Buffer);
1790
#line 2024 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1793
#line 2098 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1795
{if(fsearch("nmb_files"))
1796
nmb_files= atoi(Buffer);
1797
if(fsearch("unicode"))
1798
if(Buffer[0]=='y'||Buffer[0]=='Y')
1800
if(fsearch("min_char"))
1801
{user_min_char= strtoul(Buffer,(char**)NULL,0);
1802
have_min_char= TRUE;
1806
{if(fsearch("pk_files"))
1807
if(Buffer[0]=='n'||Buffer[0]=='N')
1809
if(fsearch("tfm_files"))
1810
if(Buffer[0]=='n'||Buffer[0]=='N')
1812
if(fsearch("ofm_file"))
1813
if(Buffer[0]=='y'||Buffer[0]=='Y')
1815
if(fsearch("long_extension"))
1816
if(Buffer[0]=='n'||Buffer[0]=='N')
1817
long_extension= FALSE;
1820
if(fsearch("slant"))
1821
slant= atof(Buffer);
1822
if(slant<0.0||slant> 1.0)
1823
{fprintf(stderr,"Invalid slant\n");
1826
if(fsearch("rotation"))
1827
if(Buffer[0]=='y'||Buffer[0]=='Y')
1830
if(fsearch("mag_x"))
1831
mag_x= atof(Buffer);
1832
if(fsearch("mag_y"))
1833
mag_y= atof(Buffer);
1843
{fprintf(stderr,"Invalid horizontal magnification\n");
1847
{fprintf(stderr,"Invalid vertical magnification\n");
1851
if(fsearch("dpi_x"))
1852
dpi_x= atoi(Buffer);
1853
if(fsearch("dpi_y"))
1854
dpi_y= atoi(Buffer);
1863
if(dpi_x<=PRINTER_MIN_RES_X)
1864
{fprintf(stderr,"Invalid horizontal printer resolution\n");
1867
if(dpi_y<=PRINTER_MIN_RES_Y)
1868
{fprintf(stderr,"Invalid vertical printer resolution\n");
1872
if(fsearch("design_size"))
1873
design_size= atof(Buffer);
1875
if(fsearch("x_offset"))
1876
offset_x= atoi(Buffer);
1878
offset_x= rotation?0:(boxp->hbf_xDisplacement*mag_x+0.5);
1879
if(fsearch("y_offset"))
1880
offset_y= atoi(Buffer);
1882
offset_y= rotation?0:(boxp->hbf_yDisplacement*mag_y+0.5);
1883
if(!fsearch("comment"))
1886
strcpy(comment,Buffer);
1888
if(fsearch("threshold"))
1889
threshold= atoi(Buffer);
1890
if(threshold<=0||threshold>=255)
1891
{fprintf(stderr,"Invalid threshold\n");
1895
if(!fsearch("checksum"))
1898
checksum= strtoul(Buffer,(char**)NULL,0);
1900
if(!fsearch("coding"))
1903
strcpy(coding,Buffer);
1905
if(!fsearch("pk_directory"))
1906
pk_directory[0]= '\0';
1908
strcpy(pk_directory,Buffer);
1910
if(!fsearch("tfm_directory"))
1911
tfm_directory[0]= '\0';
1913
strcpy(tfm_directory,Buffer);
1915
if(fsearch("rm_command"))
1916
strcpy(rm_command,Buffer);
1918
strcpy(rm_command,"rm");
1920
if(fsearch("cp_command"))
1921
strcpy(cp_command,Buffer);
1923
strcpy(cp_command,"cp");
1925
if(!fsearch("job_extension"))
1926
job_extension[0]= '\0';
1928
{strncpy(job_extension,Buffer,EXTENSION_LENGTH);
1929
job_extension[EXTENSION_LENGTH]= '\0';
1935
#line 2025 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1939
#line 2252 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1944
cp= hbfGetCodeRange(hbf,NULL,&min_char,&max_char);
1945
for(;cp!=NULL;cp= hbfGetCodeRange(hbf,cp,&dummy,&max_char))
1949
min_char= user_min_char;
1954
#line 2027 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1957
#line 2281 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1960
unsigned char dummy;
1966
b2r= hbfGetByte2Range(hbf,NULL,&min_2_byte,&max_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;
1974
if(b2_codes[i]==VALID_SUBCODE)
1980
#line 2028 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1988
#line 2313 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
1990
int fsearch(const char*search_string)
1993
char temp_buffer[STRING_LENGTH+1];
1994
char env_name[STRING_LENGTH+1];
1998
int Ch,ch,old_ch= '\n';
1999
int count= STRING_LENGTH;
2008
while(!(ch==p&&old_ch=='\n')&&Ch!=EOF)
2018
if((Ch= fgetc(config))==' '||Ch=='\t')
2022
if(tolower(Ch)!=tolower(*Q))
2033
while((Ch= fgetc(config))==' '||Ch=='\t')
2036
while(Ch!='\n'&&--count> 0&&Ch!=EOF)
2044
#line 2392 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
2048
count= STRING_LENGTH-1;
2056
{*(Buf_p++)= *(P++);
2062
if(!(isalpha(*P)||*P=='_'))
2064
"Invalid environment variable name in configuration file\n");
2069
{if(isalnum(*P)||*P=='_')
2079
env_value= getenv(env_name);
2081
{while(*env_value&&count> 0)
2082
{*(Buf_p++)= *(env_value++);
2088
{*(Buf_p++)= *(P++);
2097
#line 2367 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
2102
return(*Buffer)?1:0;
2107
#line 2452 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
2109
void config_error(const char*message)
2110
{fprintf(stderr,"Couldn't find `%s' entry in configuration file\n",
2118
#line 2495 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
2120
const char*TeX_search_version(void)
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)
2129
strcpy(buf,"MiKTeX ");
2130
miktex_get_miktex_version_string_ex(buf+7,sizeof(buf)-7);
2134
return no_version_string;
2140
#line 2537 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
2142
#ifdef HAVE_EMTEXDIR
2143
int dir_setup(ed,env,dir,flags)
2144
struct emtex_dir*ed;
2156
if(env!=NULL&&(val= getenv(env))!=NULL)
2157
return setup_list(ed,path,val,flags);
2160
"Environment variable `%s' not set; use current directory\n",
2168
#line 2569 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
2170
char*file_find(name,list)
2172
struct emtex_dir*list;
2174
{if(emtex_dir_find(name_buffer,sizeof(name_buffer),list,name,EDF_CWD))
2183
#line 2619 "/usr/local/home/wl/git/cjk/cjk-4.8.3/utils/hbf2gf/hbf2gf.w"
2185
#if defined(HAVE_LIBKPATHSEA)
2186
char*TeX_search_cfg_file(char*name)
2188
return kpse_find_file(name,kpse_program_text_format,TRUE);
2192
char*TeX_search_hbf_file(char*name)
2194
return kpse_find_file(name,kpse_miscfonts_format,TRUE);
2198
#elif defined(HAVE_EMTEXDIR)
2199
char*TeX_search_cfg_file(char*name)
2200
{return file_find(name,&cfg_path);
2204
char*TeX_search_hbf_file(char*name)
2205
{return file_find(name,&hbf_path);
2209
#elif defined(HAVE_MIKTEX)
2210
char*TeX_search_cfg_file(char*name)
2211
{char result[_MAX_PATH];
2213
if(!miktex_find_input_file("hbf2gf",*name,result))
2215
return strdup(result);
2219
char*TeX_search_hbf_file(char*name)
2220
{char result[_MAX_PATH];
2223
if(!miktex_find_miscfont_file(*name,result))
2225
return strdup(result);
2230
char*TeX_search_cfg_file(char*name)
2235
char*TeX_search_hbf_file(char*name)