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