Package: xdvik-ja / 22.87.03+j1.42-1

0004-Update-pTeX-patch-jfm.patch Patch series | download
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
From: Youhei SASAKI <uwabami@gfd-dennou.org>
Date: Tue, 12 Jul 2016 11:37:33 +0900
Subject: Update pTeX patch: jfm

Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
---
 texk/xdvik/jfm.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 texk/xdvik/jfm.h |  54 +++++++++++++++++++++
 2 files changed, 197 insertions(+)
 create mode 100644 texk/xdvik/jfm.c
 create mode 100644 texk/xdvik/jfm.h

--- /dev/null
+++ b/texk/xdvik/jfm.c
@@ -0,0 +1,143 @@
+/*========================================================================*\
+
+Copyright (C) Atsuo Kawaguchi, 1987.
+Copyright (C) 1993-2013 The Xdvik-jp project http://xdvi.sourceforge.jp/
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+NOTE:
+This module is based on prior work, as noted below and
+in the modification history in README.xdvik-jp and changelog.
+
+\*========================================================================*/
+
+/*------------------------------------------------------------------------
+  The function read_jfm0() and jfm.h are derived from
+    drivers/jxdvi.NEWS/font.{c,h}
+    in ascii jtex1.7.tar.Z (1992, ASCII CORPORATION).
+  The original author and copyright notice is shown below (in UTF-8):
+
+ *
+ * Copyright (C) Atsuo Kawaguchi, 1987.
+ * 連絡先:
+ *      (...)
+ *      (...)
+ *          川口敦生
+ *        (atsuo@sanken.osaka-u.junet)
+ * このプログラムのいかなる複写、移植、改変、修正も許諾します。
+ * Everyone is permitted to do anything on this program
+ * including copying, porting, debugging, and modifying.
+ *
+
+ -------------------------------------------------------------------------*/
+
+#include "xdvi-config.h"
+#include "xdvi.h"
+#ifdef	PTEX
+
+#include "jfm.h"
+#include "util.h"
+
+#ifndef	SEEK_SET
+#define	SEEK_SET	0
+#endif
+
+/**** read_jfm0: borrowed from jxdvi-NEWS ****/
+static int read_jfm0(FILE *fp, struct jfm *j)
+{
+	int i;
+
+	fseek(fp, 0L, SEEK_SET);
+
+	/* read jfm table field. */
+	for (i = 0; i <= J_NP; i++)
+	    j->table[i] = (short) get_bytes(fp, 2);
+
+	/* read jfm header */
+	j->check_sum = get_bytes(fp, 4);
+	j->design_size = get_bytes(fp, 4);
+	fseek(fp, (long) (4 * (j->table[J_LH] - 2)), 1);
+    
+	/* read jfm char_type */
+	j->type = xmalloc(sizeof(struct jfm_char_type) * j->table[J_NT]);
+	for (i=0; i < j->table[J_NT]; i++) {
+	    j->type[i].code = (short) get_bytes(fp, 2);
+	    j->type[i].index = (short) get_bytes(fp, 2);
+	}
+    
+	/* read jfm char_info */
+	j->info = xmalloc(sizeof(struct jfm_char_info) * (j->table[J_EC] + 1));
+	for (i = 0; i <= j->table[J_EC]; i++) {
+	    j->info[i].width_ix = (unsigned char) get_byte(fp);
+	    j->info[i].height_depth_ix = (unsigned char) get_byte(fp);
+	    j->info[i].italic_ix_tag = (unsigned char) get_byte(fp);
+	    j->info[i].remainder_ix = (unsigned char) get_byte(fp);
+	}
+    
+	/* read jfm width */
+	j->width = xmalloc(sizeof(unsigned long) * j->table[J_NW]);
+	for (i = 0; i < j->table[J_NW]; i++)
+	    j->width[i] = get_bytes(fp, 4);
+
+	/* read jfm height */
+	j->height = xmalloc(sizeof(unsigned long) * j->table[J_NH]);
+	for (i = 0; i < j->table[J_NH]; i++)
+	    j->height[i] = get_bytes(fp, 4);
+
+	/* read jfm depth */
+	j->depth = xmalloc(sizeof(unsigned long) * j->table[J_ND]);
+	for (i = 0; i < j->table[J_ND]; i++)
+	    j->depth[i] = get_bytes(fp, 4);
+
+	/* read jfm italic */
+	j->italic = xmalloc(sizeof(unsigned long) * j->table[J_NI]);
+	for (i = 0; i < j->table[J_NI]; i++)
+	    j->italic[i] = get_bytes(fp, 4);
+	return 0;
+}
+
+static int jfms_max = 0;
+static int jfms_num = 0;
+static struct jfm *jfms = NULL;
+
+struct jfm *read_jfm(FILE *fp, char *fontname)
+{
+	int i;
+	struct jfm *j;
+
+	for (i=0; i<jfms_num; i++) {
+	    if (strcmp(fontname, jfms[i].fontname) == 0) return &jfms[i];
+	}
+
+	if (jfms_num == jfms_max) {
+	    if (jfms_max == 0) jfms_max = 8;
+	    else               jfms_max *= 2;
+	    jfms = xrealloc( jfms, sizeof(jfms[0]) * jfms_max );
+	}
+	j = &jfms[jfms_num];
+
+	if (read_jfm0(fp, j)) {
+	    fprintf(stderr, "Cannot open metric file: %s\n", fontname);
+	    return NULL;
+	}
+	j->fontname = xstrdup(fontname);
+	jfms_num++;
+	return j;
+}
+#endif	/* PTEX */
--- /dev/null
+++ b/texk/xdvik/jfm.h
@@ -0,0 +1,54 @@
+/**********************************************
+ *  Copyright (C) Atsuo Kawaguchi, 1987.
+ *         (atsuo@sanken.osaka-u.junet)
+ *  Modified by Y. Hayashi from jxdvi-NEWS
+ *	   (hayashi@me.aoyama.ac.jp)
+ **********************************************/
+/* Lisense is shown in jfm.c */
+
+#ifndef JFM_H_
+#define JFM_H_
+
+#define	J_ID 0		/* id */
+#define	J_NT 1		/* number of words in the char_type table */
+#define	J_LF 2		/* length of entire file */
+#define	J_LH 3		/* length of header */
+#define	J_BC 4		/* smallest char_type */
+#define	J_EC 5		/* largest char_type */
+#define	J_NW 6		/* number of width table */
+#define	J_NH 7		/* number of height table */
+#define	J_ND 8		/* number of depth table */
+#define	J_NI 9		/* number of italic correctiuon table */
+#define	J_NL 10		/* number of glue/kern talbe */
+#define	J_NK 11
+#define	J_NG 12
+#define	J_NP 13
+
+struct jfm_char_type {
+    unsigned short	code;		/* JIS code */
+    unsigned short	index;		/* index to char_info */
+};
+
+struct jfm_char_info {
+    unsigned char	width_ix;		/* index to width */
+    unsigned char	height_depth_ix;	/* index to height & depth */
+    unsigned char	italic_ix_tag;		/* index to italic & tag */
+    unsigned char	remainder_ix;		/* index to remainder */
+};
+
+struct jfm {
+    char	*fontname;			/* font name (min10, etc.) */
+    short	table[(J_NP+1)];		/* table */
+    unsigned long check_sum;			/* header */
+    unsigned long design_size;		
+    struct jfm_char_type *type;
+    struct jfm_char_info *info;
+    unsigned long *width;
+    unsigned long *height;
+    unsigned long *depth;
+    unsigned long *italic;
+};
+
+struct jfm *read_jfm(FILE *fp, char *fontname);
+
+#endif /* JFM_H_ */