summaryrefslogtreecommitdiff
path: root/Build/source/texk/lcdf-typetools/lcdf-typetools-2.94-PATCHES/patch-30-W32TeX
blob: 933d9bb2d4d9d3a87e6a40cc1441213589f65dc6 (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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/libefont/psres.cc lcdf-typetools-2.94/libefont/psres.cc
--- lcdf-typetools-2.94.orig/libefont/psres.cc	2011-11-03 17:51:58.000000000 +0100
+++ lcdf-typetools-2.94/libefont/psres.cc	2012-08-13 16:21:03.000000000 +0200
@@ -36,6 +36,11 @@
 # endif
 #endif
 #include <string.h>
+
+#ifdef W32TEX
+#include <windows.h>
+#endif
+
 namespace Efont {
 
 PsresDatabase::PsresDatabase()
diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/otftotfm/automatic.cc lcdf-typetools-2.94/otftotfm/automatic.cc
--- lcdf-typetools-2.94.orig/otftotfm/automatic.cc	2012-08-13 13:40:24.000000000 +0200
+++ lcdf-typetools-2.94/otftotfm/automatic.cc	2012-08-13 16:55:59.000000000 +0200
@@ -124,7 +124,18 @@
 static void
 find_writable_texdir(ErrorHandler *errh, const char *)
 {
+#if defined(W32TEX)
+// W32TeX does not have TEXMFVAR
+    char *p = kpsei_var_value("TEXMFVAR");
+    if (p == NULL) // W32TeX
+        look_for_writable_texdir("$TEXMFLOCAL", true);
+    else { // TeXLive
+        free (p);
+        look_for_writable_texdir("$TEXMFVAR", true);
+    }
+#else
     look_for_writable_texdir("$TEXMFVAR", true);
+#endif
     if (!writable_texdir)
 	look_for_writable_texdir("$VARTEXMF", false);
     if (!writable_texdir)
@@ -745,6 +756,14 @@
 	    int slash = filename.find_right('\'');
 	    if (slash >= 0)
 		filename = filename.substring(slash + 1);
+#if defined(W32TEX)
+// guess_input_kanji_encoding is defined only in W32TeX
+	    char *p = kpsei_var_value("guess_input_kanji_encoding");
+	    if (p != NULL) { // W32TeX
+		free(p);
+		String command = "updmap --nomkmap --add " + shell_quote(filename) + CMD_SEP " updmap";
+	    } else // TeXLive
+#endif
 	    String command = "updmap --nomkmap --enable Map " + shell_quote(filename) + CMD_SEP " updmap";
 	    if (verbose)
 		command += " 1>&2";
diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/otftotfm/kpseinterface.c lcdf-typetools-2.94/otftotfm/kpseinterface.c
--- lcdf-typetools-2.94.orig/otftotfm/kpseinterface.c	2012-08-16 11:07:09.000000000 +0200
+++ lcdf-typetools-2.94/otftotfm/kpseinterface.c	2012-08-13 17:05:15.000000000 +0200
@@ -11,24 +11,112 @@
  * Public License for more details.
  */
 
+/* The W32TEX version does not link to Kpathsea, but uses the DLL
+ * built by MSVC.
+ */
+
+#if !defined(W32TEX)
 #include <kpathsea/config.h>
+#endif
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef W32TEX
+#define ENV_SEP ';'
+#include <windows.h>
+extern HINSTANCE Hinstance;
+#else
 #include <kpathsea/progname.h>
 #include <kpathsea/expand.h>
 #include <kpathsea/c-pathch.h>
 #include <kpathsea/tex-file.h>
+#endif
 #include "kpseinterface.h"
 
 int kpsei_env_sep_char = ENV_SEP;
 
+#ifdef W32TEX
+typedef enum
+{
+  kpse_gf_format,
+  kpse_pk_format,
+  kpse_any_glyph_format,        /* ``any'' meaning gf or pk */
+  kpse_tfm_format,
+  kpse_afm_format,
+  kpse_base_format,
+  kpse_bib_format,
+  kpse_bst_format,
+  kpse_cnf_format,
+  kpse_db_format,
+  kpse_fmt_format,
+  kpse_fontmap_format,
+  kpse_mem_format,
+  kpse_mf_format,
+  kpse_mfpool_format,
+  kpse_mft_format,
+  kpse_mp_format,
+  kpse_mppool_format,
+  kpse_mpsupport_format,
+  kpse_ocp_format,
+  kpse_ofm_format,
+  kpse_opl_format,
+  kpse_otp_format,
+  kpse_ovf_format,
+  kpse_ovp_format,
+  kpse_pict_format,
+  kpse_tex_format,
+  kpse_texdoc_format,
+  kpse_texpool_format,
+  kpse_texsource_format,
+  kpse_tex_ps_header_format,
+  kpse_troff_font_format,
+  kpse_type1_format,
+  kpse_vf_format,
+  kpse_dvips_config_format,
+  kpse_ist_format,
+  kpse_truetype_format,
+  kpse_type42_format,
+  kpse_web2c_format,
+  kpse_program_text_format,
+  kpse_program_binary_format,
+  kpse_miscfonts_format,
+  kpse_web_format,
+  kpse_cweb_format,
+  kpse_enc_format,
+  kpse_cmap_format,
+  kpse_sfd_format,
+  kpse_opentype_format,
+  kpse_pdftex_config_format,
+  kpse_lig_format,
+  kpse_texmfscripts_format,
+  kpse_lua_format,
+  kpse_fea_format,
+  kpse_cid_format,
+  kpse_mlbib_format,
+  kpse_mlbst_format,
+  kpse_clua_format,
+  kpse_ris_format,
+  kpse_bltxml_format,
+  kpse_last_format /* one past last index */
+} kpse_file_format_type;
+#endif
+
 void
 kpsei_init(const char* argv0, const char* progname)
 {
+#ifdef W32TEX
+  PROC pkpse_set_program_name;
+  pkpse_set_program_name = GetProcAddress(Hinstance, "kpse_set_program_name");
+  if(!pkpse_set_program_name) {
+    fprintf(stderr, "Failed to find Kpathsea function.\n");
+    return;
+  }
+  (void)pkpse_set_program_name(argv0, progname);
+#else
     kpse_set_program_name(argv0, progname);
+#endif
 #ifdef SELFAUTODIR
     putenv("SELFAUTODIR=" SELFAUTODIR);
 #endif
@@ -43,12 +131,34 @@
 char*
 kpsei_path_expand(const char* path)
 {
+#ifdef W32TEX
+  PROC pkpse_path_expand;
+  pkpse_path_expand = GetProcAddress(Hinstance, "kpse_path_expand");
+  if(!pkpse_path_expand) {
+    fprintf(stderr, "Failed to find Kpathsea function.\n");
+    return 0;
+  }
+  return (char *)pkpse_path_expand(path);
+#else
     return kpse_path_expand(path);
+#endif
 }
 
+#ifdef W32TEX
+#define kpse_find_file  (char *)pkpse_find_file
+#endif
+
 char*
 kpsei_find_file(const char* name, int format)
 {
+#ifdef W32TEX
+  PROC pkpse_find_file;
+  pkpse_find_file = GetProcAddress(Hinstance, "kpse_find_file");
+  if(!pkpse_find_file) {
+    fprintf(stderr, "Failed to find Kpathsea function.\n");
+    return 0;
+  }
+#endif
     switch (format) {
       case KPSEI_FMT_WEB2C:
 	return kpse_find_file(name, kpse_web2c_format, true);
@@ -76,5 +186,41 @@
 void
 kpsei_set_debug_flags(unsigned flags)
 {
+#ifdef W32TEX
+  unsigned int *pkpathsea_debug;
+  pkpathsea_debug = (unsigned int *)GetProcAddress(Hinstance, "kpathsea_debug");
+  if(!pkpathsea_debug) {
+    fprintf(stderr, "Failed to find Kpathsea variable.\n");
+    return;
+  }
+  *pkpathsea_debug = flags;
+#else
     kpathsea_debug = flags;
+#endif
+}
+
+#ifdef W32TEX
+int
+kpsei_getlongpath(char *buff, char *input, int len)
+{
+  PROC pkpse_getlongpath;
+  pkpse_getlongpath = GetProcAddress(Hinstance, "getlongpath");
+  if(!pkpse_getlongpath) {
+    fprintf(stderr, "Failed to find Kpathsea function.\n");
+    return 0;
+  }
+  return (int)pkpse_getlongpath(buff, input, len);
 }
+
+char *
+kpsei_var_value(const char *var)
+{
+  PROC pkpse_var_value;
+  pkpse_var_value = GetProcAddress(Hinstance, "kpse_var_value");
+  if(!pkpse_var_value) {
+    fprintf(stderr, "Failed to find Kpathsea function.\n");
+    return NULL;
+  }
+  return (char *)pkpse_var_value(var);
+}
+#endif
diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/otftotfm/kpseinterface.h lcdf-typetools-2.94/otftotfm/kpseinterface.h
--- lcdf-typetools-2.94.orig/otftotfm/kpseinterface.h	2011-11-03 17:51:58.000000000 +0100
+++ lcdf-typetools-2.94/otftotfm/kpseinterface.h	2012-08-13 16:22:26.000000000 +0200
@@ -13,6 +13,13 @@
 char* kpsei_find_file(const char* name, int format);
 void kpsei_set_debug_flags(unsigned flags);
 
+#ifdef W32TEX
+int kpsei_getlongpath(char *buff, char *input, int len);
+char *kpsei_var_value(const char *var);
+#define true  1
+#define false 0
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.94.orig/otftotfm/otftotfm.cc lcdf-typetools-2.94/otftotfm/otftotfm.cc
--- lcdf-typetools-2.94.orig/otftotfm/otftotfm.cc	2012-08-11 18:07:57.000000000 +0200
+++ lcdf-typetools-2.94/otftotfm/otftotfm.cc	2012-08-13 16:30:04.000000000 +0200
@@ -1739,6 +1739,11 @@
     }
 }
 
+#ifdef W32TEX
+#include <windows.h>
+HINSTANCE Hinstance;
+#endif
+
 int
 main(int argc, char *argv[])
 {
@@ -1750,6 +1755,15 @@
     Clp_AddType(clp, CHAR_OPTTYPE, 0, clp_parse_char, 0);
     program_name = Clp_ProgramName(clp);
 #if HAVE_KPATHSEA
+#ifdef W32TEX
+    Hinstance = LoadLibrary(KPSEDLLNAME);
+    if(Hinstance == NULL)
+	Hinstance = LoadLibrary(KPSEOLDDLLNAME);
+    if(Hinstance == NULL) {
+	fprintf(stderr, "I cannot load Kpathsea dynamic library.\n");
+	return 100;
+    }
+#endif
     kpsei_init(argv[0], "lcdftools");
 #endif
 #ifdef HAVE_CTIME
@@ -2121,11 +2135,19 @@
 This is free software; see the source for copying conditions.\n\
 There is NO warranty, not even for merchantability or fitness for a\n\
 particular purpose.\n");
+#ifdef W32TEX
+            if(Hinstance != NULL)
+              FreeLibrary(Hinstance);
+#endif
 	    exit(0);
 	    break;
 
 	  case HELP_OPT:
 	    usage();
+#ifdef W32TEX
+            if(Hinstance != NULL)
+              FreeLibrary(Hinstance);
+#endif
 	    exit(0);
 	    break;
 
@@ -2181,8 +2203,13 @@
     try {
 	// read font
 	otf_data = read_file(input_file, errh);
-	if (errh->nerrors())
+	if (errh->nerrors()) {
+#ifdef W32TEX
+	    if(Hinstance != NULL)
+	      FreeLibrary(Hinstance);
+#endif
 	    exit(1);
+	}
 
 	LandmarkErrorHandler cerrh(errh, printable_filename(input_file));
 	BailErrorHandler bail_errh(&cerrh);
@@ -2271,6 +2298,10 @@
     } catch (OpenType::Error e) {
 	errh->error("unhandled exception %<%s%>", e.description.c_str());
     }
+#ifdef W32TEX
+    if(Hinstance != NULL)
+      FreeLibrary(Hinstance);
+#endif
 
     return (errh->nerrors() == 0 ? 0 : 1);
 }