File: mkvsydvf.c

package info (click to toggle)
vftool 2.0alpha-2
  • links: PTS
  • area: main
  • in suites: sarge, woody
  • size: 376 kB
  • ctags: 770
  • sloc: ansic: 2,748; makefile: 186; sh: 79
file content (128 lines) | stat: -rw-r--r-- 2,488 bytes parent folder | download | duplicates (5)
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
/*
 * make vf which simulates vert-BKfont symbol by DIR + hor-BKfont
 * mkvsypvf rml 10 rmlvsy /.../rmlvsy.tfm vch [VFDIR]
 * --> rmlvsy.vf
 */
#include	<stdio.h>
#include	"defs.h"
#include	"vfcodes.h"
#include	"vchar.h"
#include	"bifont.h"

char *horfont;
char *vsyfont;
int vfds;
char *vfdir;
FILE *tfm, *vf;

/* set by readvchar */
extern struct vchar vchar[];
extern int depthratio;
extern int rdisp, ddisp, vdisp;

/* set by readtfm */
extern char header[];
extern char width[];
extern byte char_info[];
extern int nt, lh, bc, ec, nw, ds;

main(ac, av)
int ac;
char *av[];
{
    char name[64];

    horfont = av[1];
    vfds = atoi(av[2])<<20;
    vsyfont = av[3];
    if ((tfm = fopen(av[4], "r")) == NULL) {
	fprintf(stderr, "cannot read %s\n", av[4]);
	exit(1);
    }
    if (!readtfm(tfm)) {
	fprintf(stderr, "%s is not tfm\n", av[4]);
	exit(1);
    }

    readvchar(av[5]);

    vfdir = (ac > 6) ? av[6] : "";
    sprintf(name, "%s%s.vf", vfdir, vsyfont);
    if ((vf = fopen(name, "w")) == NULL) {
	fprintf(stderr, "cannot write %s\n", name);
	exit(1);
    }
    vsyvf();
    fclose(vf);

    exit(0);
}

vsyvf()
{
    struct vchar *vc;
    char jsubname[64];
    long len;
    int i;

    putuint(vf, VF_PRE, 1);
    putuint(vf, VF_ID, 1);
    putuint(vf, 0, 1);	/* no comment */
    putbytes(vf, header, 2*4);	/* check sum & design size */

    fontdef(1, horfont);

    for (vc = vchar; vc->cc != 0; vc++)
	vfchar(vc);

    len = ftell(vf);
    for (i = 0; i < 4 - len%4; i++)
	putuint(vf, VF_POST, 1);
}

fontdef(f, fn)
int f;
char *fn;
{
    putuint(vf, FNT_DEF1, 1);
    putuint(vf, f, 1);
    putuint(vf, 0, 4);
    putuint(vf, VFRATIO, 4);
    putuint(vf, vfds, 4);
    putuint(vf, 0, 1);
    putuint(vf, strlen(fn), 1);
    putbytes(vf, fn, strlen(fn));
}

vfchar(vc)
struct vchar *vc;
{
    int pl;
    int rd, dd;
    int rn, dn;
    byte rb[sizeof(int)], db[sizeof(int)];

    if (vc->op == vop_rot || vc->op == vop_mirror) {
	rd = depthratio;
	dd = -rdisp;
    } else
	return;
    pl = 5;	/* DIR 1 SET2 cc */
    rn = inttob(rb, rd, TRUE);
    pl += 1+rn;
    dn = inttob(db, dd, TRUE);
    pl += 1+dn;

    putuint(vf, VF_LONG_CHAR, 1);
    putuint(vf, pl, 4);
    putuint(vf, vc->c, 4);
    putbytes(vf, width+char_info[(vc->c-bc)*4]*4, 4);
    putuint(vf, RIGHT1+rn-1, 1);
    putbytes(vf, rb, rn);
    putuint(vf, DOWN1+dn-1, 1);
    putbytes(vf, db, dn);
    putuint(vf, DIR, 1);
    putuint(vf, 1, 1);
    putuint(vf, SET2, 1);
    putuint(vf, vc->cc, 2);
}