2
* --- make a bitmap of a text encoded in compound text.
3
* Bitmap is printed in PBM or PGM format.
5
* by Hirotsugu Kakugawa (h.kakugawa@computer.org)
7
* Copyright (C) 1998,1999 by H. Kakugawa
9
* The following character sets are supported:
11
* ISO 8859-1,2,3,4,9 (English, German, Italy, French, Spanish, etc)
12
* ISO 8859-5 (Russian)
15
* JIS X 0201 (Japanese Roman and and Roman)
16
* JIS X 0208 (Japanese Kanji)
17
* GB 2312 (Chinese Hanzi)
19
* Mule Arabic (Arabic by the Mule editor)
20
* Mule Big 5 (Chinese BIG5 by the Mule editor)
21
* Mule Viscii 1.1 (Vietnamese by the Mule editor)
22
* Mule Ethiopic (Ethiopic by the Mule editor)
24
* The following encodings are supported:
33
* 5 Jun 1998 Support for character sets ISO8859-1, JIS X0208, KSC 5601, and
34
* GB 2312. Output in PBM format. Font face selection feature.
35
* 6 Jun 1998 Added font family selection.
36
* 7 Jun 1998 Support for output of PGM format and anti-aliasing.
37
* 8 Jun 1998 Support for ISO8859-2,3,4,5,7,9 charsets.
38
* 9 Jun 1998 Support for JIS X0201-Roman and JIS X0201-Kana charsets.
39
* Fixed bugs in the compound text parser.
40
* 11 Jun 1998 Support for EUC-JP, EUC-KR, and EUC-GB, EUC-CNS for input
42
* 12 Jun 1998 Support for right-to-left directionality (e.g., Hebrew)
43
* in left-to-right directionality text.
44
* 13 Jun 1998 Support for right-to-left directionality. ISO8859-8
45
* (Hebrew) charset is supported. Scripts of left-to-right
46
* directionality in right-to-left script is also supported.
47
* Support for code sets 2 and 4 of EUC-JP encoding.
48
* 15 Jun 1998 Support for Shift-JIS encoding. Added a command line option
49
* for page width and height specification.
50
* Added reversed character command in input text.
51
* Support for arabic text file created by Mule.
52
* 16 Jun 1998 Added page width/height and center/flush-left/flush-right
54
* 18 Jun 1998 Enhanced searcing mechanism for opening fonts.
55
* Added a feature to print font list.
56
* 22 Jun 1998 Added ASCII art output format.
57
* 23 Jun 1998 Added EPS and vertical ASCII art output formats.
58
* 25 Nov 1998 Image file output code is adopted in VFlib; ctext2pgm
59
* is changed to use image output functions in VFlib.
60
* 15 Dec 1998 Added -center-line, -h-center-line, -v-center-line,
61
* -left-line and -right-line options.
62
* 22 Apr 1999 Added -bbx option for generating minimum image.
63
* 11 Jan 1999 Added Mule-VISCII, Mule-Ethiopic Mule-Big5 charsets
64
* 12 Jan 1999 Improved to handle jisx0201-kana designated in G0.
65
* 13 Jan 1999 Added tab stop feature.
69
* Copyright (C) 1998,1999 Hirotsugu Kakugawa.
70
* All rights reserved.
72
* This program is free software; you can redistribute it and/or modify
73
* it under the terms of the GNU General Public License as published by
74
* the Free Software Foundation; either version 2, or (at your option)
77
* This program is distributed in the hope that it will be useful,
78
* but WITHOUT ANY WARRANTY; without even the implied warranty of
79
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80
* GNU General Public License for more details.
82
* You should have received a copy of the GNU General Public License
83
* along with this program; if not, write to the Free Software
84
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
91
#include <VFlib-3_6.h>
93
#include "ctext2pgm.h"
97
void parse_args(int *argcp, char ***argvp);
98
void usage(int level);
99
void make_text_bitmap(FILE *fp, char *title);
100
void parser(FILE *fp, VF_BITMAPLIST page_buff);
101
void parser_eol(VF_BITMAPLIST *line_buff_p, VF_BITMAPLIST page_buff,
102
int vposx, int vposy);
103
void parser_check_wdir(int i, VF_BITMAPLIST *line_buff_p);
104
void parser_wdir_push(int wdir, VF_BITMAPLIST *line_buff_p);
105
void parser_wdir_pop(VF_BITMAPLIST *line_buff_p);
106
void parser_wdir_do_push(int wdir, VF_BITMAPLIST *line_buff_p);
107
void parser_wdir_do_pop(VF_BITMAPLIST *line_buff_p);
108
int charset_wdirection(int charset);
109
void parser_cmd(long code_point, VF_BITMAPLIST page_buff,
110
int *charset_saved_p, int g, int *posxp, int *posyp);
111
void parser_init(void);
112
void draw_char(long code_point, VF_BITMAPLIST bmlist, int g,
113
int *posxp, int *posyp);
114
void put_bitmap(VF_BITMAPLIST buff, VF_BITMAP bm,
115
int wdir, int *posxp, int *posyp);
116
long cp_conv(long code_point, int i);
117
void reverse_bitmap(VF_BITMAP bm);
118
void swap_refpt_nextpt(VF_BITMAP bm);
119
void change_fonts(int g);
120
int try_font_open(int table_index);
121
char* charset_name(int charset, char *if_unknown);
122
void show_font_list(void);
123
void wprint(char *str, int w);
126
extern VF_BITMAP vf_alloc_bitmap(int,int);
143
int page_width, page_height;
144
int margin_x, margin_y;
146
int image_position_h, image_position_v;
156
int debug_page_bitmap;
157
int debug_line_bitmap;
158
int debug_char_bitmap;
162
/* For encoding parser: parser states */
163
int current_family; /* current font family */
164
int current_face; /* current font face */
165
int current_reverse; /* reverse black and white of char */
166
int current_font_g[4]; /* current fonts for G0 and G1 */
167
int font_exists_g[4]; /* font existence flag for G0 and G1 */
168
int current_wdir_g[4];
169
int type_g[4]; /* 94/96 of G0/G1 */
170
int charset_g[4]; /* charset IDs of G0/G1 */
171
int chlen_g[4]; /* bytes per char of G0/G1 */
173
struct s_dir_stack_elem dir_stack[MAX_DIR_STACK]; /* direction stack */
174
int dir_sp; /* stack pointer */
177
/* Parser parameters */
192
main(int argc, char **argv)
197
input_encoding = ENC_DEFAULT;
198
output_format = OFORM_DEFAULT;
201
vflibcap = DEFAULT_VFLIBCAP;
204
pixel = DEFAULT_PIXEL_SIZE;
205
baselineskip = DEFAULT_BASELINESKIP;
207
tab_skip = DEFAULT_TAB_SKIP;
208
pix_reverse = DEFAULT_REVERSE;
209
wdirection = WDIR_DEFAULT;
212
margin_x = DEFAULT_MARGIN;
213
margin_y = DEFAULT_MARGIN;
216
line_typeset = DEFAULT_LINE_POS;
217
image_position_h = VF_IMAGEOUT_POSITION_NONE;
218
image_position_v = VF_IMAGEOUT_POSITION_NONE;
220
default_family = FAM_DEFAULT;
221
default_face = FACE_DEFAULT;
227
debug_page_bitmap = 0;
228
debug_line_bitmap = 0;
229
debug_char_bitmap = 0;
233
parse_args(&argc, &argv);
235
current_family = default_family;
236
current_face = default_face;
238
if (debug_vflib == 1){
239
if (vflibcap == NULL)
240
printf("VF_Init(NULL, NULL)\n");
242
printf("VF_Init(\"%s\", NULL)\n", vflibcap);
245
if (VF_Init(vflibcap, NULL) < 0){
247
case VF_ERR_NO_VFLIBCAP:
248
PR2("ctext2pgm: vflibcap is not found: \"%s\".\n",
249
(vflibcap==NULL)?DEFAULT_VFLIBCAP:vflibcap);
252
PR1("ctext2pgm: failed to initialize.\n");
258
for (i = 0; font_info[i].font_id >= 0; i++){
259
font_info[i].font_id = NOT_OPENED;
263
make_text_bitmap(stdin, "stdin");
265
if ((fp = fopen(argv[0], "r")) == NULL){
269
make_text_bitmap(fp, argv[0]);
278
parse_args(int *argcp, char ***argvp)
286
while ((argc > 0) && (*argv[0] == '-')){
287
if (strcmp(argv[0], "-v") == 0){
290
} else if (strcmp(argv[0], "-m") == 0){
291
magx = magy = atof(argv[1]);
293
} else if (strcmp(argv[0], "-mx") == 0){
294
magx = atof(argv[1]);
296
} else if (strcmp(argv[0], "-my") == 0){
297
magy = atof(argv[1]);
299
} else if (strcmp(argv[0], "-b") == 0){
300
baselineskip = atof(argv[1]);
301
if (baselineskip <= 0)
304
} else if (strcmp(argv[0], "-bbx") == 0){
306
} else if (strcmp(argv[0], "-g") == 0){
307
margin_x = margin_y = atoi(argv[1]);
309
} else if (strcmp(argv[0], "-gx") == 0){
310
margin_x = atoi(argv[1]);
312
} else if (strcmp(argv[0], "-gy") == 0){
313
margin_y = atoi(argv[1]);
315
} else if (strcmp(argv[0], "-r") == 0){
317
} else if (strcmp(argv[0], "-14") == 0){
319
} else if (strcmp(argv[0], "-16") == 0){
321
} else if (strcmp(argv[0], "-18") == 0){
323
} else if (strcmp(argv[0], "-24") == 0){
325
} else if (strcmp(argv[0], "-scale") == 0){
327
xpixel = atoi(argv[1]);
329
} else if (strcmp(argv[0], "-fixed") == 0){
330
default_family = FAM_FIXED;
331
} else if (strcmp(argv[0], "-times") == 0){
332
default_family = FAM_TIMES;
333
} else if (strcmp(argv[0], "-helv") == 0){
334
default_family = FAM_HELV;
335
} else if (strcmp(argv[0], "-cour") == 0){
336
default_family = FAM_COUR;
337
} else if (strcmp(argv[0], "-normal") == 0){
338
default_face = FACE_NORMAL;
339
} else if (strcmp(argv[0], "-bold") == 0){
340
default_face = FACE_BOLD;
341
} else if (strcmp(argv[0], "-italic") == 0){
342
default_face = FACE_ITALIC;
343
} else if (strcmp(argv[0], "-ctext") == 0){
344
input_encoding = ENC_CTEXT;
345
} else if (strcmp(argv[0], "-iso-8859-1") == 0){
346
input_encoding = ENC_ISO8859_1;
347
} else if (strcmp(argv[0], "-latin-1") == 0){
348
input_encoding = ENC_ISO8859_1;
349
} else if (strcmp(argv[0], "-iso-8859-2") == 0){
350
input_encoding = ENC_ISO8859_2;
351
} else if (strcmp(argv[0], "-latin-2") == 0){
352
input_encoding = ENC_ISO8859_2;
353
} else if (strcmp(argv[0], "-iso-8859-3") == 0){
354
input_encoding = ENC_ISO8859_3;
355
} else if (strcmp(argv[0], "-latin-3") == 0){
356
input_encoding = ENC_ISO8859_3;
357
} else if (strcmp(argv[0], "-iso-8859-4") == 0){
358
input_encoding = ENC_ISO8859_4;
359
} else if (strcmp(argv[0], "-latin-4") == 0){
360
input_encoding = ENC_ISO8859_4;
361
} else if (strcmp(argv[0], "-iso-8859-5") == 0){
362
input_encoding = ENC_ISO8859_5;
363
} else if (strcmp(argv[0], "-cyrillic") == 0){
364
input_encoding = ENC_ISO8859_5;
365
} else if (strcmp(argv[0], "-russian") == 0){
366
input_encoding = ENC_ISO8859_5;
367
} else if (strcmp(argv[0], "-iso-8859-6") == 0){
368
input_encoding = ENC_ISO8859_6;
369
} else if (strcmp(argv[0], "-iso-8859-7") == 0){
370
input_encoding = ENC_ISO8859_7;
371
} else if (strcmp(argv[0], "-greek") == 0){
372
input_encoding = ENC_ISO8859_7;
373
} else if (strcmp(argv[0], "-iso-8859-8") == 0){
374
input_encoding = ENC_ISO8859_8;
375
} else if (strcmp(argv[0], "-hebrew") == 0){
376
input_encoding = ENC_ISO8859_8;
377
} else if (strcmp(argv[0], "-iso-8859-9") == 0){
378
input_encoding = ENC_ISO8859_9;
379
} else if (strcmp(argv[0], "-iso-2022-jp") == 0){
380
input_encoding = ENC_ISO2022_JP;
381
} else if (strcmp(argv[0], "-junet") == 0){
382
input_encoding = ENC_ISO2022_JP;
384
} else if (strcmp(argv[0], "-iso-2022-kr") == 0){
385
input_encoding = ENC_ISO2022_KR;
386
} else if (strcmp(argv[0], "-iso-2022-cn") == 0){
387
input_encoding = ENC_ISO2022_CN;
389
} else if (strcmp(argv[0], "-euc-jp") == 0){
390
input_encoding = ENC_EUC_JP1;
391
} else if (strcmp(argv[0], "-euc-jp1") == 0){
392
input_encoding = ENC_EUC_JP1;
393
} else if (strcmp(argv[0], "-euc-jp2") == 0){
394
input_encoding = ENC_EUC_JP2;
395
} else if (strcmp(argv[0], "-euc-kr") == 0){
396
input_encoding = ENC_EUC_KR;
397
} else if (strcmp(argv[0], "-euc-ch") == 0){
398
input_encoding = ENC_EUC_CH_GB;
399
} else if (strcmp(argv[0], "-euc-gb") == 0){
400
input_encoding = ENC_EUC_CH_GB;
401
} else if (strcmp(argv[0], "-euc-cns") == 0){
402
input_encoding = ENC_EUC_CH_CNS;
403
} else if (strcmp(argv[0], "-sjis") == 0){
404
input_encoding = ENC_SJIS;
405
} else if (strcmp(argv[0], "-l2r") == 0){
406
wdirection = WDIR_L2R;
407
} else if (strcmp(argv[0], "-r2l") == 0){
408
wdirection = WDIR_R2L;
409
} else if (strcmp(argv[0], "-pbm") == 0){
410
output_format = OFORM_PBM_ASCII;
411
} else if (strcmp(argv[0], "-pgm") == 0){
412
output_format = OFORM_PGM_RAW;
413
} else if (strcmp(argv[0], "-pbm-ascii") == 0){
414
output_format = OFORM_PBM_ASCII;
415
} else if (strcmp(argv[0], "-pgm-ascii") == 0){
416
output_format = OFORM_PGM_ASCII;
418
} else if (strcmp(argv[0], "-pbm-raw") == 0){
419
output_format = OFORM_PBM_RAW;
421
} else if (strcmp(argv[0], "-pgm-raw") == 0){
422
output_format = OFORM_PGM_RAW;
423
} else if (strcmp(argv[0], "-eps") == 0){
424
output_format = OFORM_EPS;
425
} else if (strcmp(argv[0], "-eps-ptsize") == 0){
426
if ((eps_ptsize = atof(argv[1])) <= 0)
427
eps_ptsize = DEFAULT_EPS_POINT_SIZE;
429
} else if (strcmp(argv[0], "-ascii-art") == 0){
430
output_format = OFORM_ASCII_ART;
431
} else if (strcmp(argv[0], "-ascii-art-h") == 0){
432
output_format = OFORM_ASCII_ART;
433
} else if (strcmp(argv[0], "-ascii-art-v") == 0){
434
output_format = OFORM_ASCII_ART_V;
435
} else if (strcmp(argv[0], "-none") == 0){
436
output_format = OFORM_NONE;
437
} else if (strcmp(argv[0], "-s") == 0){
438
shrink_factor = atoi(argv[1]);
440
if (shrink_factor <= 0){
441
PR1("Shrink factor is too small. ");
444
if (shrink_factor > 8){
445
PR1("Shrink factor is too large. ");
448
} else if (strcmp(argv[0], "-tab") == 0){
449
tab_skip = atof(argv[1]);
451
} else if (strcmp(argv[0], "-pw") == 0){
452
page_width = atoi(argv[1]);
454
} else if (strcmp(argv[0], "-ph") == 0){
455
page_height = atoi(argv[1]);
457
} else if (strcmp(argv[0], "-flush-left") == 0){
458
line_typeset = LINE_FLUSH_LEFT;
459
image_position_h = VF_IMAGEOUT_POSITION_LEFT;
460
} else if (strcmp(argv[0], "-flush-right") == 0){
461
line_typeset = LINE_FLUSH_RIGHT;
462
image_position_h = VF_IMAGEOUT_POSITION_RIGHT;
463
} else if (strcmp(argv[0], "-center") == 0){
464
line_typeset = LINE_CENTER;
465
image_position_h = VF_IMAGEOUT_POSITION_CENTER;
466
image_position_v = VF_IMAGEOUT_POSITION_CENTER;
467
} else if (strcmp(argv[0], "-center-line") == 0){
468
line_typeset = LINE_CENTER;
469
} else if (strcmp(argv[0], "-left-line") == 0){
470
line_typeset = LINE_FLUSH_LEFT;
471
} else if (strcmp(argv[0], "-right-line") == 0){
472
line_typeset = LINE_FLUSH_RIGHT;
473
} else if (strcmp(argv[0], "-center-image") == 0){
474
image_position_h = VF_IMAGEOUT_POSITION_CENTER;
475
image_position_v = VF_IMAGEOUT_POSITION_CENTER;
476
} else if (strcmp(argv[0], "-h-center-image") == 0){
477
image_position_h = VF_IMAGEOUT_POSITION_CENTER;
478
} else if (strcmp(argv[0], "-v-center-image") == 0){
479
image_position_v = VF_IMAGEOUT_POSITION_CENTER;
480
} else if (strcmp(argv[0], "-left-image") == 0){
481
image_position_h = VF_IMAGEOUT_POSITION_LEFT;
482
} else if (strcmp(argv[0], "-right-image") == 0){
483
image_position_h = VF_IMAGEOUT_POSITION_RIGHT;
484
} else if (strcmp(argv[0], "-top-image") == 0){
485
image_position_v = VF_IMAGEOUT_POSITION_TOP;
486
} else if (strcmp(argv[0], "-bottom-image") == 0){
487
image_position_v = VF_IMAGEOUT_POSITION_BOTTOM;
488
} else if (strcmp(argv[0], "-ds") == 0){
490
} else if (strcmp(argv[0], "-dr2l") == 0){
492
} else if (strcmp(argv[0], "-df") == 0){
494
} else if (strcmp(argv[0], "-dbc") == 0){
495
debug_char_bitmap = 1;
496
} else if (strcmp(argv[0], "-dbl") == 0){
497
debug_line_bitmap = 1;
498
} else if (strcmp(argv[0], "-dbp") == 0){
499
debug_page_bitmap = 1;
500
} else if (strcmp(argv[0], "-dvflib") == 0){
502
} else if (strcmp(argv[0], "-dall") == 0){
506
debug_char_bitmap = 1;
507
debug_line_bitmap = 1;
508
debug_page_bitmap = 1;
510
} else if (strcmp(argv[0], "-font-list") == 0){
513
} else if (strcmp(argv[0], "-h") == 0){
515
} else if (strcmp(argv[0], "-help") == 0){
517
} else if (strcmp(argv[0], "-more-help") == 0){
519
} else if (strcmp(argv[0], "-version") == 0){
520
printf("%s %s\n", PROG_NAME, VERSION);
523
printf("Unknown option: %s\n", *argv);
536
PR3("%s --- %s\n", PROG_NAME,
537
"Make a bitmap of multilingual text in compound text format");
538
PR2("Usage: %s [OPTIONS] [FILE]\n", PROG_NAME);
540
PR2(" -v FILE vflibcap file (default: %s)\n",
542
PR1(" -bbx generate a minimun image file\n");
543
PR1(" -ctext, -euc-jp, -euc-kr, -euc-ch\n");
544
PR1(" select encoding of input text (default: -ctext)\n");
546
PR1(" -iso-8859-1, -iso-8859-2, ..., -iso-8859-9, \n");
547
PR1(" -latin-1, -latin-2, ..., -latin-4, -greek, -hebrew, -cyrillic\n");
548
PR1(" select encoding of input text (1-byte encoding)\n");
550
PR1(" -times, -helv, -cour, -fixed\n");
551
PR1(" select times/helvetica/courie/fixed font family (default: times)\n");
552
PR1(" -normal, -bold, -italic\n");
553
PR1(" select normal/bold/italic font face\n");
554
PR1(" -14, -16, -18, -24\n");
555
PR2(" select 14-/16-/18-/24-dot font set (default: %d)\n",
556
(int)DEFAULT_PIXEL_SIZE);
557
PR1(" -scale PIXEL\n");
558
PR1(" select scalable font set and specify pixel size.\n");
560
PR1(" -center, -flush-left, -flush-right\n");
561
PR1(" Each line is centered or flushed left/right.\n");
562
PR1(" -l2r, -r2l\n");
563
PR1(" Select writing directionality left-to-right/right-to-left.\n");
564
PR2(" -b SKIP baseline skip (default: %.2f)\n",
565
(double)DEFAULT_BASELINESKIP);
567
PR1(" -pbm-ascii, -pgm-ascii, -pgm-raw, -eps, -ascii-art, -none\n");
568
PR1(" select output format (default: -pgm-ascii)\n");
570
PR1(" -eps-ptsize POINT\n");
571
PR1(" select point size of characters (EPS mode only)\n");
573
PR2(" -s N shrink factor for PGM output (default: %d)\n",
574
(int)DEFAULT_SHRINK);
576
PR1(" -g N vertical and horizontal margins in pixels\n");
578
PR1(" -gx N, -gy N\n");
579
PR1(" horizontal/vertical margin in pixels\n");
580
PR1(" -r reverse black and white\n");
581
PR2(" -tab N Tab skip (default: %d)\n", DEFAULT_TAB_SKIP);
582
PR1(" -font-list print list of defined fonts\n");
583
PR1(" -more-help print full descriptions of command line options\n");
585
PR1(" -ds Print state transision of a compound text parser\n");
586
PR1(" -df Print font open processes\n");
587
PR1(" -dr2l Print state transision of bi-directionality system\n"); PR1(" -dbc Print image of each chracter in ascii-art form\n");
588
PR1(" -dbl Print image of each line in ascii-art form\n");
589
PR1(" -dbp Print image of a page in ascii-art form\n");
596
make_text_bitmap(FILE *fp, char *title)
598
struct vf_s_bitmaplist the_page_buff;
601
VF_BitmapListInit(&the_page_buff);
603
parser(fp, &the_page_buff);
608
bm0 = VF_BitmapListCompose(&the_page_buff);
609
VF_BitmapListFinish(&the_page_buff);
611
if (minimum_image == 1){
612
bm = VF_MinimizeBitmap(bm0);
620
bm->off_y = bm->bbx_height;
621
bm->mv_x = bm->bbx_width;
624
if (debug_page_bitmap == 1)
627
switch (output_format){
629
case OFORM_PBM_ASCII:
630
VF_ImageOut_PBMAscii(bm, stdout, page_width, page_height,
631
image_position_h, image_position_v,
632
margin_x, margin_x, margin_y, margin_y,
633
pix_reverse, shrink_factor, "ctext2pgm", title);
635
case OFORM_PGM_ASCII:
636
VF_ImageOut_PGMAscii(bm, stdout, page_width, page_height,
637
image_position_h, image_position_v,
638
margin_x, margin_x, margin_y, margin_y,
639
pix_reverse, shrink_factor, "ctext2pgm", title);
646
VF_ImageOut_PGMRaw(bm, stdout, page_width, page_height,
647
image_position_h, image_position_v,
648
margin_x, margin_x, margin_y, margin_y,
649
pix_reverse, shrink_factor, "ctext2pgm", title);
652
VF_ImageOut_EPS(bm, stdout, page_width, page_height,
653
image_position_h, image_position_v,
654
margin_x, margin_x, margin_y, margin_y,
655
pix_reverse, shrink_factor, "ctext2pgm", title,
656
eps_ptsize, (pixel!=0) ? pixel : xpixel);
658
case OFORM_ASCII_ART:
659
VF_ImageOut_ASCIIArt(bm, stdout, page_width, page_height,
660
image_position_h, image_position_v,
661
margin_x, margin_x, margin_y, margin_y,
662
pix_reverse, shrink_factor);
664
case OFORM_ASCII_ART_V:
665
VF_ImageOut_ASCIIArtV(bm, stdout, page_width, page_height,
666
image_position_h, image_position_v,
667
margin_x, margin_x, margin_y, margin_y,
668
pix_reverse, shrink_factor);
677
parser(FILE *fp, VF_BITMAPLIST page_buff)
679
int chlen, chmask, ch, ch1, ch2, ch3, ch4;
680
long code_point, last_code_point;
682
int v_pos_x, v_pos_y, lineskip;
684
VF_BITMAPLIST line_buff;
691
lineskip = - pixel * baselineskip * magy;
693
lineskip = - xpixel * baselineskip * magy;
698
dir_stack[dir_sp].dir = wdirection;
699
dir_stack[dir_sp].h_pos_x = 0;
700
dir_stack[dir_sp].h_pos_y = 0;
701
VF_BitmapListInit(&dir_stack[dir_sp].the_line_buff);
703
line_buff = &dir_stack[dir_sp].the_line_buff;
706
while ((ch = getc(fp)) != EOF){
711
if (debug_state == 1)
712
printf("Code point: 0x%02x\n", ch);
713
p = tab_skip * ((pixel != 0) ? pixel : xpixel);
714
if ((dir_stack[dir_sp].h_pos_x >= 0)
715
&& (dir_stack[dir_sp].dir == WDIR_L2R)){
716
dir_stack[dir_sp].h_pos_x
717
= ((dir_stack[dir_sp].h_pos_x / p) + 1) * p;
719
dir_stack[dir_sp].h_pos_x
720
= ((dir_stack[dir_sp].h_pos_x / p) - 1) * p;
725
} else if (ch == 0x0d){
729
} else if (ch == 0x0a){
731
parser_eol(&line_buff, page_buff, v_pos_x, v_pos_y);
734
dir_stack[dir_sp].h_pos_x = 0;
735
dir_stack[dir_sp].h_pos_y = 0;
738
} else if ((use_esc == 1) && (ch == 0x1b)){
739
if ((ch1 = getc(fp)) == EOF)
741
if ((ch2 = getc(fp)) == EOF)
743
if (debug_state == 1)
744
printf("Escape Sequence: %02x %02x %02x\n", 0x1b, ch1, ch2);
747
fprintf(stderr, "Parsing Error: %02x %02x %02x\n", 0x1b, ch1, ch2);
750
type_g[0] = TYPEID94;
751
charset_g[0] = CSID(TYPEID94,ch2);
753
current_wdir_g[0] = charset_wdirection(charset_g[0]);
754
if (debug_state == 1)
755
printf("Designate a 94 charset \"%s\" to G0, G0 is invoked to GL\n",
756
charset_name(charset_g[0], "???"));
761
type_g[1] = TYPEID94;
762
charset_g[1] = CSID(TYPEID94,ch2);
764
current_wdir_g[1] = charset_wdirection(charset_g[1]);
765
if (debug_state == 1)
766
printf("Designate a 94 charset \"%s\" to G1, G1 is invoked to GR\n",
767
charset_name(charset_g[1], "???"));
772
type_g[1] = TYPEID96;
773
charset_g[1] = CSID(TYPEID96,ch2);
775
current_wdir_g[1] = charset_wdirection(charset_g[1]);
776
if (debug_state == 1)
777
printf("Designate a 96 charset \"%s\" to G1, G1 is invoked to GR\n",
778
charset_name(charset_g[1], "???"));
782
case 0x24: /* Designate a 94^n charset to G0 or G1 */
785
/* XXX: support for 94^2 charsets only */
786
if ((ch3 = getc(fp)) == EOF)
788
type_g[0] = TYPEID94_2;
789
charset_g[0] = CSID(TYPEID94_2,ch3);
791
current_wdir_g[0] = charset_wdirection(charset_g[0]);
792
if (debug_state == 1)
793
printf("Designate a 94^2 charset \"%s\" to G0, "
794
"G0 is invoked to GL\n",
795
charset_name(charset_g[0], "???"));
800
/* XXX: support for 94^2 charsets only */
801
if ((ch3 = getc(fp)) == EOF)
803
type_g[1] = TYPEID94_2;
804
charset_g[1] = CSID(TYPEID94_2,ch3);
806
current_wdir_g[1] = charset_wdirection(charset_g[1]);
807
if (debug_state == 1)
808
printf("Designate a 94^2 charset \"%s\" to G1, "
809
"G1 is invoked to GR\n",
810
charset_name(charset_g[1], "???"));
814
case 0x40: /* JIS C6226-1978 */
815
case 0x41: /* GB 2312 */
816
case 0x42: /* JIS X 0208 */
817
/* XXX: support for 2-byte charsets only */
818
type_g[0] = TYPEID94_2;
819
charset_g[0] = CSID(TYPEID94_2,ch2);
821
current_wdir_g[0] = charset_wdirection(charset_g[0]);
822
if (debug_state == 1)
823
printf("Designate a 94^2 charset \"%s\" to G0, "
824
"G0 is invoked to GL\n",
825
charset_name(charset_g[0], "???"));
834
printf("Charset directionality: %s %s\n",
835
charset_name(charset_g[g], "???"),
836
(charset_g[g]==WDIR_L2R)?"left-to-right":"right-to-left");
837
parser_check_wdir(g, &line_buff);
842
} else if ((use_si == 1) && (ch == 0x0f)){
846
} else if ((use_so == 1) && (ch == 0x0e)){
850
} else if ((use_csi == 1) && (ch == 0x9b)){
851
if ((ch1 = getc(fp)) == EOF)
854
case 0x31: /* begin left-to-right text */
855
if ((ch2 = getc(fp)) == EOF)
859
if ((debug_r2l == 1) || (debug_state == 1))
860
printf("Begin left-to-right string\n");
861
parser_wdir_push(WDIR_L2R, &line_buff);
863
case 0x32: /* begin right-to-left text */
864
if ((ch2 = getc(fp)) == EOF)
868
if ((debug_r2l == 1) || (debug_state == 1))
869
printf("Begin right-to-left string\n");
870
parser_wdir_push(WDIR_R2L, &line_buff);
872
case 0x5d: /* end of string */
873
if ((debug_r2l == 1) || (debug_state == 1))
874
printf("End of string\n");
875
parser_wdir_pop(&line_buff);
883
if (use_sjis == 0){ /* non-sjis encodings */
884
if ((use_ss2 == 1) && (ch == 0x8e)){
887
chlen = chlen_g[2] + 1;
890
} else if ((use_ss3 == 1) && (ch == 0x8f)){
893
chlen = chlen_g[3] + 1;
897
code_point = (long) ch;
898
chlen = ((code_point & 0x80) == 0) ? chlen_g[0] : chlen_g[1];
899
chmask = (chlen >= 2) ? 0x7f : 0xff;
900
g = ((code_point & 0x80) == 0) ? 0 : 1;
902
code_point = code_point & chmask;
903
for (i = 1; i < chlen; i++){
904
if ((ch = getc(fp)) == EOF)
906
code_point = code_point * 256 + (long)(ch & chmask);
908
} else { /* sjis encoding */
910
if (((ch1 >= 129) && (ch1 <= 159)) || ((ch1 >= 224) && (ch1 <=239))){
911
/* 1st byte of Kanji */
912
if ((ch2 = getc(fp)) == EOF)
914
if ((ch2 >= 64) && (ch2 <= 252)){
915
/* 2nd byte of Kanji */
916
ch3 = (((ch1 - ((ch1<160)?112:176)) << 1) - ((ch2<159)?1:0));
917
ch4 = ch2 - ((ch2<159) ? (ch2>127?32:31) : 126);
918
code_point = ch3 * 256 + ch4;
922
} else if ((ch >= 161) && (ch <= 223)){
924
code_point = (long) ch;
928
code_point = (long) ch;
933
if (last_code_point != (long)'\\'){
934
/* characters to be printed or backslash */
935
if (code_point != (long)'\\'){
938
if (debug_state == 1){
939
if ((0x20 <= code_point) && (code_point < 0x7e)){
940
printf("Code point: 0x%lx '%c' (G%d)\n",
941
code_point, (int)code_point, g);
943
printf("Code point: 0x%lx (G%d)\n", code_point, g);
946
parser_check_wdir(g, &line_buff);
947
draw_char(code_point, line_buff, g,
948
&dir_stack[dir_sp].h_pos_x, &dir_stack[dir_sp].h_pos_y);
951
/* a command by backslash */
952
last_code_point = code_point;
956
/* backslash command */
957
parser_cmd(code_point, line_buff, &charset_saved, g,
958
&dir_stack[dir_sp].h_pos_x, &dir_stack[dir_sp].h_pos_y);
965
if (nchars_in_line > 0) /* the last line does not end by '\n' char */
966
parser_eol(&line_buff, page_buff, v_pos_x, v_pos_y);
970
parser_eol(VF_BITMAPLIST *line_buff_p, VF_BITMAPLIST page_buff,
971
int vposx, int vposy)
977
parser_wdir_pop(line_buff_p);
978
if ((line_bm = VF_BitmapListCompose(*line_buff_p)) == NULL){
982
if (debug_line_bitmap == 1)
983
VF_DumpBitmap(line_bm);
984
VF_BitmapListFinish(*line_buff_p);
986
switch (line_typeset){
991
case LINE_FLUSH_LEFT:
992
if (wdirection == WDIR_R2L)
993
swap_refpt_nextpt(line_bm);
996
case LINE_FLUSH_RIGHT:
997
if (wdirection == WDIR_L2R){
998
swap_refpt_nextpt(line_bm);
1001
x = vposx - line_bm->bbx_width;
1005
x = vposx - line_bm->bbx_width/2;
1008
VF_BitmapListPut(page_buff, line_bm, x, vposy);
1013
parser_check_wdir(int i, VF_BITMAPLIST *line_buff_p)
1015
if ((i < 0) || (1 < i))
1019
printf("dir_stack[%d].dir=%s, current_wdir_g[%d]=%d\n",
1020
dir_sp, (dir_stack[dir_sp].dir==WDIR_L2R)?"WDIR_L2R":"WDIR_R2L",
1021
i, current_wdir_g[i]);
1023
if (dir_stack[dir_sp].dir != current_wdir_g[i]){
1024
if (current_wdir_g[i] != wdirection){
1025
if (current_wdir_g[i] == WDIR_L2R){
1027
printf("Change directionality to left-to-right mode\n");
1028
parser_wdir_push(WDIR_L2R, line_buff_p);
1031
printf("Change directionality to right-to-left mode\n");
1032
parser_wdir_push(WDIR_R2L, line_buff_p);
1036
printf("End of directionality change\n");
1037
parser_wdir_pop(line_buff_p);
1043
parser_wdir_push(int wdir, VF_BITMAPLIST *line_buff_p)
1045
if ((wdirection == WDIR_R2L)
1046
&& (dir_sp == 1) && (wdir == WDIR_R2L)){
1047
/* darty trick for right-to-left text */
1048
parser_wdir_do_pop(line_buff_p);
1050
parser_wdir_do_push(wdir, line_buff_p);
1055
parser_wdir_pop(VF_BITMAPLIST *line_buff_p)
1057
if ((wdirection == WDIR_R2L)
1058
&& (dir_sp == 0) && (dir_stack[dir_sp].dir == WDIR_R2L)){
1059
/* darty trick for right-to-left text */
1060
parser_wdir_do_push(WDIR_L2R, line_buff_p);
1062
parser_wdir_do_pop(line_buff_p);
1067
parser_wdir_do_push(int wdir, VF_BITMAPLIST *line_buff_p)
1072
dir_stack[dir_sp].dir = wdir;
1073
dir_stack[dir_sp].h_pos_x = 0;
1074
VF_BitmapListInit(&dir_stack[dir_sp].the_line_buff);
1075
*line_buff_p = &dir_stack[dir_sp].the_line_buff;
1077
if (debug_r2l == 1){
1078
printf("Push to dir_stack\n");
1079
for (s = dir_sp; s >= 0; s--){
1080
printf(" dir_stack[%d].dir=%s\n",
1081
s, (dir_stack[s].dir==WDIR_L2R)?"WDIR_L2R":"WDIR_R2L");
1087
parser_wdir_do_pop(VF_BITMAPLIST *line_buff_p)
1090
VF_BITMAP inline_bm;
1092
inline_bm = VF_BitmapListCompose(&dir_stack[dir_sp].the_line_buff);
1094
*line_buff_p = &dir_stack[dir_sp].the_line_buff;
1096
if (debug_r2l == 1){
1097
printf("Pop dir_stack\n");
1098
for (s = dir_sp; s >= 0; s--){
1099
printf(" dir_stack[%d].dir=%s\n",
1100
s, (dir_stack[s].dir==WDIR_L2R)?"WDIR_L2R":"WDIR_R2L");
1102
printf("current_wdir_g[0]=%s, current_wdir_g[1]=%s\n",
1103
(current_wdir_g[0]==WDIR_L2R)?"WDIR_L2R":"WDIR_R2L",
1104
(current_wdir_g[1]==WDIR_L2R)?"WDIR_L2R":"WDIR_R2L");
1108
VF_DumpBitmap(inline_bm);
1109
if (dir_stack[dir_sp].dir != dir_stack[dir_sp+1].dir)
1110
swap_refpt_nextpt(inline_bm);
1112
VF_DumpBitmap(inline_bm);
1114
put_bitmap(*line_buff_p, inline_bm, dir_stack[dir_sp].dir,
1115
&dir_stack[dir_sp].h_pos_x, &dir_stack[dir_sp].h_pos_y);
1119
charset_wdirection(int charset)
1124
case CS_ISO8859_6: /* Latin/Arabic */
1125
case CS_ISO8859_8: /* Latin/Hebrew */
1126
case CS_MULE_ARAB1: /* Mule Arabic 1 */
1127
case CS_MULE_ARAB2: /* Mule Arabic 2 */
1130
case CS_MULE_ARAB0: /* Mule Arabic 0 */
1141
draw_char(long code_point, VF_BITMAPLIST buff, int i, int *posxp, int *posyp)
1145
if ((font_exists_g[i] == 1) && (font_info[current_font_g[i]].font_id >= 0)){
1147
code_point = cp_conv(code_point, i);
1149
if (debug_vflib == 1){
1150
printf("VF_GetBitmap2(%d, 0x%lx, 1, 1);\n",
1151
font_info[current_font_g[i]].font_id, code_point);
1153
if ((bm = VF_GetBitmap2(font_info[current_font_g[i]].font_id,
1154
code_point, 1, 1)) == NULL){
1155
PR3("Cannot get bitmap 0x%lx of font %s\n",
1156
code_point, font_info[current_font_g[i]].font_name);
1157
*posxp = *posxp + ((pixel != 0)?pixel:xpixel)/2;
1159
if (current_reverse == 1)
1161
if ((current_wdir_g[i] == WDIR_R2L) && (bm->mv_x > 0))
1162
swap_refpt_nextpt(bm);
1163
if (debug_char_bitmap == 1)
1165
put_bitmap(buff, bm, current_wdir_g[i], posxp, posyp);
1171
cp_conv(long code_point, int i)
1174
static int tbl_mule_visvii_l[] = {
1175
0,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
1176
176,177,178, 0, 0,181,182,183,184, 0, 0, 0, 0,189,190, 0,
1177
0, 0, 0, 0, 0, 0,198,199, 0, 0, 0, 0, 0, 0, 0,207,
1178
0,209, 0, 0, 0,213,214,215,216, 0, 0,219,220, 0,222,223,
1179
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
1180
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254, 0
1182
static int tbl_mule_visvii_u[] = {
1183
0,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
1184
144,145,146, 0, 0,147,150,151,152, 0, 0, 0, 0,180,149, 0,
1185
0, 0, 0, 0, 0, 0, 2, 5, 0, 0, 0, 0, 0, 0, 0,159,
1186
0,186, 0, 0, 0,128, 20,187,188, 0, 0, 25, 30, 0,179,191,
1187
192,193,194,195,196,197,255, 6,200,201,202,203,204,205,206,155,
1188
208,185,210,211,212,160,153,154,158,217,218,157,156,221,148, 0
1191
r0 = code_point % 0x100;
1192
r1 = code_point / 0x100;
1194
switch (font_info[current_font_g[i]].charset_id){
1205
case CS_MULE_BIG5_L1:
1206
case CS_MULE_BIG5_L2:
1207
r0 = (r1 - 0x21) * 94 + (r0 - 0x21);
1208
r1 = (r0 / 157) + 0xa1;
1214
if (font_info[current_font_g[i]].charset_id == CS_MULE_BIG5_L2)
1217
case CS_MULE_ETHIOPIC:
1218
r1 = (r1 - 33) * 94;
1219
r0 = (r0 - 33) + r1;
1222
} else if (r0 < 448){
1230
case CS_MULE_VISCII_L:
1233
r0 = tbl_mule_visvii_l[r0 - 160];
1235
case CS_MULE_VISCII_U:
1238
r0 = tbl_mule_visvii_u[r0 - 160];
1242
return r1 * 0x100 + r0;
1246
put_bitmap(VF_BITMAPLIST buff, VF_BITMAP bm, int wdir, int *posxp, int *posyp)
1248
VF_BitmapListPut(buff, bm, *posxp, *posyp);
1254
reverse_bitmap(VF_BITMAP bm)
1257
unsigned char *p, w;
1258
static unsigned char bits[] = {
1259
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
1265
b = bm->bbx_width / 8;
1266
m = bm->bbx_width % 8;
1268
for (y = 0; y < bm->bbx_height; y++){
1269
p = &bm->bitmap[y * bm->raster];
1270
for (x = 0; x < b; x++){
1279
for (y = 0; y < bm->bbx_height; y++){
1287
swap_refpt_nextpt(VF_BITMAP bm)
1292
offx = bm->off_x - bm->mv_x;
1293
offy = bm->off_y - bm->mv_y;
1303
void parser_cmd(long code_point, VF_BITMAPLIST buff, int *charset_saved_p,
1304
int g, int *posxp, int *posyp)
1306
switch ((char)code_point){
1308
PR2("Unknown command: \\%c\n", (char)code_point);
1311
parser_check_wdir(g, &buff);
1312
draw_char((long)'\\', buff, 0, posxp, posyp);
1316
current_family = default_family;
1317
current_face = default_face;
1319
case 'd': current_family = default_family; break;
1320
case 'f': current_family = FAM_FIXED; break;
1321
case 't': current_family = FAM_TIMES; break;
1322
case 'h': current_family = FAM_HELV; break;
1323
case 'c': current_family = FAM_COUR; break;
1324
case 'D': current_face = default_face; break;
1325
case 'N': current_face = FACE_NORMAL; break;
1326
case 'B': current_face = FACE_BOLD; break;
1327
case 'I': current_face = FACE_ITALIC; break;
1328
case '(': current_reverse = 1; break;
1329
case ')': current_reverse = 0; break;
1330
/* \< and \> commands swicthes fonts to iso8859-1 font */
1331
/* This is effective (but ad-hoc) if looks of fonts of GL and */
1332
/* GR are different. */
1333
case '<': /* switch to a iso8859-1 font */
1334
*charset_saved_p = charset_g[0];
1335
charset_g[0] = CS_ISO8859_1;
1336
if (debug_state == 1)
1337
printf("Use iso8859-1 font temporarily\n");
1339
case '>': /* switch back to the original */
1340
charset_g[0] = *charset_saved_p;
1341
if (debug_state == 1)
1342
printf("Go back to the original font\n");
1362
/* search an exact font */
1363
for (j = 0; font_info[j].charset_id >= 0; j++){
1364
if ( (font_info[j].pixel_size == pixel)
1365
&& (font_info[j].charset_id == charset_g[i])
1366
&& (font_info[j].family_id == current_family)
1367
&& (font_info[j].face_id == current_face)){
1368
if (try_font_open(j) >= 0){
1374
/* search a font of the default face */
1376
&& (current_face != default_face)){
1377
for (j = 0; font_info[j].charset_id >= 0; j++){
1378
if ( (font_info[j].pixel_size == pixel)
1379
&& (font_info[j].charset_id == charset_g[i])
1380
&& (font_info[j].family_id == current_family)
1381
&& (font_info[j].face_id == default_face)){
1382
if (try_font_open(j) >= 0){
1389
/* search a font of the default face */
1391
&& (current_face != FACE_DEFAULT)
1392
&& (default_face != FACE_DEFAULT)){
1393
for (j = 0; font_info[j].charset_id >= 0; j++){
1394
if ( (font_info[j].pixel_size == pixel)
1395
&& (font_info[j].charset_id == charset_g[i])
1396
&& (font_info[j].family_id == current_family)
1397
&& (font_info[j].face_id == FACE_DEFAULT)){
1398
if (try_font_open(j) >= 0){
1405
/* search a font of default face and default family */
1407
&& (current_family != default_family)){
1408
for (j = 0; font_info[j].charset_id >= 0; j++){
1409
if ( (font_info[j].pixel_size == pixel)
1410
&& (font_info[j].charset_id == charset_g[i])
1411
&& (font_info[j].family_id == default_family)
1412
&& (font_info[j].face_id == FACE_DEFAULT)){
1413
if (try_font_open(j) >= 0){
1420
/* search a font of default face of default family */
1422
&& (current_family != FAM_DEFAULT)
1423
&& (default_family != FAM_DEFAULT)){
1424
for (j = 0; font_info[j].charset_id >= 0; j++){
1425
if ( (font_info[j].pixel_size == pixel)
1426
&& (font_info[j].charset_id == charset_g[i])
1427
&& (font_info[j].family_id == FAM_DEFAULT)
1428
&& (font_info[j].face_id == FACE_DEFAULT)){
1429
if (try_font_open(j) >= 0){
1436
/* search any font of the charset */
1438
for (j = 0; font_info[j].charset_id >= 0; j++){
1439
if ( (font_info[j].pixel_size == pixel)
1440
&& (font_info[j].charset_id == charset_g[i])){
1441
if (try_font_open(j) >= 0){
1451
font_exists_g[i] = 0; /* NO FONT */
1452
current_font_g[i] = 0;
1453
PR2("No font for %s\n", charset_name(charset_g[i], "???"));
1455
font_exists_g[i] = 1;
1456
current_font_g[i] = opened;
1457
if (debug_state == 1)
1458
printf("** Charset: %s\n", charset_name(charset_g[i], "???"));
1463
try_font_open(int table_index)
1465
if (debug_font == 1)
1466
printf("Try font open: %s", font_info[table_index].font_name);
1468
switch (font_info[table_index].font_id){
1470
if (debug_vflib == 1){
1471
printf("VF_OpenFont2(\"%s\", %d, %.3f, %.3f);\n",
1472
font_info[table_index].font_name, xpixel, magx, magy);
1474
font_info[table_index].font_id
1475
= VF_OpenFont2(font_info[table_index].font_name, xpixel, magx, magy);
1476
if (debug_vflib == 1)
1477
printf(" VFlib font ID = %d\n", font_info[table_index].font_id );
1478
if (font_info[table_index].font_id < 0){
1479
font_info[table_index].font_id = NOT_FOUND;
1480
if (debug_font == 1)
1481
printf("... cannot open\n");
1484
if (debug_font == 1)
1485
printf("... successfully opened!\n");
1488
if (debug_font == 1)
1489
printf("... could not opened before\n");
1492
if (debug_font == 1)
1493
printf("... opened before\n");
1497
if (debug_font == 1)
1498
printf("Font switch: %s\n", font_info[table_index].font_name);
1507
for (i = 0; i < 4; i++){
1508
font_exists_g[i] = 0; /* font does not exist */
1509
type_g[i] = TYPEID94;
1510
charset_g[i] = CS_ISO8859_1;
1514
/* Default values */
1526
switch (input_encoding){
1531
/* Designate ISO8859-1 into G0 */
1532
type_g[0] = TYPEID94;
1533
charset_g[0] = CS_ISO8859_1;
1536
/* Designate right-hand of ISO Latin-1 into G1 */
1537
type_g[1] = TYPEID96;
1538
charset_g[1] = CS_ISO8859_1;
1544
/* Designate ISO8859-1 into G0 */
1545
type_g[0] = TYPEID94;
1546
charset_g[0] = CS_ISO8859_1;
1549
/* Designate right-hand of ISO Latin-1 into G1 */
1550
type_g[1] = TYPEID96;
1551
charset_g[1] = CS_ISO8859_1;
1557
/* Designate ISO8859-2 into G0 */
1558
type_g[0] = TYPEID94;
1559
charset_g[0] = CS_ISO8859_2;
1562
/* Designate right-hand of ISO8859-1 into G1 */
1563
type_g[1] = TYPEID96;
1564
charset_g[1] = CS_ISO8859_2;
1570
/* Designate ISO8859-3 into G0 */
1571
type_g[0] = TYPEID94;
1572
charset_g[0] = CS_ISO8859_3;
1575
/* Designate right-hand of ISO8859-2 into G1 */
1576
type_g[1] = TYPEID96;
1577
charset_g[1] = CS_ISO8859_2;
1583
/* Designate ISO8859-4 into G0 */
1584
type_g[0] = TYPEID94;
1585
charset_g[0] = CS_ISO8859_4;
1588
/* Designate right-hand of ISO8859-4 into G1 */
1589
type_g[1] = TYPEID96;
1590
charset_g[1] = CS_ISO8859_4;
1594
case ENC_ISO8859_5: /* Cryillic */
1596
/* Designate ISO8859-1 into G0 */
1597
type_g[0] = TYPEID94;
1598
charset_g[0] = CS_ISO8859_1;
1601
/* Designate right-hand of ISO8859-5 into G1 */
1602
type_g[1] = TYPEID96;
1603
charset_g[1] = CS_ISO8859_5;
1607
case ENC_ISO8859_6: /* Arabic */
1609
wdirection = WDIR_R2L;
1610
/* Designate ISO8859-1 into G0 */
1611
type_g[0] = TYPEID94;
1612
charset_g[0] = CS_ISO8859_1;
1615
/* Designate right-hand of ISO8859-6 into G1 */
1616
type_g[1] = TYPEID96;
1617
charset_g[1] = CS_ISO8859_6;
1621
case ENC_ISO8859_7: /* Greek */
1623
/* Designate ISO8859-1 into G0 */
1624
type_g[0] = TYPEID94;
1625
charset_g[0] = CS_ISO8859_1;
1628
/* Designate right-hand of ISO8859-7 into G1 */
1629
type_g[1] = TYPEID96;
1630
charset_g[1] = CS_ISO8859_7;
1634
case ENC_ISO8859_8: /* Hebrew */
1636
wdirection = WDIR_R2L;
1637
/* Designate ISO8859-1 into G0 */
1638
type_g[0] = TYPEID94;
1639
charset_g[0] = CS_ISO8859_1;
1642
/* Designate right-hand of ISO8859-8 into G1 */
1643
type_g[1] = TYPEID96;
1644
charset_g[1] = CS_ISO8859_8;
1650
/* Designate ISO8859-9 into G0 */
1651
type_g[0] = TYPEID94;
1652
charset_g[0] = CS_ISO8859_9;
1655
/* Designate right-hand of ISO8859-9 into G1 */
1656
type_g[1] = TYPEID96;
1657
charset_g[1] = CS_ISO8859_9;
1661
case ENC_ISO2022_JP:
1663
/* Designate ASCII into G0 */
1664
type_g[0] = TYPEID94;
1665
charset_g[0] = CS_ASCII;
1670
case ENC_ISO2022_KR:
1674
/* Designate ASCII into G0 */
1675
type_g[0] = TYPEID94;
1676
charset_g[0] = CS_ASCII;
1679
/* Designate KSC5601 into G1 */
1680
type_g[1] = TYPEID94_2;
1681
charset_g[1] = CS_KSC5601;
1685
case ENC_ISO2022_CN:
1693
/* Designate ASCII into G0 */
1694
type_g[0] = TYPEID94;
1695
charset_g[0] = CS_ASCII;
1707
if (input_encoding == ENC_EUC_JP1){
1708
/* Designate JIS X0201 into G0 (code set 0) */
1709
type_g[0] = TYPEID94;
1710
charset_g[0] = CS_JISX0201R;
1714
/* Designate ISO8859-1 into G0 (code set 0) */
1715
type_g[0] = TYPEID94;
1716
charset_g[0] = CS_ISO8859_1;
1720
/* Designate JIS X0208 into G1 (code set 1) */
1721
type_g[1] = TYPEID94_2;
1722
charset_g[1] = CS_JISX0208;
1725
/* Designate JIS X0208 into G2 (code set 2) */
1726
type_g[2] = TYPEID94;
1727
charset_g[2] = CS_JISX0201K;
1730
/* Designate JIS X0212 into G3 (code set 3) */
1731
type_g[3] = TYPEID94_2;
1732
charset_g[3] = CS_JISX0212;
1738
/* Designate ISO8859-1 into G0 (code set 0) */
1739
type_g[0] = TYPEID94;
1740
charset_g[0] = CS_ISO8859_1;
1743
/* Designate KSC5601 into G1 (code set 1) */
1744
type_g[1] = TYPEID94_2;
1745
charset_g[1] = CS_KSC5601;
1751
/* Designate ISO8859-1 into G0 (code set 0) */
1752
type_g[0] = TYPEID94;
1753
charset_g[0] = CS_ISO8859_1;
1756
/* Designate GB2312 into G1 (code set 1) */
1757
type_g[1] = TYPEID94_2;
1758
charset_g[1] = CS_GB2312;
1762
case ENC_EUC_CH_CNS:
1767
/* Designate ISO8859-1 into G0 (code set 0) */
1768
type_g[0] = TYPEID94;
1769
charset_g[0] = CS_ISO8859_1;
1772
/* Designate CNS11643-1 into G1 (code set 1) */
1773
type_g[1] = TYPEID94_2;
1774
charset_g[1] = CS_CNS11643_1;
1777
/* Designate CNS11643-2 into G3 (code set 3) */
1778
type_g[3] = TYPEID94_2;
1779
charset_g[3] = CS_CNS11643_2;
1787
/* JISX0201 Roman into G0 */
1788
type_g[0] = TYPEID94;
1789
charset_g[0] = CS_JISX0201R;
1792
/* JISX0208 into G1 */
1793
type_g[1] = TYPEID94_2;
1794
charset_g[1] = CS_JISX0208;
1797
/* JISX0201 Kana into G2 */
1798
type_g[2] = TYPEID94;
1799
charset_g[2] = CS_JISX0201K;
1804
fprintf(stderr, "Input encoding is unknown.\n");
1808
for (i = 0; i < 4; i++){
1809
current_wdir_g[i] = charset_wdirection(charset_g[i]);
1814
charset_name(int charset, char *if_unknown)
1821
case CS_ASCII: name = "ASCII"; break;
1822
case CS_ISO8859_1: name = "ISO 8859-1 (Latin-1)"; break;
1823
case CS_ISO8859_2: name = "ISO 8859-2 (Latin-2)"; break;
1824
case CS_ISO8859_3: name = "ISO 8859-3 (Latin-3)"; break;
1825
case CS_ISO8859_4: name = "ISO 8859-4 (Latin-4)"; break;
1826
case CS_ISO8859_5: name = "ISO 8859-5 (Cyrillic)"; break;
1827
case CS_ISO8859_6: name = "ISO 8859-6 (Arabic)"; break;
1828
case CS_ISO8859_7: name = "ISO 8859-7 (Greek)"; break;
1829
case CS_ISO8859_8: name = "ISO 8859-8 (Hebrew)"; break;
1830
case CS_ISO8859_9: name = "ISO 8859-9 (Latin-5)"; break;
1831
case CS_JISX0201R: name = "JIS X 0201-Roman"; break;
1832
case CS_JISX0201K: name = "JIS X 0201-Kana"; break;
1833
case CS_JISX0208: name = "JIS X 0208 (Japanese)"; break;
1834
case CS_JISX0212: name = "JIS X 0212 (Japanese)"; break;
1835
case CS_KSC5601: name = "KSC 5601 (Hangle)"; break;
1836
case CS_GB2312: name = "GB 2312 (Chinese)"; break;
1837
case CS_CNS11643_1: name = "CNS 11643-1 (Chinese)"; break;
1838
case CS_CNS11643_2: name = "CNS 11643-2 (Chinese)"; break;
1839
case CS_CNS11643_3: name = "CNS 11643-3 (Chinese)"; break;
1840
case CS_CNS11643_4: name = "CNS 11643-4 (Chinese)"; break;
1841
case CS_CNS11643_5: name = "CNS 11643-5 (Chinese)"; break;
1842
case CS_CNS11643_6: name = "CNS 11643-6 (Chinese)"; break;
1843
case CS_CNS11643_7: name = "CNS 11643-7 (Chinese)"; break;
1844
case CS_MULE_BIG5_L1: name = "BIG5 Level 1 (Chinese)"; break;
1845
case CS_MULE_BIG5_L2: name = "BIG5 Level 2 (Chinese)"; break;
1846
case CS_MULE_ARAB0: name = "Mule Arabic 0"; break;
1847
case CS_MULE_ARAB1: name = "Mule Arabic 1"; break;
1848
case CS_MULE_ARAB2: name = "Mule Arabic 2"; break;
1849
case CS_MULE_ETHIOPIC: name = "Mule Ethiopic"; break;
1850
case CS_MULE_VISCII_L: name = "Mule VISCII 1.1 Lower"; break;
1851
case CS_MULE_VISCII_U: name = "Mule VISCII 1.1 Upper"; break;
1857
#define FONTLIST_W_CHARSET 28
1858
#define FONTLIST_W_FAM_FACE 17
1859
#define FONTLIST_W_PIXEL 12
1860
#define FONTLIST_W_FONT -1
1864
show_font_list(void)
1866
char buff[80], *s1, *s2;
1869
wprint("Character Set Name", FONTLIST_W_CHARSET);
1870
wprint("Family&Face", FONTLIST_W_FAM_FACE);
1871
wprint("Pixel Size", FONTLIST_W_PIXEL);
1872
wprint("Font Name", FONTLIST_W_FONT);
1875
for (i = 0; font_info[i].charset_id >= 0; i++){
1878
sprintf(buff, "%s", charset_name(font_info[i].charset_id, "???"));
1879
wprint(buff, FONTLIST_W_CHARSET);
1881
/* font family & font face */
1882
switch (font_info[i].family_id){
1884
case FAM_FIXED: s1 = "Fixed"; break;
1885
case FAM_TIMES: s1 = "Times"; break;
1886
case FAM_HELV: s1 = "Helvetia"; break;
1887
case FAM_COUR: s1 = "Courier"; break;
1889
switch (font_info[i].face_id){
1891
case FACE_NORMAL: s2 = "Normal"; break;
1892
case FACE_ITALIC: s2 = "Italic"; break;
1893
case FACE_BOLD: s2 = "Bold"; break;
1895
sprintf(buff, "%s %s", s1, s2);
1896
wprint(buff, FONTLIST_W_FAM_FACE);
1899
if (font_info[i].pixel_size == 0)
1900
sprintf(buff, "%s", "scalable");
1902
sprintf(buff, "%d", font_info[i].pixel_size);
1903
wprint(buff, FONTLIST_W_PIXEL);
1906
wprint(font_info[i].font_name, FONTLIST_W_FONT);
1913
wprint(char *str, int w)
1924
for (i = 0; i < w; i++){