summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/pmpostdir
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
committerKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
commitad547a6b5986815fda458221149728d9d9ab1d87 (patch)
tree16296910eb3eca724371474ea9aea3994dc69614 /Build/source/texk/web2c/pmpostdir
parent947b43de3dd21d58ccc2ffadefc4441ea1c2a813 (diff)
restore Build,TODO from r57911
git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/pmpostdir')
-rw-r--r--Build/source/texk/web2c/pmpostdir/ChangeLog123
-rw-r--r--Build/source/texk/web2c/pmpostdir/Changes.old.ja20
-rw-r--r--Build/source/texk/web2c/pmpostdir/README19
-rw-r--r--Build/source/texk/web2c/pmpostdir/README.old.ja87
-rw-r--r--Build/source/texk/web2c/pmpostdir/am/pmpost.am193
-rw-r--r--Build/source/texk/web2c/pmpostdir/pmp.ch359
-rw-r--r--Build/source/texk/web2c/pmpostdir/pmpost.ch315
-rwxr-xr-xBuild/source/texk/web2c/pmpostdir/pmpost.test14
-rwxr-xr-xBuild/source/texk/web2c/pmpostdir/pmpsamp.test42
-rw-r--r--Build/source/texk/web2c/pmpostdir/pmpxout.ch556
-rw-r--r--Build/source/texk/web2c/pmpostdir/ppsout.ch86
-rw-r--r--Build/source/texk/web2c/pmpostdir/psvgout.ch77
-rw-r--r--Build/source/texk/web2c/pmpostdir/ptfmin.ch116
-rw-r--r--Build/source/texk/web2c/pmpostdir/tests/psample.mp16
-rw-r--r--Build/source/texk/web2c/pmpostdir/tests/testnewu.mp36
-rw-r--r--Build/source/texk/web2c/pmpostdir/tests/testnewu.tex7
-rw-r--r--Build/source/texk/web2c/pmpostdir/tests/testnewu.tfmbin0 -> 388 bytes
-rwxr-xr-xBuild/source/texk/web2c/pmpostdir/upmpost.test14
-rwxr-xr-xBuild/source/texk/web2c/pmpostdir/upmpsamp.test42
19 files changed, 2122 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/pmpostdir/ChangeLog b/Build/source/texk/web2c/pmpostdir/ChangeLog
new file mode 100644
index 00000000000..4d4229be6f7
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/ChangeLog
@@ -0,0 +1,123 @@
+2020-10-25 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
+
+ * pmp.ch: Bump upmpost version to 2.00-0.04-u1.27.
+
+2020-05-17 Hironobu Yamashita <h.y.acetaminophen@gmail.com>
+
+ * pmp.ch: Avoid a compiler warning: equality comparison with
+ extraneous parentheses.
+
+2020-02-23 Akira Kakuto <kakuto@w32tex.org>
+
+ * pmp.ch: Bump upmpost version to 2.00-0.04-u1.26.
+
+2019-05-28 Akira Kakuto <kakuto@w32tex.org>
+
+ * pmp.ch: Bump upmpost version to 2.00-0.04-u1.25.
+
+2019-03-22 Akira Kakuto <kakuto@w32tex.org>
+
+ * pmp.ch: Sync with the change of mp.w.
+
+2019-02-23 Akira Kakuto <kakuto@w32tex.org>
+
+ * pmp.ch: Bump upmpost version to 2.00-0.04-u1.24.
+ * pmpost.ch: Do not change internal encoding by -kanji option.
+
+2019-01-29 Akira Kakuto <kakuto@w32tex.org>
+
+ * pmpost.ch: adapt to the new mpost.w.
+ Forbid too long kanji option.
+
+2018-12-21 Karl Berry <karl@freefriends.org>
+
+ * am/pmpost.am (bin_links): make r* links at install time;
+ see entry in ../mplibdir/ChangeLog.
+
+2018-09-09 Karl Berry <karl@tug.org>
+
+ * upmpsamp.test,
+ * pmpsamp.test: LC_ALL=LANGUAGE=C.
+
+2018-08-16 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
+
+ * ptfmin.ch: Support new JFM spec, which allows 3-byte
+ characters in TYPE > 0.
+ * tests/testnewu.{mp,tex,tfm}: Added. (File testnewu.tfm
+ is the same as uptexdir/tests.)
+
+2018-03-26 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * pmpost.ch: Use UTF-8 as a default encoding also on
+ Windows.
+
+2018-02-19 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * pmp.ch: Adapt to the new mp.w.
+
+2018-01-27 Hironobu Yamashita <h.y.acetaminophen@gmail.com>
+
+ * README.old.ja, Changes.old.ja: Import README.jis and
+ Changes.jis from old upstream jmpost-0.04.tar.gz,
+ renamed and converted to UTF-8.
+ * README: Added.
+ * am/pmpost.am: Adjusted.
+
+2017-07-30 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * ppsout.ch, pmpost.ch: Force a space between " and ".
+
+2017-04-24 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
+
+ * pmpxout.ch: p\TeX -> \pTeX.
+
+2017-03-31 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * pmp.ch: Adapt to MetaPost 2.000.
+
+2017-02-28 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * ppsout.ch: Do not change the first 19 characters %%Creator: MetaPost.
+
+2016-12-02 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * pmpost.ch: Adapt to the restricted mode in the latest mpost.w.
+
+2016-03-06 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * pmp.ch: Adapt to MetaPost 1.9991.
+
+2015-07-10 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * am/pmpost.am: Dependencies for 'make check'.
+
+2014-10-30 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * pmpost.ch, pmpxout.ch: Cleanup for pdvitomp and updvitomp.
+
+2014-10-30 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * pmpost.ch [W32TEX]: Handle building of (u)pmpost.dll.
+
+2014-10-26 Karl Berry <karl@tug.org>
+
+ * pmpsamp.test, upmpsamp.test: check that e[u]ptex can read
+ their .fmt files, since that is what [u]pmpost is going to do.
+
+2014-09-22 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * pmpsamp.test, upmpsamp.test, tests/psample.mp: Shell scripts
+ and data for new tests.
+
+2014-09-17 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * ptfmin.ch: Allow character codes up to 0xffff.
+ * pmp.ch, pmpost.ch, ppsout.ch: Use P_UP prefix to handle
+ strings pMetaPost vs upMetaPost and similar.
+
+2014-09-05 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * Import pMetaPost and upMetaPost from ???.
+ * Rename change files and adapt to TeX Live build system.
+ * Handle pMetaPost/upMetaPost differences via '#ifdef UPMP'.
+ * pmpost.test, upmpost.test: Shell scripts for simple tests.
diff --git a/Build/source/texk/web2c/pmpostdir/Changes.old.ja b/Build/source/texk/web2c/pmpostdir/Changes.old.ja
new file mode 100644
index 00000000000..ebb388bedf0
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/Changes.old.ja
@@ -0,0 +1,20 @@
+2000-03-20 (version 0.04)
+ * pTeX-2.1.9 対応
+
+2000-01-14 (version 0.03)
+ * ソースコードの整理 (機能に変化なし)
+
+1999-09-29 (version 0.02)
+ * デフォルトで pmakempx をインストール
+ * SJIS 版で JIS 漢字コードのサポート
+
+1999-09-26 (version 0.01)
+ * 鈴木秀幸 <hideyuki@sat.t.u-tokyo.ac.jp> による機能拡張パッチをマージ。
+ - btex etex なしでも日本語対応 (jmpost: JFM support)
+ - prologues:=0 のときに日本語対応 (jmpost: %*Font: 出力)
+ - 日本語の多書体対応 (配列サイズの拡大)
+ - 縦書き対応 (jmpost: bbox 計算, pdvitomp: dir 対応)
+
+1999-07-24 (version 0.00)
+ * 松山道夫さん <fwhw5892@mb.infoweb.ne.jp> による日本語MetaPost初公開。
+ http://village.infoweb.ne.jp/~fwhw5892/jweb/jmpost.htm
diff --git a/Build/source/texk/web2c/pmpostdir/README b/Build/source/texk/web2c/pmpostdir/README
new file mode 100644
index 00000000000..ff2e7fe3fc1
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/README
@@ -0,0 +1,19 @@
+(This file is public domain.)
+
+This directory contains pMetaPost and upMetaPost, a Japanese version
+of MetaPost. They were originally published/maintained as jMetaPost
+by Michio Matsuyama and Hideyuki Suzuki.
+
+A few years later, the changes files were translated from WEB to
+CWEB by Akira Kakuto for W32TeX distribution. The project name
+was changed to pMetaPost around 2009, to be consistent with pTeX
+and upTeX. The command names are currently pmpost and upmpost.
+
+Old information and development history (around 1999) can be obtained
+from Web archives:
+
+* http://web.archive.org/web/20040414071904/http://village.infoweb.ne.jp:80/~fwhw5892/jweb/jmpost.htm
+
+* http://web.archive.org/web/20110723233250/http://www.sat.t.u-tokyo.ac.jp:80/~hideyuki/metapost/
+
+Japanese TeX Development Community
diff --git a/Build/source/texk/web2c/pmpostdir/README.old.ja b/Build/source/texk/web2c/pmpostdir/README.old.ja
new file mode 100644
index 00000000000..bb2377d5d80
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/README.old.ja
@@ -0,0 +1,87 @@
+===========================================================================
+ 日本語 MetaPost
+
+ $Id: README.jis,v 1.7 2000/03/20 02:52:52 hideyuki Exp $
+===========================================================================
+
+
+◎ はじめに
+
+John Hobby によって作成された MetaPost の日本語化です。
+
+オリジナルと比べて,以下の機能が拡張されます。
+
+ ・ 文字列に日本語を入れられる
+ ・ btex etex 内に日本語を書ける
+ ・ 日本語フォント(横書き・縦書き)を指定できる
+
+ドキュメントが整備されていませんが,詳細な情報は以下の URL から得られます。
+
+ ・ http://www.sat.t.u-tokyo.ac.jp/~hideyuki/metapost/
+
+
+◎ インストール
+
+必要なファイル
+
+日本語MetaPostのインストールには他に以下のファイルが必要です。どれもpTeXの
+インストールに必要なものです。
+
+ ・ ptex-src-2.1.9.tar.gz
+ ・ ptex-texmf-1.5.tar.gz
+ ・ teTeX-src-1.0.7.tar.gz
+
+TeX, pTeX のインストール
+
+ソースとライブラリを展開して,TeX, pTeX を make してください。詳細はpTeXに
+付属のドキュメントを参照してください。実際にはインストールまでする必要はあ
+りません。
+% cd /.../teTeX-1.0
+% ./configure
+% make all
+# make install strip
+% cd texk/web2c/ptex-src-2.1.9
+% ./configure (JIS|EUC|SJIS)
+% make
+# make install
+
+日本語MetaPostのインストール
+
+pTeXを展開したディレクトリの中で,日本語MetaPostの配布を展開して, jmpdir
+に移動,configure, make, make install します。
+% tar xvzf /.../jmpost-0.XX.tar.gz
+% cd jmpost-0.XX
+% ./configure
+% make
+# make install
+
+環境設定
+
+ ・ 環境変数TEXに ptex, platex などを設定。
+ ・ 環境変数DVITOMPに pdvitomp を設定。
+
+これで日本語MetaPostが jmpost コマンドで使えるようになります。 DVITOMPを設
+定するかわりに,$TEXMF/web2c/texmf.cnf に
+
+% What MetaPost runs to make MPX files. This is passed an option -troff
+% if MP is in troff mode. Set to `0' to disable this feature.
+MPXCOMMAND.jmpost = pmakempx
+MPXCOMMAND = makempx
+
+と書いてもいいでしょう。
+
+
+◎ 参考
+
+MetaPost の日本語化を初めて手掛けられたのは松山道夫さん
+(fwhw5892@mb.infoweb.ne.jp)です。松山さんの日本語 MetaPost の
+ページは以下の URL にあります。
+http://village.infoweb.ne.jp/~fwhw5892/jweb/jmpost.htm
+
+現在,日本語 MetaPost に関する最新の情報・詳細な情報は以下の
+URL から得られます。
+http://www.sat.t.u-tokyo.ac.jp/~hideyuki/metapost/
+
+--
+鈴木 秀幸 (Hideyuki Suzuki)
+hideyuki@sat.t.u-tokyo.ac.jp
diff --git a/Build/source/texk/web2c/pmpostdir/am/pmpost.am b/Build/source/texk/web2c/pmpostdir/am/pmpost.am
new file mode 100644
index 00000000000..f7e60851bf4
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/am/pmpost.am
@@ -0,0 +1,193 @@
+## texk/web2c/pmpostdir/am/pmpost.am: Makefile fragment for pMetaPost.
+##
+## Copyright 2018 Karl Berry <tex-live@tug.org>
+## Copyright 2014-2015 Peter Breitenlohner <tex-live@tug.org>
+## You may freely use, modify and/or distribute this file.
+
+## pMetaPost and upMetaPost
+##
+if PMP
+bin_PROGRAMS += pmpost
+if WIN32
+noinst_PROGRAMS += call_pmpost
+install_exe_links += install-pmpost-links
+uninstall_exe_links += uninstall-pmpost-links
+else !WIN32
+bin_links += pmpost$(EXEEXT):pdvitomp
+bin_links += pmpost$(EXEEXT):r-pmpost
+endif !WIN32
+endif PMP
+if UPMP
+bin_PROGRAMS += upmpost
+if WIN32
+noinst_PROGRAMS += call_upmpost
+install_exe_links += install-upmpost-links
+uninstall_exe_links += uninstall-upmpost-links
+else !WIN32
+bin_links += upmpost$(EXEEXT):updvitomp
+bin_links += upmpost$(EXEEXT):r-upmpost
+endif !WIN32
+endif UPMP
+EXTRA_PROGRAMS += pmpost upmpost
+
+call_pmpost_CPPFLAGS = -DEXEPROG=\"pmpost.exe\"
+nodist_call_pmpost_SOURCES = callexe.c
+call_pmpost_LDADD =
+
+call_upmpost_CPPFLAGS = -DEXEPROG=\"upmpost.exe\"
+nodist_call_upmpost_SOURCES = callexe.c
+call_upmpost_LDADD =
+
+pmpost_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \
+ $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir
+pmpost_LDADD = $(PTEXENC_LIBS) $(KPATHSEA_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \
+ $(CAIRO_LIBS) $(PIXMAN_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) libmputil.a
+
+upmpost_CPPFLAGS = -DUPMP $(pmpost_CPPFLAGS)
+upmpost_LDADD = $(pmpost_LDADD)
+
+.PHONY: install-pmpost-links install-upmpost-links uninstall-pmpost-links uninstall-upmpost-links
+if WIN32
+install-pmpost-links: call_pmpost$(EXEEXT)
+ $(INSTALL_PROGRAM) call_pmpost$(EXEEXT) $(DESTDIR)$(bindir)/pdvitomp$(EXEEXT)
+install-upmpost-links: call_upmpost$(EXEEXT)
+ $(INSTALL_PROGRAM) call_upmpost$(EXEEXT) $(DESTDIR)$(bindir)/updvitomp$(EXEEXT)
+uninstall-pmpost-links:
+ rm -f $(DESTDIR)$(bindir)/pdvitomp$(EXEEXT)
+uninstall-upmpost-links:
+ rm -f $(DESTDIR)$(bindir)/updvitomp$(EXEEXT)
+endif WIN32
+
+# Creating one file: just one rule
+pmp_ctangle = $(ctangle_silent)CWEBINPUTS=.:$(srcdir)/pmpostdir $(ctangle)
+# Creating several files: need stamp file and two rules with identical recipes
+pmp_ctangle_sh = CWEBINPUTS=.:$(srcdir)/pmpostdir AM_V_P=$(AM_V_P) $(SHELL) ./tangle-sh $@ $(CTANGLE)
+
+## pMetaPost C sources
+nodist_pmpost_SOURCES = $(pmp_c_h) $(pmpmath_c_h) $(pmpmathbinary_c_h) $(pmpmathdecimal_c_h) \
+ $(pmpmathdouble_c_h) pmpost.c $(pmpstrings_c_h) $(pmpxout_c_h) \
+ $(ppngout_c_h) $(ppsout_c_h) $(psvgout_c_h) ptfmin.c
+pmp_c_h = pmp.c pmplib.h pmpmp.h
+pmpmath_c_h = pmpmath.c pmpmath.h
+pmpmathbinary_c_h = pmpmathbinary.c pmpmathbinary.h
+pmpmathdecimal_c_h = pmpmathdecimal.c pmpmathdecimal.h
+pmpmathdouble_c_h = pmpmathdouble.c pmpmathdouble.h
+pmpstrings_c_h = pmpstrings.h pmpstrings.c
+pmpxout_c_h = pmpxout.c pmpxout.h
+ppngout_c_h = pmplibpng.h pmppngout.h ppngout.c
+ppsout_c_h = pmppsout.h ppsout.c pmplibps.h
+psvgout_c_h = pmplibsvg.h pmpsvgout.h psvgout.c
+
+## upMetaPost C sources
+nodist_upmpost_SOURCES = $(nodist_pmpost_SOURCES)
+
+# sed script
+pmp_sed_main = 's/mpxout\.h/pmpxout.h/;s/mpmp\.h/pmpmp.h/;s/mplib\.h/pmplib.h/;s/mpstrings\.h/pmpstrings.h/'
+pmp_sed_math = 's/mpmath\([a-z]*\)\.h/pmpmath\1.h/'
+pmp_sed_ps = 's/mplibps\.h/pmplibps.h/;s/mppsout\.h/pmppsout.h/'
+pmp_sed_svg = 's/mplibsvg\.h/pmplibsvg.h/;s/mpsvgout\.h/pmpsvgout.h/'
+pmp_sed_png = 's/mplibpng\.h/pmplibpng.h/;s/mppngout\.h/pmppngout.h/'
+pmp_sed = sed -e $(pmp_sed_main) -e $(pmp_sed_math) -e $(pmp_sed_ps) -e $(pmp_sed_svg) -e $(pmp_sed_png)
+
+pmp.w: mplibdir/mp.w
+ $(AM_V_GEN)$(pmp_sed) $(srcdir)/mplibdir/mp.w >$@
+pmpmath.c: mpmath.c
+ $(AM_V_GEN)$(pmp_sed) mpmath.c >$@
+pmpmath.h: mpmath.h
+ $(AM_V_GEN)$(pmp_sed) mpmath.h >$@
+pmpmathbinary.c: mpmathbinary.c
+ $(AM_V_GEN)$(pmp_sed) mpmathbinary.c >$@
+pmpmathbinary.h: mpmathbinary.h
+ $(AM_V_GEN)$(pmp_sed) mpmathbinary.h >$@
+pmpmathdecimal.c: mpmathdecimal.c
+ $(AM_V_GEN)$(pmp_sed) mpmathdecimal.c >$@
+pmpmathdecimal.h: mpmathdecimal.h
+ $(AM_V_GEN)$(pmp_sed) mpmathdecimal.h >$@
+pmpmathdouble.c: mpmathdouble.c
+ $(AM_V_GEN)$(pmp_sed) mpmathdouble.c >$@
+pmpmathdouble.h: mpmathdouble.h
+ $(AM_V_GEN)$(pmp_sed) mpmathdouble.h >$@
+pmpost.w: mplibdir/mpost.w
+ $(AM_V_GEN)$(pmp_sed) $(srcdir)/mplibdir/mpost.w >$@
+pmpstrings.c: mpstrings.c
+ $(AM_V_GEN)$(pmp_sed) mpstrings.c >$@
+pmpstrings.h: mpstrings.h
+ $(AM_V_GEN)$(pmp_sed) mpstrings.h >$@
+pmpxout.w: mplibdir/mpxout.w
+ $(AM_V_GEN)$(pmp_sed) $(srcdir)/mplibdir/mpxout.w >$@
+pmplibpng.h: mplibpng.h
+ $(AM_V_GEN)$(pmp_sed) mplibpng.h >$@
+pmppngout.h: mppngout.h
+ $(AM_V_GEN)$(pmp_sed) mppngout.h >$@
+ppngout.c: pngout.c
+ $(AM_V_GEN)$(pmp_sed) pngout.c >$@
+ppsout.w: mplibdir/psout.w
+ $(AM_V_GEN)$(pmp_sed) $(srcdir)/mplibdir/psout.w >$@
+psvgout.w: mplibdir/svgout.w
+ $(AM_V_GEN)$(pmp_sed) $(srcdir)/mplibdir/svgout.w >$@
+ptfmin.w: mplibdir/tfmin.w
+ $(AM_V_GEN)$(pmp_sed) $(srcdir)/mplibdir/tfmin.w >$@
+
+# Creating one file: just one rule
+pmpost.c: ctangle$(EXEEXT) pmpost.w pmpostdir/pmpost.ch
+ $(pmp_ctangle) pmpost pmpost
+ptfmin.c: ctangle$(EXEEXT) ptfmin.w pmpostdir/ptfmin.ch
+ $(pmp_ctangle) ptfmin ptfmin
+
+# Creating several files: need stamp file and two rules with identical recipes
+$(pmp_c_h): pmp-tangle
+ @$(pmp_ctangle_sh) pmp pmp
+pmp-tangle: ctangle$(EXEEXT) pmp.w pmpostdir/pmp.ch tangle-sh
+ @$(pmp_ctangle_sh) pmp pmp
+
+$(pmpxout_c_h): pmpxout-tangle
+ @$(pmp_ctangle_sh) pmpxout pmpxout
+pmpxout-tangle: ctangle$(EXEEXT) pmpxout.w pmpostdir/pmpxout.ch tangle-sh
+ @$(pmp_ctangle_sh) pmpxout pmpxout
+
+$(ppsout_c_h): ppsout-tangle
+ @$(pmp_ctangle_sh) ppsout ppsout
+ppsout-tangle: ctangle$(EXEEXT) ppsout.w pmpostdir/ppsout.ch tangle-sh
+ @$(pmp_ctangle_sh) ppsout ppsout
+
+$(psvgout_c_h): psvgout-tangle
+ @$(pmp_ctangle_sh) psvgout psvgout
+psvgout-tangle: ctangle$(EXEEXT) psvgout.w pmpostdir/psvgout.ch tangle-sh
+ @$(pmp_ctangle_sh) psvgout psvgout
+
+## pMetaPost CWeb sources
+pmpost_web = pmpostdir/pmp.ch pmpostdir/pmpost.ch pmpostdir/pmpxout.ch pmpostdir/ppsout.ch \
+ pmpostdir/psvgout.ch pmpostdir/ptfmin.ch
+
+$(pmpost_OBJECTS) $(upmpost_OBJECTS): $(nodist_pmpost_SOURCES) $(PTEXENC_DEPEND) \
+ $(LIBPNG_DEPEND) $(CAIRO_DEPEND) $(MPFR_DEPEND)
+
+EXTRA_DIST += pmpostdir/ChangeLog $(pmpost_web)
+
+DISTCLEANFILES += $(nodist_pmpost_SOURCES) \
+ pmp.w pmpost.w pmpxout.w ppsout.w psvgout.w ptfmin.w \
+ pmp-tangle pmpxout-tangle ppsout-tangle psvgout-tangle
+
+## (u)pMetaPost Tests
+##
+pmpost_tests = pmpostdir/pmpost.test pmpostdir/pmpsamp.test
+pmpostdir/pmpost.log pmpostdir/pmpsamp.log: pmpost$(EXEEXT)
+upmpost_tests = pmpostdir/upmpost.test pmpostdir/upmpsamp.test
+pmpostdir/upmpost.log pmpostdir/upmpsamp.log: upmpost$(EXEEXT)
+
+EXTRA_DIST += $(pmpost_tests) $(upmpost_tests)
+
+if PMP
+TESTS += $(pmpost_tests)
+endif PMP
+if UPMP
+TESTS += $(upmpost_tests)
+endif UPMP
+
+EXTRA_DIST += pmpostdir/tests/psample.mp
+EXTRA_DIST += pmpostdir/README pmpostdir/README.old.ja pmpostdir/Changes.old.ja
+## pmpostdir/pmpsamp.test
+DISTCLEANFILES += pmpsamp.*
+## pmpostdir/upmpsamp.test
+DISTCLEANFILES += upmpsamp.*
+
diff --git a/Build/source/texk/web2c/pmpostdir/pmp.ch b/Build/source/texk/web2c/pmpostdir/pmp.ch
new file mode 100644
index 00000000000..edab992e8ec
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/pmp.ch
@@ -0,0 +1,359 @@
+% jMetaPost change file for MetaPost
+%
+% written by Michio Matsuyama <fwhw5892@mb.infoweb.ne.jp>
+% Hideyuki Suzuki <hideyuki@sat.t.u-tokyo.ac.jp>
+%
+% $Id: jmp.ch,v 1.42 2000/03/20 02:55:50 hideyuki Exp $
+
+%
+%
+% change file of mp.w for pMetaPost (CWEB version)
+% Akira Kakuto (translated the WEB version)
+%
+%
+
+@x
+@d default_banner "This is MetaPost, Version 2.00" /* printed when \MP\ starts */
+@y
+@z
+
+@x
+#define metapost_version "2.00"
+@y
+#ifdef UPMP
+#define P_UP "up"
+#define metapost_version "2.00-0.04-u1.27"
+#else
+#define P_UP "p"
+#define metapost_version "2.00-0.04"
+#endif
+#define default_banner "This is " P_UP "MetaPost, Version " metapost_version /* printed when \MP\ starts */
+@z
+
+@x
+# include <unistd.h> /* for access */
+#endif
+@y
+# include <unistd.h> /* for access */
+#endif
+#include <kpathsea/config.h>
+#include <kpathsea/kpathsea.h>
+#include <ptexenc/ptexenc.h>
+#include <errno.h>
+@z
+
+@x
+void mp_close_file (MP mp, void *f) {
+ (void) mp;
+ if (f != NULL)
+ fclose ((FILE *) f);
+@y
+void mp_close_file (MP mp, void *f) {
+ (void) mp;
+#ifdef WIN32
+ if (f != NULL) {
+ clear_infile_enc((FILE *)f);
+ fclose ((FILE *) f);
+ }
+#else
+ if (f != NULL)
+ fclose ((FILE *) f);
+#endif
+@z
+
+@x
+mp->buf_size = 200;
+@y
+{
+ char *kpse_buf = kpse_var_value("buf_size");
+ if(kpse_buf) {
+ mp->buf_size = atoi(kpse_buf);
+ free(kpse_buf);
+ } else {
+ mp->buf_size = 500000;
+ }
+}
+@z
+
+@x
+static boolean mp_input_ln (MP mp, void *f) {
+ /* inputs the next line or returns |false| */
+ char *s;
+ size_t size = 0;
+ mp->last = mp->first; /* cf.\ Matthew 19\thinspace:\thinspace30 */
+ s = (mp->read_ascii_file) (mp, f, &size);
+ if (s == NULL)
+ return false;
+ if (size > 0) {
+ mp->last = mp->first + size;
+ if (mp->last >= mp->max_buf_stack) {
+ mp->max_buf_stack = mp->last + 1;
+ while (mp->max_buf_stack > mp->buf_size) {
+ mp_reallocate_buffer (mp, (mp->buf_size + (mp->buf_size >> 2)));
+ }
+ }
+ (void) memcpy ((mp->buffer + mp->first), s, size);
+ }
+ free (s);
+ return true;
+}
+@y
+static boolean mp_input_ln (MP mp, void *f ) {
+ int i = EOF;
+ mp->last = input_line2((FILE *)f, mp->buffer, mp->first, mp->buf_size, &i);
+ if (i == EOF && errno != EINTR && mp->last == mp->first)
+ return false;
+ if (i != EOF && i != '\n' && i != '\r') {
+ fprintf (stderr, "! Unable to read an entire line---bufsize=%u.\n",
+ (unsigned) mp->buf_size);
+ fputs ("Please increase buf_size in texmf.cnf.\n", stderr);
+ exit (1);
+ }
+ if (i == '\r') {
+ while ((i = getc ((FILE *)f)) == EOF && errno == EINTR)
+ ;
+ if (i != '\n')
+ ungetc (i, f);
+ }
+ return true;
+}
+@z
+
+@x
+wterm (mp->banner);
+@y
+wterm (mp->banner);
+wterm(" (");
+wterm(getencstring());
+wterm(")");
+@z
+
+@x
+} four_quarters;
+typedef union {
+ integer sc;
+ four_quarters qqqq;
+} font_data;
+@y
+} four_quarters;
+typedef struct {
+ halfword RH, LH;
+} two_halves;
+typedef union {
+ two_halves hh;
+ integer sc;
+ four_quarters qqqq;
+} font_data;
+@z
+
+%
+% tategaki support
+%
+% Suppose h==(0,height), d==(0,-depth) && w==(width,0) in horizontal string,
+% && h==(height,0), d==(-depth,0) && w==(0,-width) in vertical string.
+% Four vertices of the bounding box is h, d, h+w && d+w && those of the
+% transformed boundig box is Th, Td, T(h+w) && T(d+w), so that the values
+% of Th, Td && Tw are compared here.
+
+@x
+@ The height width and depth information stored in a text node determines a
+rectangle that needs to be transformed according to the transformation
+parameters stored in the text node.
+
+@y
+@ The height width and depth information stored in a text node determines a
+rectangle that needs to be transformed according to the transformation
+parameters stored in the text node.
+
+Boundig box depends on JFM font ID.
+
+@d yoko_jfm_id 11 /* `yoko-kumi' fonts */
+@d tate_jfm_id 9 /* `tate-kumi' fonts */
+@d font_jfm_p(A) (mp->font_id[(A)]!=0)
+
+@z
+
+@x
+ mp_number x0a, y0a, x1a, y1a, arg1;
+ mp_text_node p0 = (mp_text_node)p;
+ new_number (x0a);
+ new_number (x1a);
+ new_number (y0a);
+ new_number (y1a);
+ new_number (arg1);
+ number_clone (arg1, p0->depth);
+ number_negate (arg1);
+ take_scaled (x1a, p0->txx, p0->width);
+ take_scaled (y0a, p0->txy, arg1);
+ take_scaled (y1a, p0->txy, p0->height);
+@y
+ mp_number x0a, y0a, x1a, y1a, arg1, arg2;
+ mp_text_node p0 = (mp_text_node)p;
+ new_number (x0a);
+ new_number (x1a);
+ new_number (y0a);
+ new_number (y1a);
+ new_number (arg1);
+ new_number (arg2);
+ number_clone (arg1, p0->depth);
+ number_negate (arg1);
+ number_clone (arg2, p0->width);
+ number_negate (arg2);
+ if ( mp->font_id[mp_font_n(p)]!=tate_jfm_id ) {
+ take_scaled (x1a, p0->txx, p0->width);
+ take_scaled (y0a, p0->txy, arg1);
+ take_scaled (y1a, p0->txy, p0->height);
+ } else {
+ take_scaled (x1a, p0->txy, arg2);
+ take_scaled (y0a, p0->txx, arg1);
+ take_scaled (y1a, p0->txx, p0->height);
+ }
+@z
+
+@x
+ take_scaled (x1a, p0->tyx, p0->width);
+ number_clone (arg1, p0->depth);
+ number_negate (arg1);
+ take_scaled (y0a, p0->tyy, arg1);
+ take_scaled (y1a, p0->tyy, p0->height);
+@y
+ if ( mp->font_id[mp_font_n(p)]!=tate_jfm_id ) {
+ take_scaled (x1a, p0->tyx, p0->width);
+ number_clone (arg1, p0->depth);
+ number_negate (arg1);
+ take_scaled (y0a, p0->tyy, arg1);
+ take_scaled (y1a, p0->tyy, p0->height);
+ } else {
+ number_clone (arg1, p0->depth);
+ number_negate (arg1);
+ number_clone (arg2, p0->width);
+ number_negate (arg2);
+ take_scaled (x1a, p0->tyy, arg2);
+ take_scaled (y0a, p0->tyx, arg1);
+ take_scaled (y1a, p0->tyx, p0->height);
+ }
+@z
+
+@x
+ wlog (mp->banner);
+@y
+ wlog (mp->banner);
+ wlog (" (");
+ wlog (getencstring());
+ wlog (")");
+@z
+
+%
+% char type pointers
+@x
+eight_bits *font_bc;
+eight_bits *font_ec; /* first and last character code */
+@y
+eight_bits *font_bc;
+eight_bits *font_ec; /* first and last character code */
+halfword *font_nt;
+halfword *font_id;
+@z
+
+@x
+int *char_base; /* base address for |char_info| */
+@y
+int *char_base; /* base address for |char_info| */
+int *ctype_base;
+@z
+
+@x
+xfree (mp->char_base);
+@y
+xfree (mp->font_id);
+xfree (mp->font_nt);
+xfree (mp->char_base);
+xfree (mp->ctype_base);
+@z
+
+@x
+ XREALLOC (mp->char_base, l, int);
+@y
+ XREALLOC (mp->font_id, l, halfword);
+ XREALLOC (mp->font_nt, l, halfword);
+ XREALLOC (mp->char_base, l, int);
+ XREALLOC (mp->ctype_base, l, int);
+@z
+
+
+@x
+mp->char_base[null_font] = 0;
+@y
+mp->font_id[null_font] = 0;
+mp->font_nt[null_font] = 0;
+mp->char_base[null_font] = 0;
+mp->ctype_base[null_font] = 0;
+@z
+
+@x
+@d char_mp_info(A,B) mp->font_info[mp->char_base[(A)]+(B)].qqqq
+@y
+@d char_mp_info(A,B) mp->font_info[mp->char_base[(A)]+(B)].qqqq
+@d ctype_char_end(A) (A)].hh.LH
+@d ctype_char(A) mp->font_info[mp->ctype_base[(A)]+ctype_char_end
+@d ctype_type_end(A) (A)].hh.RH
+@d ctype_type(A) mp->font_info[mp->ctype_base[(A)]+ctype_type_end
+@z
+
+%
+% lookup character type table
+@x
+void mp_set_text_box (MP mp, mp_text_node p) {
+@y
+@<Declare JFM function for text measuring@>;
+void mp_set_text_box (MP mp, mp_text_node p) {
+@z
+
+@x
+ if ((*(mp_text_p (p)->str + k) < bc) || (*(mp_text_p (p)->str + k) > ec)) {
+ mp_lost_warning (mp, f, *(mp_text_p (p)->str + k));
+ } else {
+ cc = char_mp_info (f, *(mp_text_p (p)->str + k));
+@y
+ if ( ((*(mp_text_p (p)->str + k) < bc) || (*(mp_text_p (p)->str + k) > ec)) && (mp->font_id[f]==0) ) {
+ mp_lost_warning (mp, f, *(mp_text_p (p)->str + k));
+ } else {
+ if (mp->font_id[f]!=0) {
+#ifdef UPMP
+ integer cx; /* code for Japanese two byte character */
+ if (multistrlen(mp_text_p (p)->str, kk, k)>1) {
+ cx=fromBUFF(mp_text_p (p)->str, kk, k);
+ k=k+multistrlen(mp_text_p (p)->str, kk, k)-1;
+ } else {
+ cx=*(mp_text_p (p)->str + k);
+ }
+ cc=char_mp_info(f,mp_lookup_ctype(mp, f, cx));
+#else
+ cc=char_mp_info(f,mp_lookup_ctype(mp, f,fromBUFF(mp_text_p(p)->str,limit,k)));
+ k++;
+#endif
+ } else {
+ cc = char_mp_info (f, *(mp_text_p (p)->str + k));
+ }
+@z
+
+@x
+@* Debugging.
+@y
+@ @<Declare JFM function for text measuring@>=
+static int mp_lookup_ctype (MP mp,font_number f, integer c)
+{
+ int l, u, r, ch;
+ l=0; u=mp->font_nt[f]-1;
+ while ( l<u ) {
+ r=(l+u)/2;
+ ch=ctype_char(f)(r);
+ if ( ch==c ) {
+ return ctype_type(f)(r);};
+ if ( ch<c ) l=r+1;
+ else u=r-1;
+ };
+ return 0;
+}
+@* Debugging.
+@z
diff --git a/Build/source/texk/web2c/pmpostdir/pmpost.ch b/Build/source/texk/web2c/pmpostdir/pmpost.ch
new file mode 100644
index 00000000000..b16981d0ecc
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/pmpost.ch
@@ -0,0 +1,315 @@
+@x
+#include <kpathsea/kpathsea.h>
+@y
+#include <kpathsea/kpathsea.h>
+#include <ptexenc/ptexenc.h>
+char kanjioption[16];
+@z
+
+@x
+@d TEX "tex"
+@y
+@d TEX "e"@= @>P_UP@= @>"tex"
+@z
+
+@x
+#define MPXCOMMAND "makempx"
+@y
+#define MPXCOMMAND P_UP@= @>"makempx"
+@z
+
+@x
+ if (cnf_cmd!=NULL && (strcmp (cnf_cmd, "1")!=0)) {
+ if (mp_troff_mode(mp)!=0)
+ cmd = concatn (cnf_cmd, " -troff ",
+ qmpname, " ", qmpxname, NULL);
+ else if (mpost_tex_program!=NULL && *mpost_tex_program != '\0')
+ cmd = concatn (cnf_cmd, " -tex=", mpost_tex_program, " ",
+ qmpname, " ", qmpxname, NULL);
+@y
+ if (cnf_cmd!=NULL && (strcmp (cnf_cmd, "1")!=0)) {
+ if (kanjioption[0])
+ cnf_cmd = concatn (cnf_cmd, " --kanji=", kanjioption, NULL);
+ if (mp_troff_mode(mp))
+ cmd = concatn (cnf_cmd, " -troff ",
+ qmpname, " ", qmpxname, NULL);
+ else if (mpost_tex_program!=NULL && *mpost_tex_program != '\0')
+ cmd = concatn (cnf_cmd, " -tex=", mpost_tex_program, " ",
+ qmpname, " ", qmpxname, NULL);
+@z
+
+@x
+ if (mpost_tex_program != NULL && *mpost_tex_program != '\0') {
+ maincmd = mpost_xstrdup(mpost_tex_program);
+ } else {
+ if (mpxmode == mpx_tex_mode) {
+ s = kpse_var_value("TEX");
+ if (s==NULL) s = kpse_var_value("MPXMAINCMD");
+ if (s==NULL) s = mpost_xstrdup (TEX);
+ maincmd = (char *)mpost_xmalloc (strlen(s)+strlen(default_args)+1);
+ strcpy(maincmd,s);
+@y
+ if (mpost_tex_program != NULL && *mpost_tex_program != '\0') {
+ if (kanjioption[0]) {
+ maincmd = (char *)mpost_xmalloc (strlen(mpost_tex_program) +
+ strlen(kanjioption) + 15);
+ strcpy(maincmd, mpost_tex_program);
+ strcat(maincmd, " --kanji=");
+ strcat(maincmd, kanjioption);
+ } else
+ maincmd = mpost_xstrdup(mpost_tex_program);
+ } else {
+ if (mpxmode == mpx_tex_mode) {
+ s = kpse_var_value("TEX");
+ if (s==NULL) s = kpse_var_value("MPXMAINCMD");
+ if (s==NULL) s = mpost_xstrdup (TEX);
+ if (kanjioption[0])
+ maincmd = (char *)mpost_xmalloc (strlen(s)+strlen(default_args)+
+ strlen(kanjioption)+13);
+ else
+ maincmd = (char *)mpost_xmalloc (strlen(s)+strlen(default_args)+1);
+ strcpy(maincmd,s);
+ if (kanjioption[0]) {
+ strcat(maincmd, " --kanji=");
+ strcat(maincmd, kanjioption);
+ }
+@z
+
+@x
+ const char *banner = "% Written by metapost version ";
+@y
+ const char *banner = "% Written by "@= @>P_UP@= @>"mpost version ";
+@z
+
+@x
+ const char *banner = "% Written by dvitomp version ";
+@y
+ const char *banner = "% Written by "@= @>P_UP@= @>"dvitomp version ";
+@z
+
+@x
+ { "kpathsea-debug", 1, 0, 0 },
+@y
+ { "kpathsea-debug", 1, 0, 0 },
+ { "kanji", 1, 0, 0 },
+@z
+
+@x
+ } else if (ARGUMENT_IS ("interaction")) {
+@y
+ } else if (ARGUMENT_IS ("kanji")) {
+ if (optarg) {
+ if (strlen(optarg) > 15) {
+ optarg[15] = '\0';
+ }
+ strcpy(kanjioption, optarg);
+ if (!set_enc_string(optarg, NULL)) {
+ fprintf(stderr,"Ignoring unknown argument `%s' to --kanji\n", optarg);
+ }
+ }
+
+ } else if (ARGUMENT_IS ("interaction")) {
+@z
+
+@x
+ { "no-kpathsea", 0, &nokpse, 1 },
+@y
+ { "no-kpathsea", 0, &nokpse, 1 },
+ { "kanji", 1, 0, 0 },
+@z
+
+@x
+ } else if (option_is ("progname")) {
+ user_progname = optarg;
+@y
+ } else if (option_is ("progname")) {
+ user_progname = optarg;
+ } else if (option_is ("kanji")) {
+ if (optarg) {
+ if (strlen(optarg) > 15) {
+ optarg[15] = '\0';
+ }
+ strcpy (kanjioption, optarg);
+ if (!set_enc_string(optarg, NULL)) {
+ fprintf(stderr,"Ignoring unknown argument `%s' to --kanji\n", optarg);
+ }
+ }
+@z
+
+@x
+ fprintf(stdout, "This is dvitomp %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+else
+ fprintf(stdout, "This is MetaPost %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+@y
+ fprintf(stdout, "This is "@= @>P_UP@= @>"dvitomp %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+else
+ fprintf(stdout, "This is "@= @>P_UP@= @>"MetaPost %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+@z
+
+@x
+"Usage: mpost [OPTION] [&MEMNAME] [MPNAME[.mp]] [COMMANDS]\n"
+" mpost --dvitomp DVINAME[.dvi] [MPXNAME[.mpx]]\n"
+"\n"
+" Run MetaPost on MPNAME, usually creating MPNAME.NNN (and perhaps\n"
+" MPNAME.tfm), where NNN are the character numbers generated.\n"
+" Any remaining COMMANDS are processed as MetaPost input,\n"
+" after MPNAME is read.\n\n"
+" With a --dvitomp argument, MetaPost acts as DVI-to-MPX converter only.\n"
+" Call MetaPost with --dvitomp --help for option explanations.\n\n");
+fprintf(stdout,
+" -ini be inimpost, for dumping mem files\n"
+@y
+"Usage: "@= @>P_UP@= @>"mpost [OPTION] [&MEMNAME] [MPNAME[.mp]] [COMMANDS]\n"
+" "@= @>P_UP@= @>"mpost --dvitomp DVINAME[.dvi] [MPXNAME[.mpx]]\n"
+"\n"
+" Run "@= @>P_UP@= @>"MetaPost on MPNAME, usually creating MPNAME.NNN (and perhaps\n"
+" MPNAME.tfm), where NNN are the character numbers generated.\n"
+" Any remaining COMMANDS are processed as "@= @>P_UP@= @>"MetaPost input,\n"
+" after MPNAME is read.\n\n"
+" With a --dvitomp argument, "@= @>P_UP@= @>"MetaPost acts as DVI-to-MPX converter only.\n"
+" Call "@= @>P_UP@= @>"MetaPost with --dvitomp --help for option explanations.\n\n");
+fprintf(stdout,
+" -ini be ini"@= @>P_UP@= @>"mpost, for dumping mem files\n"
+@z
+
+@x
+" -jobname=STRING set the job name to STRING\n"
+@y
+" -jobname=STRING set the job name to STRING\n"
+" -kanji=STRING set the Japanese encoding to STRING\n"
+@z
+
+@x
+" -version output version information and exit\n"
+"\n"
+"Email bug reports to mp-implementors@@tug.org.\n"
+@y
+" -version output version information and exit\n"
+@z
+
+@x
+ fprintf(stdout, "This is dvitomp %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+else
+ fprintf(stdout, "This is MetaPost %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+@y
+ fprintf(stdout, "This is "@= @>P_UP@= @>"dvitomp %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+else
+ fprintf(stdout, "This is "@= @>P_UP@= @>"MetaPost %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+@z
+
+@x
+"Usage: dvitomp DVINAME[.dvi] [MPXNAME[.mpx]]\n"
+" mpost --dvitomp DVINAME[.dvi] [MPXNAME[.mpx]]\n"
+@y
+"Usage: "@= @>P_UP@= @>"dvitomp DVINAME[.dvi] [MPXNAME[.mpx]]\n"
+" "@= @>P_UP@= @>"mpost --dvitomp DVINAME[.dvi] [MPXNAME[.mpx]]\n"
+@z
+
+@x
+" -progname=STRING set program name to STRING\n"
+@y
+" -progname=STRING set program name to STRING\n"
+#ifdef UPMP
+" -kanji=STRING set kanji encoding (STRING=euc|jis|sjis|utf8|uptex)\n"
+#else
+" -kanji=STRING set kanji encoding (sjis, jis, euc, utf8)\n"
+#endif
+@z
+
+@x
+ fprintf(stdout, "dvitomp (MetaPost) %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+else
+ fprintf(stdout, "MetaPost %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+@y
+ fprintf(stdout, P_UP@= @>"dvitomp ("@= @>P_UP@= @>"MetaPost) %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+else
+ fprintf(stdout, P_UP@= @>"MetaPost %s" WEB2CVERSION " (%s)\n", s, kpathsea_version_string);
+@z
+
+@x
+"Current maintainer of MetaPost: Luigi Scarso.\n\n"
+@y
+"Current maintainer of MetaPost: Luigi Scarso.\n"
+#ifdef UPMP
+"Authors of upMetaPost: Michio Matsuyama, Hideyuki Suzuki, Takuji Tanaka.\n\n"
+#else
+"Authors of pMetaPost: Michio Matsuyama, Hideyuki Suzuki.\n\n"
+#endif
+@z
+
+@x
+ const char * banner = "This is MetaPost, version ";
+@y
+ const char * banner = "This is "@= @>P_UP@= @>"MetaPost, version ";
+@z
+
+@x
+@<Declarations@>=
+#define DLLPROC dllmpostmain
+@y
+@<Declarations@>=
+#ifdef UPMP
+#define DLLPROC dllupmpostmain
+#else
+#define DLLPROC dllpmpostmain
+#endif
+@z
+
+@x
+ if (FILESTRCASEEQ(base, "rmpost")){
+@y
+ if (FILESTRCASEEQ(base, "r"@= @>P_UP@= @>"mpost")){
+@z
+
+@x
+ } else if (FILESTRCASEEQ(base, "r-mpost")){
+@y
+ } else if (FILESTRCASEEQ(base, "r-"@= @>P_UP@= @>"mpost")){
+@z
+
+@x
+ if (FILESTRCASEEQ(base, "dvitomp"))
+@y
+ if (FILESTRCASEEQ(base, P_UP@= @>"dvitomp"))
+@z
+
+@x
+ if (dvitomp_only) {
+ @<Read and set \.{dvitomp} command line options@>;
+ } else {
+@y
+ kanjioption[0] = '\0';
+#ifdef UPMP
+ enable_UPTEX (true);
+ set_enc_string("uptex", "uptex");
+#else
+ enable_UPTEX (false);
+#if defined(WIN32)
+ set_enc_string("utf8", "sjis");
+#else
+ set_enc_string("utf8", "euc");
+#endif
+#endif
+
+ if (dvitomp_only) {
+ @<Read and set \.{dvitomp} command line options@>;
+ } else {
+@z
+
+@x
+ if (FILESTRCASEEQ(kpse_program_name, "rmpost"))
+@y
+ if (FILESTRCASEEQ(kpse_program_name, "r"@= @>P_UP@= @>"mpost"))
+@z
+
+@x
+ else if (FILESTRCASEEQ(kpse_program_name, "r-mpost"))
+@y
+ else if (FILESTRCASEEQ(kpse_program_name, "r-"@= @>P_UP@= @>"mpost"))
+@z
+
+@x
+ if(putenv(xstrdup("engine=metapost")))
+@y
+ if(putenv(xstrdup("engine="@= @>P_UP@= @>"mpost")))
+@z
diff --git a/Build/source/texk/web2c/pmpostdir/pmpost.test b/Build/source/texk/web2c/pmpostdir/pmpost.test
new file mode 100755
index 00000000000..07be9d3c6bc
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/pmpost.test
@@ -0,0 +1,14 @@
+#! /bin/sh -vx
+# $Id$
+# Copyright 2017 Karl Berry <tex-live@tug.org>
+# Copyright 2014 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+./pmpost -version || exit 1
+
+./pmpost -help || exit 1
+
+./pmpost -dvitomp -version || exit 1
+
+./pmpost -dvitomp -help || exit 1
+
diff --git a/Build/source/texk/web2c/pmpostdir/pmpsamp.test b/Build/source/texk/web2c/pmpostdir/pmpsamp.test
new file mode 100755
index 00000000000..19586a0a39d
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/pmpsamp.test
@@ -0,0 +1,42 @@
+#! /bin/sh -vx
+# $Id$
+# Copyright 2017-2018 Karl Berry <tex-live@tug.org>
+# Copyright 2014 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+LC_ALL=C; export LC_ALL; LANGUAGE=C; export LANGUAGE
+
+tests=pmpostdir/tests
+
+test -d $tests || mkdir -p $tests
+
+TEXMFCNF=$srcdir/../kpathsea
+
+tfmpath=`$KPSEWHICH cmr10.tfm` || exit 77
+TFMFONTS="$srcdir/$tests;`echo $tfmpath | sed 's,/fonts/tfm/.*$,/fonts/tfm//,'`"
+
+mppath=`$KPSEWHICH plain.mp` || exit 77
+MPINPUTS=".;`dirname $mppath`"
+
+mappath=`$KPSEWHICH psfonts.map` || exit 77
+TEXFONTMAPS=`echo $mappath | sed 's,/fonts/map/.*$,/fonts/map//,'`
+
+t1path=`$KPSEWHICH cmmi10.pfb` || exit 77
+T1FONTS="$srcdir/$tests;`echo $t1path | sed 's,/fonts/type1/.*$,/fonts/type1//,'`"
+
+vfpath=`$KPSEWHICH min10.vf` || exit 77
+VFFONTS="$srcdir/$tests;`dirname $vfpath`"
+
+export TEXMFCNF TFMFONTS MPINPUTS TEXFONTMAPS T1FONTS VFFONTS
+
+# check that we have eptex at all.
+eptex -version >/dev/null 2>&1 || exit 77
+
+# ensure that eptex.fmt exists and can be read.
+eptex \\end >/dev/null 2>&1 || exit 77
+
+echo 'input plain;' >pmpsamp.mp
+cat "$srcdir/$tests/psample.mp" >>pmpsamp.mp
+
+./pmpost -ini -kanji=utf8 -tex=eptex pmpsamp || exit 1
+
diff --git a/Build/source/texk/web2c/pmpostdir/pmpxout.ch b/Build/source/texk/web2c/pmpostdir/pmpxout.ch
new file mode 100644
index 00000000000..ae6345ffcda
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/pmpxout.ch
@@ -0,0 +1,556 @@
+@x
+\def\MP{MetaPost}
+@y
+\def\MP{MetaPost}
+\def\pTeX{p\kern-.15em\TeX}
+@z
+
+@x
+#include "avl.h"
+@y
+#include "avl.h"
+#include <ptexenc/ptexenc.h>
+@z
+
+@x
+@d virtual_space 1000000 /* maximum total bytes of typesetting commands for virtual fonts */
+@d max_fonts 1000 /* maximum number of distinct fonts per \.{DVI} file */
+@d max_fnums 3000 /* maximum number of fonts plus fonts local to virtual fonts */
+@d max_widths (256*max_fonts) /* maximum number of different characters among all fonts */
+@d line_length 79 /* maximum output line length (must be at least 60) */
+@d stack_size 100 /* \.{DVI} files shouldn't |push| beyond this depth */
+@d font_tolerance 0.00001
+@y
+@ @<Glob...@>=
+#ifdef UPMP
+#define virtual_space 2000000 /* maximum total bytes of typesetting commands for virtual fonts */
+#else
+#define virtual_space 1000000 /* maximum total bytes of typesetting commands for virtual fonts */
+#endif
+#define max_fonts 1000 /* maximum number of distinct fonts per \.{DVI} file */
+#define max_fnums 3000 /* maximum number of fonts plus fonts local to virtual fonts */
+#ifdef UPMP
+#define max_widths 2000000 /* maximum number of different characters among all fonts */
+#else
+#define max_widths 512000 /* maximum number of different characters among all fonts */
+#endif
+#define line_length 79 /* maximum output line length (must be at least 60) */
+#define stack_size 100 /* \.{DVI} files shouldn't |push| beyond this depth */
+#define font_tolerance 0.00001
+@z
+
+@x
+@d undefined_commands 250: case 251: case 252: case 253: case 254: case 255
+@y
+@d dir 255 /* \pTeX\ direction */
+@d undefined_commands 250: case 251: case 252: case 253: case 254
+@z
+
+@x
+mpx_read_tfm_word(mpx); lh=mpx->b2*(int)(256)+mpx->b3;
+@y
+mpx_read_tfm_word(mpx);
+@<Read the pTeX header data@>;@/
+lh=mpx->b2*(int)(256)+mpx->b3;
+@z
+
+@x
+ if ( mpx->b0<128 )
+ mpx->tfm_check_sum=((mpx->b0*(int)(256)+mpx->b1)*256+mpx->b2)*256+mpx->b3;
+ else
+ mpx->tfm_check_sum=(((mpx->b0-256)*(int)(256)+mpx->b1)*256+mpx->b2)*256+mpx->b3;
+ }
+ if ( k==5 ) {
+ if (mpx->mode == mpx_troff_mode) {
+ mpx->font_design_size[f]=(((mpx->b0*(int)(256)+mpx->b1)*256+mpx->b2)*256+mpx->b3)/(65536.0*16);
+ }
+ }
+}
+@y
+ if ( mpx->b0<128 )
+ mpx->tfm_check_sum=((mpx->b0*(int)(256)+mpx->b1)*256+mpx->b2)*256+mpx->b3;
+ else
+ mpx->tfm_check_sum=(((mpx->b0-256)*(int)(256)+mpx->b1)*256+mpx->b2)*256+mpx->b3;
+ }
+ if ( k==5 ) {
+ if (mpx->mode == mpx_troff_mode) {
+ mpx->font_design_size[f]=(((mpx->b0*(int)(256)+mpx->b1)*256+mpx->b2)*256+mpx->b3)/(65536.0*16);
+ }
+ }
+}
+@<Read JFM character type table@>;
+@z
+
+@x
+@<Width of character |c| in font |f|@>=
+floor(mpx->dvi_scale*mpx->font_scaled_size[f]*char_width(f,c))
+
+@ @<Width of character |p| in font |cur_font|@>=
+floor(mpx->dvi_scale*mpx->font_scaled_size[cur_font]*char_width(cur_font,p))
+@y
+@ @c @<Declare JFM character type table lookup routine@>@; /* \pTeX */
+static integer mpx_scaled_char_width (MPX mpx,integer f,integer c)
+{
+ if (mpx->font_id[f]!=0) c=mpx_lookup_ctype(mpx, f,c);
+ return floor(mpx->dvi_scale*mpx->font_scaled_size[f]*char_width(f,c));
+}
+@z
+
+@x
+@ @c @<Declare a procedure called |finish_last_char|@>@;
+static void mpx_do_set_char (MPX mpx,web_integer f, web_integer c) {
+ if ( (c<mpx->font_bc[f])||(c>mpx->font_ec[f]) )
+ mpx_abort(mpx,"attempt to typeset invalid character %d",c);
+@.attempt to typeset...@>
+@y
+@ (u)pDVItoMP: |do_set_char| is called with non-virtual font.
+In the case of non-virtual Kanji font, the width is looked up
+with the character type, and the character is printed by the
+function |set_kanji_char|.
+
+When the width written in the virtual font is same as
+the width of the substituted font, the next character can be
+written in the same string in output mpx file.
+In other words, the width of the character is calculated
+in |do_dvi_commands|. So even if the width is wrong here, the output PostScript file is not affected.
+
+@ @c @<Declare a procedure called |finish_last_char|@>@;
+static void mpx_do_set_char (MPX mpx,integer f,integer c)
+{
+integer kkk;
+
+if (mpx->font_id[f]!=0) {
+ kkk=mpx_lookup_ctype(mpx, f,c);
+ if ( (kkk<mpx->font_bc[f]) || (kkk>mpx->font_ec[f]) )
+ mpx_abort(mpx,"attempt to typeset invalid character (JFM) %d",c);
+} else if ( (c<mpx->font_bc[f])||(c>mpx->font_ec[f]) ) {
+ mpx_abort(mpx,"attempt to typeset invalid character %d",c);
+}
+@.attempt to typeset...@>
+@z
+
+@x
+ if ((mpx->h!=mpx->str_h2)||(mpx->v!=mpx->str_v)||
+ (f!=mpx->str_f)||(mpx->dvi_scale!=mpx->str_scale) ) {
+@y
+ if ((mpx->h!=mpx->str_h2)||(mpx->v!=mpx->str_v2)||
+ (f!=mpx->str_f)||(mpx->dvi_scale!=mpx->str_scale) ) {
+@z
+
+@x
+ fprintf(mpx->mpxfile,"_s("); mpx->print_col=3;@/
+ mpx->str_scale=mpx->dvi_scale; mpx->str_f=f;
+ mpx->str_v=mpx->v; mpx->str_h1=mpx->h;
+@y
+ if ((mpx->d==0) || (mpx->font_id[f]==9)) {
+ fprintf(mpx->mpxfile,"_s("); mpx->print_col=3;}@/
+ else {
+ fprintf(mpx->mpxfile,"_sr("); mpx->print_col=4;}@/
+ mpx->str_scale=mpx->dvi_scale; mpx->str_f=f;
+ mpx->str_v1=mpx->v; mpx->str_h1=mpx->h;
+@z
+
+@x
+ mpx_print_char(mpx, (unsigned char)c);
+ mpx->str_h2=(web_integer)(mpx->h+@<Width of character |c| in font |f|@>);
+@y
+ if (mpx->font_id[f]!=0)
+ mpx_print_kanji_char(mpx, c);
+ else
+ mpx_print_char(mpx, c);
+ if (mpx->d==0) {
+ mpx->str_h2=mpx->h+mpx_scaled_char_width(mpx, f, c);
+ mpx->str_v2=mpx->v;
+ } else {
+ mpx->str_h2=mpx->h;
+ mpx->str_v2=mpx->v+mpx_scaled_char_width(mpx, f, c);
+ }
+@z
+
+@x
+web_integer str_h1;
+web_integer str_v; /* starting position for current output string */
+web_integer str_h2; /* where the current output string ends */
+@y
+integer str_h1;
+integer str_v1; /* starting position for current output string */
+integer str_h2;
+integer str_v2; /* where the current output string ends */
+@z
+
+@x
+ fprintf(mpx->mpxfile,"vardef _s(expr _t,_f,_m,_x,_y)(text _c)=\n");
+ fprintf(mpx->mpxfile,
+ " addto _p also _t infont _f scaled _m shifted (_x,_y) _c; enddef;\n");
+@y
+ fprintf(mpx->mpxfile,"vardef _s(expr _t,_f,_m,_x,_y)(text _c)=\n");
+ fprintf(mpx->mpxfile,
+ " addto _p also _t infont _f scaled _m shifted (_x,_y) _c; enddef;\n");
+ fprintf(mpx->mpxfile,"vardef _sr(expr _t,_f,_m,_x,_y)=\n");
+ fprintf(mpx->mpxfile," addto _p also _t infont _f rotated -90");
+ fprintf(mpx->mpxfile," scaled _m shifted (_x,_y); enddef;\n");
+@z
+
+@x
+ x=mpx->conv*mpx->str_h1;
+ y=mpx->conv*(-mpx->str_v);
+@y
+ x=mpx->conv*mpx->str_h1;
+ y=mpx->conv*(-mpx->str_v1);
+@z
+
+@x
+@<Handle a special rule that determines the box size@>=
+{
+ mpx->pic_wd=mpx->h; mpx->pic_dp=mpx->v; mpx->pic_ht=ht-mpx->v;
+}
+@y
+@<Handle a special rule that determines the box size@>=
+{ if (mpx->d==0) {
+ mpx->pic_wd=mpx->h; mpx->pic_dp=mpx->v; mpx->pic_ht=ht-mpx->v;
+ } else {
+ mpx->pic_wd=mpx->v; mpx->pic_dp=-mpx->h; mpx->pic_ht=ht+mpx->h;
+ }
+}
+@z
+
+@x
+ mpx->str_v=0;
+ mpx->str_h2=0;
+ mpx->str_scale=1.0; /* values don't matter */
+@y
+ mpx->str_h2=0;
+ mpx->str_v2=0;
+ mpx->str_scale=1.0; /* values don't matter */
+@z
+
+@x
+dd=-mpx->pic_dp*mpx->conv;
+w=mpx->conv*mpx->pic_wd;
+h=mpx->conv*mpx->pic_ht;
+fprintf(mpx->mpxfile,
+ "setbounds _p to (0,%1.4f)--(%1.4f,%1.4f)--\n"
+ " (%1.4f,%1.4f)--(0,%1.4f)--cycle;\n",dd,w,dd,w,h,h)
+@y
+if (mpx->d==0) {
+ dd=-mpx->pic_dp*mpx->conv;
+ w=mpx->conv*mpx->pic_wd;
+ h=mpx->conv*mpx->pic_ht;
+ fprintf(mpx->mpxfile,
+ "setbounds _p to (0,%1.4f)--(%1.4f,%1.4f)--\n",dd,w,dd);
+ fprintf(mpx->mpxfile,
+ " (%1.4f,%1.4f)--(0,%1.4f)--cycle;\n",w,h,h);
+} else {
+ dd=-mpx->pic_dp*mpx->conv;
+ w=-mpx->pic_wd*mpx->conv;
+ h=mpx->conv*mpx->pic_ht;
+ fprintf(mpx->mpxfile,
+ "setbounds _p to (%1.4f,0)--(%1.4f,%1.4f)--\n",h,h,w);
+ fprintf(mpx->mpxfile,
+ " (%1.4f,%1.4f)--(%1.4f,0)--cycle;\n", dd,w,dd);
+}
+@z
+
+@x
+web_integer w;web_integer x;web_integer y;web_integer z;
+ /* current state values (|h| and |v| have already been declared) */
+web_integer hstack[(stack_size+1)];
+web_integer vstack[(stack_size+1)];
+web_integer wstack[(stack_size+1)];
+web_integer xstack[(stack_size+1)];
+web_integer ystack[(stack_size+1)];
+web_integer zstack[(stack_size+1)]; /* pushed down values in \.{DVI} units */
+@y
+integer w;integer x;integer y;integer z;integer d;
+ /* current state values (|h| and |v| have already been declared) */
+integer hstack[(stack_size+1)];
+integer vstack[(stack_size+1)];
+integer wstack[(stack_size+1)];
+integer xstack[(stack_size+1)];
+integer ystack[(stack_size+1)];
+integer zstack[(stack_size+1)];
+integer dstack[(stack_size+1)]; /* pushed down values in \.{DVI} units */
+@z
+
+@x
+mpx->h=0; mpx->v=0;
+@y
+mpx->h=0; mpx->v=0; mpx->d=0;
+@z
+
+@x
+ mpx->hstack[mpx->stk_siz]=mpx->h;
+ mpx->vstack[mpx->stk_siz]=mpx->v; mpx->wstack[mpx->stk_siz]=mpx->w;
+ mpx->xstack[mpx->stk_siz]=mpx->x;
+ mpx->ystack[mpx->stk_siz]=mpx->y; mpx->zstack[mpx->stk_siz]=mpx->z;
+@y
+ mpx->hstack[mpx->stk_siz]=mpx->h;
+ mpx->vstack[mpx->stk_siz]=mpx->v; mpx->wstack[mpx->stk_siz]=mpx->w;
+ mpx->xstack[mpx->stk_siz]=mpx->x;
+ mpx->ystack[mpx->stk_siz]=mpx->y; mpx->zstack[mpx->stk_siz]=mpx->z;
+ mpx->dstack[mpx->stk_siz]=mpx->d;
+@z
+
+@x
+ mpx->h=mpx->hstack[mpx->stk_siz];
+ mpx->v=mpx->vstack[mpx->stk_siz]; mpx->w=mpx->wstack[mpx->stk_siz];
+ mpx->x=mpx->xstack[mpx->stk_siz];
+ mpx->y=mpx->ystack[mpx->stk_siz]; mpx->z=mpx->zstack[mpx->stk_siz];
+@y
+ mpx->h=mpx->hstack[mpx->stk_siz];
+ mpx->v=mpx->vstack[mpx->stk_siz]; mpx->w=mpx->wstack[mpx->stk_siz];
+ mpx->x=mpx->xstack[mpx->stk_siz];
+ mpx->y=mpx->ystack[mpx->stk_siz]; mpx->z=mpx->zstack[mpx->stk_siz];
+ mpx->d=mpx->dstack[mpx->stk_siz];
+@z
+
+@x
+ case z0: return mpx->z; break;
+@y
+ case z0: return mpx->z; break;
+ case dir: return mpx_get_byte(mpx); break;
+@z
+
+@x
+ mpx->h += @<Width of character |p| in font |cur_font|@>;
+@y
+ if (mpx->d==0) {
+ mpx->h+=mpx_scaled_char_width(mpx, cur_font, p);
+ } else {
+ mpx->v+=mpx_scaled_char_width(mpx, cur_font, p);
+ }
+@z
+
+@x
+ mpx->h += q;
+@y
+ if (mpx->d==0) {
+ mpx->h += q;
+ } else {
+ mpx->v += q;
+ }
+@z
+
+@x
+case pop:
+ mpx_do_pop(mpx);
+ break;
+@y
+case pop:
+ mpx_do_pop(mpx);
+ break;
+case dir:
+ mpx->d=p;
+ break;
+@z
+
+@x
+case four_cases(right1):
+ mpx->h += trunc(p*mpx->dvi_scale);
+ break;
+case w0: case four_cases(w1):
+ mpx->w = (web_integer)trunc(p*mpx->dvi_scale); mpx->h += mpx->w;
+ break;
+case x0: case four_cases(x1):
+ mpx->x = (web_integer)trunc(p*mpx->dvi_scale); mpx->h += mpx->x;
+ break;
+case four_cases(down1):
+ mpx->v += trunc(p*mpx->dvi_scale);
+ break;
+case y0: case four_cases(y1):
+ mpx->y = (web_integer)trunc(p*mpx->dvi_scale); mpx->v += mpx->y;
+ break;
+case z0: case four_cases(z1):
+ mpx->z = (web_integer)trunc(p*mpx->dvi_scale); mpx->v += mpx->z;
+ break;
+@y
+case four_cases(right1):
+ if (mpx->d==0) {
+ mpx->h+=trunc(p*mpx->dvi_scale);
+ } else {
+ mpx->v+=trunc(p*mpx->dvi_scale);
+ }
+ break;
+case w0: case four_cases(w1):
+ if (mpx->d==0) {
+ mpx->h+=mpx->w;
+ } else {
+ mpx->v+=mpx->w;
+ }
+ break;
+case x0: case four_cases(x1):
+ if (mpx->d==0) {
+ mpx->h+=mpx->x;
+ } else {
+ mpx->v+=mpx->x;
+ }
+ break;
+case four_cases(down1):
+ if (mpx->d==0) {
+ mpx->v+=trunc(p*mpx->dvi_scale);
+ } else {
+ mpx->h-=trunc(p*mpx->dvi_scale);
+ }
+ break;
+case y0: case four_cases(y1):
+ if (mpx->d==0) {
+ mpx->v+=mpx->y;
+ } else {
+ mpx->h-=mpx->y;
+ }
+ break;
+case z0: case four_cases(z1):
+ if (mpx->d==0) {
+ mpx->v+=mpx->z;
+ } else {
+ mpx->h-=mpx->z;
+ }
+ break;
+@z
+
+@x
+ mpx->progname = "dvitomp";
+@y
+#ifdef UPMP
+ mpx->progname = "updvitomp";
+#else
+ mpx->progname = "pdvitomp";
+#endif
+@z
+
+@x
+@<Check if mp file is newer than mpxfile, exit if not@>=
+if (mpx_newer(mpxopt->mpname, mpxopt->mpxname))
+ return 0
+@y
+@<Check if mp file is newer than mpxfile, exit if not@>=
+if (mpx_newer(mpxopt->mpname, mpxopt->mpxname))
+ return 0
+
+@ ASCII \pTeX\ JFM ID
+@d yoko_jfm_id 11 /* for `yoko-kumi' fonts */
+@d tate_jfm_id 9 /* for `tate-kumi' fonts */
+@d font_jfm_p(A) (mpx->font_id[(A)]!=0)
+
+@ @<Global...@>=
+integer font_nt[max_fonts+1]; /* number of words in ctype table */
+integer font_id[max_fonts+1];
+integer jfm_char_code[max_widths+1];
+integer jfm_char_type[max_widths+1];
+integer jfm_char_index[max_fonts+1];
+integer next_jfm_char_index;
+
+@ @<Set init...@>=
+mpx->font_nt[0]=0;
+mpx->font_id[0]=0;
+mpx->jfm_char_type[0]=0;
+mpx->next_jfm_char_index=0;
+
+@ JFM character type table is stored in the array |jfm_char_code| and
+|jfm_char_type|. The character code and the character type of $i$-th
+record is stored in |jfm_char_code[i]| and |jfm_char_type[i]|, respectively.
+The table is in the order of character code.
+
+@<Read the pTeX header data@>=
+mpx->font_id[f]=mpx->b0*(int)(256)+mpx->b1;
+if ((mpx->font_id[f]==yoko_jfm_id) || (mpx->font_id[f]==tate_jfm_id)) {
+ mpx->font_nt[f]=mpx->b2*(int)(256)+mpx->b3;
+ mpx_read_tfm_word(mpx);
+} else {
+ mpx->font_id[f]=0;
+ mpx->font_nt[f]=0;
+}
+
+@ @<Read JFM character type table@>=
+mpx->jfm_char_index[f]=mpx->next_jfm_char_index;
+k=mpx->jfm_char_index[f];
+mpx->next_jfm_char_index+=mpx->font_nt[f];
+while (k<mpx->next_jfm_char_index) {
+ mpx_read_tfm_word(mpx);
+ mpx->jfm_char_code[k]=mpx->b0*(int)(256)+mpx->b1;
+ mpx->jfm_char_type[k]=mpx->b2*(int)(256)+mpx->b3;
+ k++;
+}
+
+@ JFM character type table is looked up by binary search.
+
+@<Declare JFM character type table lookup routine@>=
+static integer mpx_lookup_ctype (MPX mpx,integer f, integer c)
+{
+ integer l, u, r, ch;
+ l=0; u=mpx->font_nt[f]-1;
+ while (l<u) {
+ r=(l+u)/2;
+ ch=mpx->jfm_char_code[mpx->jfm_char_index[f]+r];
+ if (ch==c) {
+ return mpx->jfm_char_type[mpx->jfm_char_index[f]+r];
+ }
+ if (ch<c)
+ l=r+1;
+ else
+ u=r-1;
+ }
+ return 0;
+}
+
+@ All Kanji characters are supposed to be printable here,
+so that the state always results in normal at the end of the procedure.
+Kanji characters need to be converted into output Kanji encoding
+from DVI(JIS).
+
+@<Declare subroutines for printing strings@>=
+static void mpx_print_kanji_char (MPX mpx,integer c)
+{
+#ifdef UPMP
+#define BYTE1(x) (((x)>>24) & 0xff)
+#define BYTE2(x) (((x)>>16) & 0xff)
+#define BYTE3(x) (((x)>> 8) & 0xff)
+#define BYTE4(x) ( (x) & 0xff)
+ int pflag = 0;
+#else
+#define Hi(x) (((x)>> 8) & 0xff)
+#define Lo(x) ( (x) & 0xff)
+#endif
+ if (mpx->print_col+2>line_length-2 ) {
+ if (mpx->state==normal) {
+ fprintf(mpx->mpxfile, "\"");
+ mpx->state=special;
+ }
+ fprintf(mpx->mpxfile, " \n");
+ mpx->print_col=0;
+ }
+ if (mpx->state==special) {
+ fprintf(mpx->mpxfile,"&");
+ mpx->print_col++;
+ }
+ if (mpx->state!=normal) {
+ fprintf(mpx->mpxfile, "\"");
+ mpx->print_col++;
+ mpx->state=normal;
+ }
+ c=toBUFF(fromDVI(c));
+#ifdef UPMP
+ if (BYTE1(c)!=0) pflag = 1;
+ if (pflag) {
+ putc2(BYTE1(c), mpx->mpxfile);
+ mpx->print_col++;
+ }
+ if (BYTE2(c)!=0) pflag = 1;
+ if (pflag) {
+ putc2(BYTE2(c), mpx->mpxfile);
+ mpx->print_col++;
+ }
+ if (BYTE3(c)!=0) pflag = 1;
+ if (pflag) {
+ putc2(BYTE3(c), mpx->mpxfile);
+ mpx->print_col++;
+ }
+ putc2(BYTE4(c), mpx->mpxfile);
+#else
+ putc2(Hi(c), mpx->mpxfile);
+ mpx->print_col++;
+ putc2(Lo(c), mpx->mpxfile);
+#endif
+ mpx->print_col++;
+}
+@z
diff --git a/Build/source/texk/web2c/pmpostdir/ppsout.ch b/Build/source/texk/web2c/pmpostdir/ppsout.ch
new file mode 100644
index 00000000000..1353e0b284c
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/ppsout.ch
@@ -0,0 +1,86 @@
+%
+%
+% change file of psout.w for jMetaPost (CWEB version)
+% Akira Kakuto (translated the WEB version)
+%
+%
+
+@x
+#include <math.h>
+@y
+#include <math.h>
+#include <ptexenc/ptexenc.h>
+#ifdef UPMP
+#include <ptexenc/unicode.h>
+#endif
+@z
+
+% Treat all Kanji fonts as used
+@x
+ if ( mp->font_info[p].qqqq.b3==mp_used )
+@y
+ if ( mp->font_info[p].qqqq.b3==mp_used || mp->font_id[f]!=0)
+@z
+
+%
+% Kanji string output
+@x
+static void mp_print_initial_comment(MP mp,mp_edge_object *hh, int prologues);
+@y
+static void mp_print_initial_comment(MP mp,mp_edge_object *hh, int prologues);
+
+#define Hi(x) (((x) >> 8) & 0xff)
+#define Lo(x) ((x) & 0xff)
+
+@ @c
+static void mp_ps_kanji_string_out (MP mp, char *s)
+{
+ int i, c;
+ size_t len;
+
+ len = strlen(s);
+ i=0;
+ mp_ps_print(mp, "<");
+ while (i<len) {
+ if ( mp->ps->ps_offset+5>mp->max_print_line )
+ mp_ps_print_ln(mp);
+#ifdef UPMP
+ c=toDVI(fromBUFF((unsigned char*)s, len, i));
+ i=i+multistrlen((unsigned char*)s, len, i);
+ if (isinternalUPTEX() && c>65535) {
+ int cx=UTF32toUTF16HS(c); /* High surrogate */
+ mp_hex_digit_out(mp, Hi(cx) / 16);
+ mp_hex_digit_out(mp, Hi(cx) % 16);
+ mp_hex_digit_out(mp, Lo(cx) / 16);
+ mp_hex_digit_out(mp, Lo(cx) % 16);
+ c=UTF32toUTF16LS(c); /* Low surrogate */
+ }
+#else
+ c=toDVI(fromBUFF((unsigned char*)s, i+2, i));
+ i=i+2;
+#endif
+ mp_hex_digit_out(mp, Hi(c) / 16);
+ mp_hex_digit_out(mp, Hi(c) % 16);
+ mp_hex_digit_out(mp, Lo(c) / 16);
+ mp_hex_digit_out(mp, Lo(c) % 16);
+ };
+ mp_ps_print(mp, ">");
+};
+@z
+
+@x
+ mp_ps_print_nl(mp, "%%Creator: MetaPost ");
+@y
+ mp_ps_print_nl(mp, "%%Creator: MetaPost ("@= @>P_UP@= @>"MetaPost) ");
+@z
+
+%
+% Call Kanji string output routine if the font is JFM.
+@x
+ mp_ps_string_out(mp, gr_text_p(p),gr_text_l(p));
+@y
+ if (mp->font_id[gr_font_n(p)]!=0)
+ mp_ps_kanji_string_out(mp, gr_text_p(p));
+ else
+ mp_ps_string_out(mp, gr_text_p(p),gr_text_l(p));
+@z
diff --git a/Build/source/texk/web2c/pmpostdir/psvgout.ch b/Build/source/texk/web2c/pmpostdir/psvgout.ch
new file mode 100644
index 00000000000..5e624585709
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/psvgout.ch
@@ -0,0 +1,77 @@
+@x
+#include <math.h>
+@y
+#include <math.h>
+#include <ptexenc/ptexenc.h>
+#ifdef UPMP
+#include <ptexenc/unicode.h>
+#endif
+@z
+
+@x
+@<Character |k| is not allowed in SVG output@>=
+ (k=='&')||(k=='>')||(k=='<')
+@y
+@<Character |k| is not allowed in SVG output@>=
+ (k=='&')||(k=='>')||(k=='<')||(k>=0x7F)
+@z
+
+@x
+@ Now for outputting the actual graphic objects.
+@y
+@ Now for outputting the actual graphic objects.
+
+@d yoko_jfm_id 11 /* `yoko-kumi' fonts */
+@d tate_jfm_id 9 /* `tate-kumi' fonts */
+@d font_jfm_p(A) (mp->font_id[(A)]!=0)
+@z
+
+@x Even if prologues=3, Japanese texts are not converted into paths.
+ if (prologues == 3 ) {
+@y
+ if (prologues == 3 && mp->font_id[gr_font_n(p)]==0) {
+@z
+
+@x To realise vertical Japanese texts ...
+ mp_svg_attribute(mp, "font-size", mp->svg->buf);
+@y
+ mp_svg_attribute(mp, "font-size", mp->svg->buf);
+ if ( mp->font_id[gr_font_n(p)]==tate_jfm_id ) {
+ mp_svg_reset_buf(mp);
+ append_string("tb-rl");
+ mp_svg_attribute(mp, "writing-mode", mp->svg->buf);
+ }
+@z
+
+@x
+ while (l-->0) {
+@y
+ if ( mp->font_id[gr_font_n(p)]!=0 ) {
+#ifdef UPMP
+ if (is_internalUPTEX() ) {
+ while (l>0) {
+ append_string("&#");
+ mp_svg_store_int(mp,UTF8StoUCS(s));
+ append_char(';');
+ k = UTF8length((int)*s); s += k; l -= k;
+ }
+ } else /* 1 charatcer = 2 bytes */
+#endif
+ {
+ l >>= 1;
+ while (l-->0) {
+ k =((int)*s++)*0x100; k += (int)*s++;
+ append_string("&#");
+ mp_svg_store_int(mp,toUCS(k));
+ append_char(';');
+ }
+ }
+ } else
+ while (l-->0) {
+@z
+
+@x
+ mp_svg_print(mp, "<?xml version=\"1.0\"?>");
+@y
+ mp_svg_print(mp, "<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+@z
diff --git a/Build/source/texk/web2c/pmpostdir/ptfmin.ch b/Build/source/texk/web2c/pmpostdir/ptfmin.ch
new file mode 100644
index 00000000000..296a98a74df
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/ptfmin.ch
@@ -0,0 +1,116 @@
+@x
+#include <w2c/config.h>
+@y
+#include <kpathsea/kpathsea.h>
+#include <w2c/config.h>
+@z
+
+%
+% local variable "nt" && "ct"
+@x
+ halfword lf,tfm_lh,bc,ec,nw,nh,nd; /* subfile size parameters */
+@y
+ halfword lf,tfm_lh,bc,ec,nw,nh,nd,nt; /* subfile size parameters */
+@z
+
+@x
+ int h_and_d; /* height and depth indices being unpacked */
+@y
+ int h_and_d; /* height and depth indices being unpacked */
+ halfword ct; /* char and type */
+ halfword id; /* JFM font id */
+@z
+
+@x
+@<Read the character data and the width, height, and depth tables and
+ |goto done|@>
+@y
+@<Read the character type table@>;
+@<Read the character data and the width, height, and depth tables and
+ |goto done|@>
+@z
+
+@x
+@d read_two(A) { (A)=tfbyte;
+@y
+@d read_pair(A) { (A)=tfbyte;
+ tfget; (A)=(A)*0400+tfbyte;
+}
+@d read_triplekanji(A) { (A)=tfbyte;
+ tfget; (A)=(A)*0400+tfbyte;
+ tfget; (A)=(A)+tfbyte*0200000;
+}
+@d read_two(A) { (A)=tfbyte;
+@z
+
+%
+% routine to process JFM file format
+@x
+@<Read the \.{TFM} size fields@>=
+tfget; read_two(lf);
+@y
+@d yoko_jfm_id 11 /* `yoko-kumi' fonts */
+@d tate_jfm_id 9 /* `tate-kumi' fonts */
+@d font_jfm_p(A) (mp->font_id[(A)]!=0)
+@d incr(A) (A)=(A)+1 /* increase a variable by unity */
+@<Read the \.{TFM} size fields@>=
+tfget; read_two(lf);
+if ( (lf==yoko_jfm_id) || (lf==tate_jfm_id) ) {
+ id=lf;
+ tfget; read_two(nt);
+ tfget; read_two(lf);
+} else {
+ id=0; nt=0;
+};
+@z
+
+@x
+whd_size=(size_t)((ec+1-bc)+nw+nh+nd);
+@y
+whd_size=(size_t)((ec+1-bc)+nt+nw+nh+nd);
+@z
+
+%
+% reserve space for character type table
+@x
+mp->char_base[n]=(int)(mp->next_fmem-(size_t)bc);
+mp->width_base[n]=(int)(mp->next_fmem+(size_t)(ec-bc)+1);
+@y
+mp->font_id[n]=id;
+mp->font_nt[n]=nt;
+mp->ctype_base[n]=mp->next_fmem;
+mp->char_base[n]=(int)(mp->next_fmem+nt-(size_t)bc);
+mp->width_base[n]=(int)(mp->next_fmem+nt+(size_t)(ec-bc)+1);
+@z
+
+%
+% read character type table
+%
+@x
+tf_ignore(4*(tfm_lh-2))
+@y
+tf_ignore(4*(tfm_lh-2))
+
+@ @<Read the character type table@>=
+ii=mp->ctype_base[n]+nt;
+i=mp->ctype_base[n];
+while ( i<ii ) {
+ tfget; read_triplekanji(ct); /* allow character codes up to 0xffffff */
+ mp->font_info[i].hh.LH=ct;
+ tfget; mp->font_info[i].hh.RH=tfbyte;
+ incr(i);
+}
+@z
+
+@x
+mp_pack_file_name(mp, mp->cur_name,mp->cur_area,mp->cur_ext);
+mp->tfm_infile = (mp->open_file)(mp, mp->name_of_file, "r",mp_filetype_metrics);
+@y
+mp_pack_file_name(mp, mp->cur_name,mp->cur_area,mp->cur_ext);
+{
+ char *fulln;
+ fulln = kpse_find_file(fname, kpse_tfm_format, 1);
+ mp->tfm_infile = (mp->open_file)(mp, fulln, "r",mp_filetype_metrics);
+ if(fulln) mp_xfree(fulln);
+}
+@z
diff --git a/Build/source/texk/web2c/pmpostdir/tests/psample.mp b/Build/source/texk/web2c/pmpostdir/tests/psample.mp
new file mode 100644
index 00000000000..db5867ba8df
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/tests/psample.mp
@@ -0,0 +1,16 @@
+prologues:=3;
+outputformat:="eps";
+outputtemplate:="%j.%o";
+beginfig(1);
+ u=1cm;
+ drawarrow (-.5u,0)--(4u,0);
+ drawarrow (0,-.5u)--(0,2u);
+ pickup pencircle scaled 1pt;
+ draw (0,0){up}
+ for i=1 upto 8: ..(i/2,sqrt(i/2))*u endfor;
+ label.lrt(btex 関数$y=\sqrt{x}$ etex, (3,sqrt(3))*u);
+ label.rt(btex $x$軸 etex, (4,0)*u);
+ label.top(btex $y$軸 etex, (0,2)*u);
+ label.llft(btex 原点$O$ etex, (0,0));
+endfig;
+end.
diff --git a/Build/source/texk/web2c/pmpostdir/tests/testnewu.mp b/Build/source/texk/web2c/pmpostdir/tests/testnewu.mp
new file mode 100644
index 00000000000..6cc60d3b095
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/tests/testnewu.mp
@@ -0,0 +1,36 @@
+prologues:=0;
+beginfig(1);
+ u:=.5cm; h:=0; v:=0;
+ picture pct; string FONT;
+ bboxmargin:=-0pt;
+ def TEST(expr a)=
+ pct:=(a if length(FONT)>0: infont FONT fi);
+ draw bbox pct shifted (h,v) withcolor (blue+green);
+ draw pct shifted (h,v);
+ h:=h+xpart(urcorner pct-ulcorner pct); v:=v+0.1u;
+ enddef;
+
+ FONT:="cmr10";
+ TEST("VAr10");
+ h:=0; v:=v+u; FONT:="cmss10";
+ TEST("VAss10");
+ h:=0; v:=v+u; FONT:="uprml-h";
+ TEST("あ,臼𦥑あ"); % upjisr-h: error
+ h:=0; v:=v+u;
+ TEST("あ" );
+ TEST("," );
+ TEST("臼" );
+ TEST("𦥑" );
+ TEST("あ" );
+ h:=0; v:=v+u; FONT:="testnewu";
+ TEST("あ,臼𦥑あ");
+ h:=0; v:=v+u;
+ TEST("あ" );
+ TEST("," );
+ TEST("臼" );
+ TEST("𦥑" );
+ TEST("あ" );
+ h:=0; v:=v+u; FONT:="";
+ TEST(btex あ,臼𦥑あ etex);
+endfig;
+end;
diff --git a/Build/source/texk/web2c/pmpostdir/tests/testnewu.tex b/Build/source/texk/web2c/pmpostdir/tests/testnewu.tex
new file mode 100644
index 00000000000..5c524efecbf
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/tests/testnewu.tex
@@ -0,0 +1,7 @@
+%#!uplatex
+\documentclass{ujarticle}
+\usepackage[dvipdfmx]{graphicx}
+\begin{document}
+\special{pdf:mapline testnewu UniJIS-UTF16-H ipaexg.ttf}%
+\fbox{\includegraphics{testnewu.1}}
+\end{document} \ No newline at end of file
diff --git a/Build/source/texk/web2c/pmpostdir/tests/testnewu.tfm b/Build/source/texk/web2c/pmpostdir/tests/testnewu.tfm
new file mode 100644
index 00000000000..6860278f2ca
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/tests/testnewu.tfm
Binary files differ
diff --git a/Build/source/texk/web2c/pmpostdir/upmpost.test b/Build/source/texk/web2c/pmpostdir/upmpost.test
new file mode 100755
index 00000000000..43913d8af6d
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/upmpost.test
@@ -0,0 +1,14 @@
+#! /bin/sh -vx
+# $Id$
+# Copyright 2017 Karl Berry <tex-live@tug.org>
+# Copyright 2014 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+./upmpost -version || exit 1
+
+./upmpost -help || exit 1
+
+./upmpost -dvitomp -version || exit 1
+
+./upmpost -dvitomp -help || exit 1
+
diff --git a/Build/source/texk/web2c/pmpostdir/upmpsamp.test b/Build/source/texk/web2c/pmpostdir/upmpsamp.test
new file mode 100755
index 00000000000..8d11af07fd8
--- /dev/null
+++ b/Build/source/texk/web2c/pmpostdir/upmpsamp.test
@@ -0,0 +1,42 @@
+#! /bin/sh -vx
+# $Id$
+# Copyright 2017-2018 Karl Berry <tex-live@tug.org>
+# Copyright 2014 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+LC_ALL=C; export LC_ALL; LANGUAGE=C; export LANGUAGE
+
+tests=pmpostdir/tests
+
+test -d $tests || mkdir -p $tests
+
+TEXMFCNF=$srcdir/../kpathsea
+
+tfmpath=`$KPSEWHICH cmr10.tfm` || exit 77
+TFMFONTS="$srcdir/$tests;`echo $tfmpath | sed 's,/fonts/tfm/.*$,/fonts/tfm//,'`"
+
+mppath=`$KPSEWHICH plain.mp` || exit 77
+MPINPUTS=".;`dirname $mppath`"
+
+mappath=`$KPSEWHICH psfonts.map` || exit 77
+TEXFONTMAPS=`echo $mappath | sed 's,/fonts/map/.*$,/fonts/map//,'`
+
+t1path=`$KPSEWHICH cmmi10.pfb` || exit 77
+T1FONTS="$srcdir/$tests;`echo $t1path | sed 's,/fonts/type1/.*$,/fonts/type1//,'`"
+
+vfpath=`$KPSEWHICH upjisr-h.vf` || exit 77
+VFFONTS="$srcdir/$tests;`dirname $vfpath`"
+
+export TEXMFCNF TFMFONTS MPINPUTS TEXFONTMAPS T1FONTS VFFONTS
+
+# check that we have euptex at all.
+euptex -version >/dev/null 2>&1 || exit 77
+
+# ensure that euptex.fmt exists and can be read.
+euptex \\end >/dev/null 2>&1 || exit 77
+
+echo 'input plain;' >upmpsamp.mp
+cat "$srcdir/$tests/psample.mp" >>upmpsamp.mp
+
+./upmpost -ini -tex=euptex upmpsamp || exit 1
+