summaryrefslogtreecommitdiff
path: root/Build/source/texk/makejvf/main.c
blob: 132fb35b13acb514aac7681ae1f7ed65cc5306fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <kpathsea/config.h>
#include <ptexenc/ptexenc.h>
#include "makejvf.h"

FILE *vfp,*afp=NULL;
char *atfmname,*vtfmname,*afmname,*vfname,*kanatfm;
int kanatume=-1,chotai=0,baseshift=0,minute=0;

int main(int argc, char ** argv)
{
	int i,j;

	set_enc_string(NULL, "EUC");
	if (argc < 3) {
		usage();
		exit(0);
	}

	argv++;

	for (;**argv=='-';argv++) {
		switch ((*argv)[1]) {
		case 'k':
			if ((*argv)[2]!='\0') {
				kanatume = atoi(&(*argv)[2]);
			}
			else {
				kanatume = atoi(*(++argv));
			}
			break;
		case 'K':
			if ((*argv)[2]!='\0') {
				kanatfm = strdup(&(*argv)[2]);
			}
			else {
				kanatfm = strdup(*(++argv));
			}
			break;
		case 'C':
			chotai=1;
			break;
		case 'a':
			if ((*argv)[2]!='\0') {
				afmname = strdup(&(*argv)[2]);
			}
			else {
				afmname = strdup(*(++argv));
			}
			if ((afp = fopen(afmname,"r"))==NULL) {
				fprintf(stderr,"no AFM file, %s.\n",afmname);
				exit(-1);
			}
			break;
		case 'b':
			if ((*argv)[2]!='\0') {
				baseshift = atoi(&(*argv)[2]);
			}
			else {
				baseshift = atoi(*(++argv));
			}
			break;
		case 'm':
			minute=1;
			break;
		default:
			usage();
			exit(0);
		}
	}

	if (kanatume>=0 && !afp) {
		fprintf(stderr,"No AFM file for kanatume.\n");
		exit(-1);
	}

	atfmname = malloc(strlen(*argv)+4);
	strcpy(atfmname,*argv);

	vfname = malloc(strlen(*argv)+4);
	strcpy(vfname,*argv);
	for (i = strlen(vfname)-1 ; i >= 0 ; i--) {
		if (vfname[i] == '/') {
			vfname = &vfname[i+1];
			break;
		}
	}
	if (!strcmp(&vfname[strlen(vfname)-4],".tfm")) {
		vfname[strlen(vfname)-4] = '\0';
	}
	strcat(vfname,".vf");

	argv++;

	vtfmname = strdup(*argv);
	if (!strcmp(&vtfmname[strlen(vtfmname)-4],".tfm")) {
		vtfmname[strlen(vtfmname)-4] = '\0';
	}

	tfmget(atfmname);

	maketfm(vtfmname);

	if (kanatfm) {
		if (!strcmp(&kanatfm[strlen(kanatfm)-4],".tfm")) {
			kanatfm[strlen(kanatfm)-4] = '\0';
		}
		maketfm(kanatfm);
	}

	vfp = vfopen(vfname);

	for (i=0;i<94;i++)
		for (j=0;j<94;j++)
			writevf((0x21+i)*256+(0x21+j),vfp);

	vfclose(vfp);

	exit(0);
}

void usage(void)
{
	fputs2("MAKEJVF ver.1.1a -- make Japanese VF file.\n", stderr);
	fputs2("%% makejvf [<options>] <TFMfile> <PSfontTFM>\n", stderr);
	fputs2("options:\n", stderr);
	fputs2("-C           ĹÂΥ⡼¥É\n", stderr);
	fputs2("-K <TFMfile> Èó´Á»úÉôÍѤ˺îÀ®¤¹¤ëPS¥Õ¥©¥ó¥ÈTFM̾\n", stderr);
	fputs2("-b <¿ôÃÍ>    ¥Ù¡¼¥¹¥é¥¤¥óÊäÀµ\n", stderr);
	fputs2("             ʸ»ú¤Î¹â¤µ¤ò1000¤È¤·¤ÆÀ°¿ô¤Ç»ØÄê\n", stderr);
	fputs2("             ¥×¥é¥¹¤Çʸ»ú¤¬²¼¤¬¤ê¡¢¥Þ¥¤¥Ê¥¹¤Çʸ»ú¤¬¾å¤¬¤ë\n", stderr);
	fputs2("-m           ½Ä½ñ¤­»þ¤Ë¥¯¥ª¡¼¥È(¡Ç¡É)¤ÎÂå¤ï¤ê¤Ë¥ß¥Ë¥å¡¼¥È(¡ì¡í)¤ò»ÈÍÑ\n", stderr);
	fputs2("-a <AFMfile> AFM¥Õ¥¡¥¤¥ë̾¡Ê¤«¤ÊµÍ¤á»þ¤Ë»ÈÍÑ¡Ë\n", stderr);
	fputs2("-k <¿ôÃÍ>    ¤«¤ÊµÍ¤á¥Þ¡¼¥¸¥ó»ØÄê\n", stderr);
	fputs2("             ʸ»úÉý¤ò1000¤È¤·¤ÆÀ°¿ô¤Ç»ØÄê¡£-a¥ª¥×¥·¥ç¥ó¤È¶¦¤Ë»ÈÍÑ\n", stderr);
}