diff -ur -x Makefile.in -x aclocal.m4 -x autoconf.h.in -x configure lcdf-typetools-2.98.orig/otftotfm/automatic.cc lcdf-typetools-2.98/otftotfm/automatic.cc
--- lcdf-typetools-2.98.orig/otftotfm/automatic.cc	2013-04-11 09:20:12.000000000 +0200
+++ lcdf-typetools-2.98/otftotfm/automatic.cc	2013-04-11 09:21:35.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)
+// jtex_filetype is defined only in W32TeX
+	    char *p = kpsei_var_value("jtex_filetype");
+	    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.98.orig/otftotfm/kpseinterface.c lcdf-typetools-2.98/otftotfm/kpseinterface.c
--- lcdf-typetools-2.98.orig/otftotfm/kpseinterface.c	2012-08-16 15:02:19.000000000 +0200
+++ lcdf-typetools-2.98/otftotfm/kpseinterface.c	2013-04-11 09:21:35.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,13 +131,35 @@
 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)
 {
     char *result;
+#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);
@@ -81,5 +191,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.98.orig/otftotfm/kpseinterface.h lcdf-typetools-2.98/otftotfm/kpseinterface.h
--- lcdf-typetools-2.98.orig/otftotfm/kpseinterface.h	2010-05-30 02:00:16.000000000 +0200
+++ lcdf-typetools-2.98/otftotfm/kpseinterface.h	2013-04-11 09:21:35.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.98.orig/otftotfm/otftotfm.cc lcdf-typetools-2.98/otftotfm/otftotfm.cc
--- lcdf-typetools-2.98.orig/otftotfm/otftotfm.cc	2013-04-11 09:17:37.000000000 +0200
+++ lcdf-typetools-2.98/otftotfm/otftotfm.cc	2013-04-11 09:21:35.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);
 }
