summaryrefslogtreecommitdiff
path: root/fonts/ptex-fontmaps/script
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /fonts/ptex-fontmaps/script
Initial commit
Diffstat (limited to 'fonts/ptex-fontmaps/script')
-rwxr-xr-xfonts/ptex-fontmaps/script/kanji-config-updmap-sys.sh24
-rwxr-xr-xfonts/ptex-fontmaps/script/kanji-config-updmap-user.sh24
-rwxr-xr-xfonts/ptex-fontmaps/script/kanji-config-updmap.pl548
-rw-r--r--fonts/ptex-fontmaps/script/kanji-fontmap-creator.pl590
-rwxr-xr-xfonts/ptex-fontmaps/script/updmap-otf.sh323
5 files changed, 1509 insertions, 0 deletions
diff --git a/fonts/ptex-fontmaps/script/kanji-config-updmap-sys.sh b/fonts/ptex-fontmaps/script/kanji-config-updmap-sys.sh
new file mode 100755
index 0000000000..4d0944572a
--- /dev/null
+++ b/fonts/ptex-fontmaps/script/kanji-config-updmap-sys.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# kanji-config-updmap-sys:
+# copy of fmtutil-sys by Thomas Esser, public domain.
+
+# wrapper script for updmap-setup-kanji with TEXMFVAR and TEXMFCONFIG set to
+# TEXMFSYSVAR / TEXMFSYSCONFIG
+
+test -f /bin/ksh && test -z "$RUNNING_KSH" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
+ && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; }
+unset RUNNING_KSH
+
+test -f /bin/bsh && test -z "$RUNNING_BSH" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \
+ && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; }
+unset RUNNING_BSH
+
+# hack around a bug in zsh:
+test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
+export PATH
+
+exec kanji-config-updmap --sys ${1+"$@"}
+
diff --git a/fonts/ptex-fontmaps/script/kanji-config-updmap-user.sh b/fonts/ptex-fontmaps/script/kanji-config-updmap-user.sh
new file mode 100755
index 0000000000..8426f66e57
--- /dev/null
+++ b/fonts/ptex-fontmaps/script/kanji-config-updmap-user.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# kanji-config-updmap-user:
+# copy of fmtutil-sys by Thomas Esser, public domain.
+
+# wrapper script for updmap-setup-kanji with TEXMFVAR and TEXMFCONFIG set to
+# TEXMFVAR / TEXMFCONFIG
+
+test -f /bin/ksh && test -z "$RUNNING_KSH" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
+ && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; }
+unset RUNNING_KSH
+
+test -f /bin/bsh && test -z "$RUNNING_BSH" \
+ && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \
+ && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; }
+unset RUNNING_BSH
+
+# hack around a bug in zsh:
+test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
+export PATH
+
+exec kanji-config-updmap --user ${1+"$@"}
+
diff --git a/fonts/ptex-fontmaps/script/kanji-config-updmap.pl b/fonts/ptex-fontmaps/script/kanji-config-updmap.pl
new file mode 100755
index 0000000000..230b0a9a02
--- /dev/null
+++ b/fonts/ptex-fontmaps/script/kanji-config-updmap.pl
@@ -0,0 +1,548 @@
+#!/usr/bin/env perl
+# kanji-config-updmap: setup Japanese font embedding
+# Version 20190506.0
+#
+# formerly known as updmap-setup-kanji
+#
+# Copyright 2004-2006 by KOBAYASHI R. Taizo for the shell version (updmap-otf)
+# Copyright 2011-2019 by PREINING Norbert
+# Copyright 2016-2019 by Japanese TeX Development Community
+#
+# This file is licensed under GPL version 3 or any later version.
+# For copyright statements see end of file.
+#
+# For development see
+# https://github.com/texjporg/jfontmaps
+#
+# For a changelog see the git log
+#
+
+$^W = 1;
+use Getopt::Long qw(:config no_autoabbrev ignore_case_always);
+use strict;
+
+my $prg = "kanji-config-updmap";
+my $version = '20190506.0';
+
+my $updmap_real = "updmap";
+my $updmap = $updmap_real;
+
+my $dry_run = 0;
+my $opt_help = 0;
+my $opt_jis = 0;
+my $opt_sys = 0;
+my $opt_user = 0;
+my $opt_old = 0;
+my $opt_force = 0;
+my @opt_mode_list;
+my $opt_mode_one;
+my $opt_mode_ja;
+my $opt_mode_sc;
+my $opt_mode_tc;
+my $opt_mode_ko;
+
+if (! GetOptions(
+ "n|dry-run" => \$dry_run,
+ "h|help" => \$opt_help,
+ "jis2004" => \$opt_jis,
+ "mode=s" => \$opt_mode_one,
+ "ja=s" => \$opt_mode_ja,
+ "sc=s" => \$opt_mode_sc,
+ "tc=s" => \$opt_mode_tc,
+ "ko=s" => \$opt_mode_ko,
+ "sys" => \$opt_sys,
+ "user" => \$opt_user,
+ "old" => \$opt_old,
+ "force" => \$opt_force,
+ "version" => sub { print &version(); exit(0); }, ) ) {
+ die "Try \"$0 --help\" for more information.\n";
+}
+
+if ($opt_mode_one) {
+ if (defined($opt_mode_ja) || defined($opt_mode_sc) ||
+ defined($opt_mode_tc) || defined($opt_mode_ko)) {
+ die "Options --ja/--sc/--tc/--ko are invalid with --mode=NN!\n";
+ }
+ # define a corresponding option by empty string
+ if ($opt_mode_one eq "ja") {
+ $opt_mode_ja = '';
+ } elsif ($opt_mode_one eq "sc") {
+ $opt_mode_sc = '';
+ } elsif ($opt_mode_one eq "tc") {
+ $opt_mode_tc = '';
+ } elsif ($opt_mode_one eq "ko") {
+ $opt_mode_ko = '';
+ } else {
+ die "Unknown mode $opt_mode_one!";
+ }
+}
+push @opt_mode_list, "ja" if (defined($opt_mode_ja));
+push @opt_mode_list, "sc" if (defined($opt_mode_sc));
+push @opt_mode_list, "tc" if (defined($opt_mode_tc));
+push @opt_mode_list, "ko" if (defined($opt_mode_ko));
+if (!@opt_mode_list) {
+ # default mode needs to be set, define it by empty string
+ $opt_mode_one = "ja";
+ $opt_mode_ja = '';
+ push @opt_mode_list, "ja";
+}
+
+sub win32 { return ($^O=~/^MSWin(32|64)$/i); }
+my $nul = (win32() ? 'nul' : '/dev/null') ;
+
+if (defined($ARGV[0]) && $ARGV[0] ne "status") {
+ if (!($opt_user || $opt_sys)) {
+ die "Either -user or -sys mode is required.";
+ }
+}
+
+if ($opt_user && $opt_sys) {
+ die "Only one of -user and -sys can be used!";
+}
+
+if ($opt_sys) {
+ $updmap = "$updmap --sys" ;
+ $updmap_real = "$updmap_real --sys" ;
+} else {
+ # TeX Live 2017 requires --user option
+ # try to determine the version of updmap installed
+ my $updver = `updmap --version 2>&1`;
+ if ($updver =~ m/^updmap version r([0-9]*) /) {
+ if ($1 >= 44080) {
+ $updmap = "$updmap --user" ;
+ $updmap_real = "$updmap_real --user" ;
+ } # else nothing to do, already set up for old updmap
+ } else {
+ # not recognized updmap -> assume new updmap unless --old
+ if (!$opt_old) {
+ $updmap = "$updmap --user" ;
+ $updmap_real = "$updmap_real --user" ;
+ }
+ }
+}
+if ($dry_run) {
+ $updmap = "echo updmap";
+}
+
+if ($opt_help) {
+ Usage();
+ exit(0);
+}
+
+#
+# representatives of support font families
+#
+my %representatives;
+my %ai0flags;
+my @databaselist = "ptex-fontmaps-data.dat";
+push @databaselist, "ptex-fontmaps-macos-data.dat" if (macosx_new());
+
+
+main(@ARGV);
+
+sub macosx { return ($^O=~/^darwin$/i); }
+
+sub macosx_new {
+ if (macosx()) {
+ my $macos_ver = `sw_vers -productVersion`;
+ my $macos_ver_major = $macos_ver;
+ $macos_ver_major =~ s/^(\d+)\.(\d+).*/$1/;
+ my $macos_ver_minor = $macos_ver;
+ $macos_ver_minor =~ s/^(\d+)\.(\d+).*/$2/;
+ if ($macos_ver_major==10) {
+ if ($macos_ver_minor>=11) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+sub version {
+ my $ret = sprintf "%s version %s\n", $prg, $version;
+ return $ret;
+}
+
+sub Usage {
+ my $usage = <<"EOF";
+ $prg $version
+ Set up embedding of Japanese/Chinese/Korean fonts via updmap.cfg.
+
+ This script searches for some of the most common fonts
+ for embedding into pdfs by dvipdfmx.
+
+ In addition it allows to set up arbitrary font families
+ to be embedded into the generated pdf files, as long
+ as at least the representative map file is present.
+ Other map files will be used if available:
+
+ For Japanese:
+ ptex-<family>.map (representative map file)
+ uptex-<family>.map
+ otf-<family>.map
+ otf-up-<family>.map
+
+ For Simplified Chinese, Traditional Chinese and Korean:
+ uptex-<NN>-<family>.map (representative map file)
+ otf-<NN>-<family>.map
+ (NN being: sc, tc, ko)
+
+ Please see the documentation of updmap for details (updmap --help).
+
+ Usage: $prg [OPTION] {<fontname>|auto|nofont|status}
+
+ <family> Embed an arbitrary font family <family>, at least
+ the representative map file has to be available.
+ auto: If the current status is noEmbed or unknown, try to embed
+ one of the supported font families automatically.
+ If none of them is available, fall back to nofont
+ nofont: Embed no fonts (and rely on system fonts when displaying pdfs).
+ If your system does not have any of the supported font
+ families, this target is selected automatically.
+ status: Get information about current environment and usable font maps.
+
+ Options:
+ -n, --dry-run Do not actually run updmap
+ -h, --help Show this message and exit
+ --mode=NN Setup for Japanese (NN=ja), Korean (NN=ko),
+ Simplified Chinese (NN=sc), Traditional Chinese (NN=tc)
+ --NN Shorthand for --mode=NN
+ --jis2004 Use JIS2004 variants for default fonts of (u)pTeX
+ --sys Run in sys mode, i.e., call updmap -sys
+ --user Run in user mode, i.e., call updmap -user or updmap,
+ by checking the version of the updmap script.
+ If a non-parsable output of `updmap --version' is found,
+ a new updmap with --user option is assumed.
+ If this is not the case, explicitly use --old.
+ --old Makes $prg call `updmap' without --user argument in user mode.
+ --force Set up font embedding even if the font is not available.
+ --version Show version information and exit
+
+EOF
+;
+ print $usage;
+ exit(0);
+}
+
+
+
+###
+### Collect Database Lines
+###
+
+sub InitDatabase {
+ %representatives = ();
+ %ai0flags = ();
+}
+
+sub ReadDatabase {
+ my @curdbl;
+ # open database
+ for my $f (@databaselist) {
+ my $foo = kpse_miscfont($f);
+ if (!open(FDB, "<$foo")) {
+ printf STDERR "Cannot find $f, skipping!\n";
+ next;
+ }
+ @curdbl = <FDB>;
+ close(FDB);
+ # parse lines
+ my $lineno = 0;
+ chomp(@curdbl);
+ push @curdbl, ""; # add a "final empty line" to easy parsing
+ for my $l (@curdbl) {
+ $lineno++;
+ next if ($l =~ m/^\s*$/); # skip empty line
+ next if ($l =~ m/^\s*#/); # skip comment line
+ $l =~ s/\s*#.*$//; # skip comment after '#'
+ if ($l =~ m/^JA\((\d+)\):\s*(.*):\s*(.*)$/) {
+ $representatives{'ja'}{$2}{'priority'} = $1;
+ $representatives{'ja'}{$2}{'file'} = $3;
+ next;
+ }
+ if ($l =~ m/^SC\((\d+)\):\s*(.*):\s*(.*)$/) {
+ $representatives{'sc'}{$2}{'priority'} = $1;
+ $representatives{'sc'}{$2}{'file'} = $3;
+ next;
+ }
+ if ($l =~ m/^TC\((\d+)\):\s*(.*):\s*(.*)$/) {
+ $representatives{'tc'}{$2}{'priority'} = $1;
+ $representatives{'tc'}{$2}{'file'} = $3;
+ next;
+ }
+ if ($l =~ m/^KO\((\d+)\):\s*(.*):\s*(.*)$/) {
+ $representatives{'ko'}{$2}{'priority'} = $1;
+ $representatives{'ko'}{$2}{'file'} = $3;
+ next;
+ }
+ if ($l =~ m/^JA-AI0:\s*(.*):\s*(.*)$/) {
+ $representatives{'ja'}{$1}{'priority'} = 9999; # lowest
+ $representatives{'ja'}{$1}{'file'} = $2;
+ $ai0flags{'ja'}{$1} = 1;
+ next;
+ }
+ if ($l =~ m/^SC-AI0:\s*(.*):\s*(.*)$/) {
+ $representatives{'sc'}{$1}{'priority'} = 9999; # lowest
+ $representatives{'sc'}{$1}{'file'} = $2;
+ $ai0flags{'sc'}{$1} = 1;
+ next;
+ }
+ if ($l =~ m/^TC-AI0:\s*(.*):\s*(.*)$/) {
+ $representatives{'tc'}{$1}{'priority'} = 9999; # lowest
+ $representatives{'tc'}{$1}{'file'} = $2;
+ $ai0flags{'tc'}{$1} = 1;
+ next;
+ }
+ if ($l =~ m/^KO-AI0:\s*(.*):\s*(.*)$/) {
+ $representatives{'ko'}{$1}{'priority'} = 9999; # lowest
+ $representatives{'ko'}{$1}{'file'} = $2;
+ $ai0flags{'ko'}{$1} = 1;
+ next;
+ }
+ # we are still here??
+ die "Cannot parse \"$foo\" at line $lineno,
+ exiting. Strange line: >>>$l<<<\n";
+ }
+ }
+ if (!%representatives) {
+ die "Candidate list is empty, cannot proceed!\n";
+ }
+}
+
+sub kpse_miscfont {
+ my ($file) = @_;
+ chomp(my $foo = `kpsewhich -format=miscfont $file`);
+ # for GitHub repository diretory structure
+ if ($foo eq "") {
+ $foo = "database/$file" if (-f "database/$file");
+ }
+ return $foo;
+}
+
+###
+### Check Installed Font
+###
+
+sub CheckInstallFont {
+ for my $opt_mode (@opt_mode_list) {
+ for my $k (keys %{$representatives{$opt_mode}}) {
+ my $f = `kpsewhich $representatives{$opt_mode}{$k}{'file'}`;
+ if ($?) {
+ $representatives{$opt_mode}{$k}{'available'} = "";
+ } else {
+ $representatives{$opt_mode}{$k}{'available'} = chomp($f);
+ }
+ }
+ }
+}
+
+###
+### GetStatus
+###
+
+sub check_mapfile {
+ my $mapf = shift;
+ my $f = `kpsewhich $mapf 2> $nul`;
+ my $ret = $?;
+ if (wantarray) {
+ return (!$ret, $f);
+ } else {
+ return (!$ret);
+ }
+}
+
+sub gen_mapfile {
+ my $opt_mode = shift;
+ my $map_base = shift;
+ # returns a representative map file name
+ # ptex-${map_base}.map also exists for Japanese AI0 fonts,
+ # but it is a stub so we use uptex-${map_base}.map instead
+ return ($opt_mode eq "ja" ?
+ ($ai0flags{$opt_mode}{$map_base} ?
+ "uptex-${map_base}.map" :
+ "ptex-${map_base}.map") :
+ "uptex-${opt_mode}-${map_base}.map");
+}
+
+sub GetStatus {
+ my $opt_mode = shift;
+ my $val = `$updmap_real --quiet --showoption ${opt_mode}Embed`;
+ my $STATUS;
+ if ($val =~ m/^${opt_mode}Embed=([^()\s]*)(\s+\()?/) {
+ $STATUS = $1;
+ } else {
+ die "Cannot find status of current ${opt_mode}Embed setting via updmap --showoption!\n";
+ }
+
+ my $testmap = gen_mapfile($opt_mode, $STATUS);
+ if (check_mapfile($testmap)) {
+ print "CURRENT family for $opt_mode: $STATUS";
+ print " (AI0)" if ($ai0flags{$opt_mode}{$STATUS});
+ print "\n";
+ } else {
+ print STDERR "WARNING: Currently selected map file for $opt_mode cannot be found: $testmap\n";
+ }
+
+ for my $k (sort keys %{$representatives{$opt_mode}}) {
+ my $MAPFILE = gen_mapfile($opt_mode, $k);
+ next if ($MAPFILE eq $testmap);
+ if (check_mapfile($MAPFILE)) {
+ if ($representatives{$opt_mode}{$k}{'available'}) {
+ print "Standby family : $k";
+ print " (AI0)" if ($ai0flags{$opt_mode}{$k});
+ print "\n";
+ }
+ }
+ }
+ return $STATUS;
+}
+
+###
+### Setup Map files
+###
+
+sub SetupMapFile {
+ my $opt_mode = shift;
+ my $rep = shift;
+ my $MAPFILE = gen_mapfile($opt_mode, $rep);
+ if (check_mapfile($MAPFILE)) {
+ print "Setting up ... $rep";
+ print " (AI0)" if ($ai0flags{$opt_mode}{$rep});
+ print " for $opt_mode\n";
+ system("$updmap --quiet --nomkmap --nohash --setoption ${opt_mode}Embed $rep");
+ if ($opt_jis) {
+ system("$updmap --quiet --nomkmap --nohash --setoption jaVariant -04");
+ } else {
+ system("$updmap --quiet --nomkmap --nohash --setoption jaVariant \"\"");
+ }
+ } else {
+ die "NOT EXIST $MAPFILE\n";
+ }
+}
+
+sub SetupReplacement {
+ my $opt_mode = shift;
+ my $rep = shift;
+ if (defined($representatives{$opt_mode}{$rep})) {
+ if ($representatives{$opt_mode}{$rep}{'available'} || $opt_force) {
+ return SetupMapFile($opt_mode, $rep);
+ } else {
+ printf STDERR "$rep not available, falling back to auto!\n";
+ return SetupReplacement($opt_mode, "auto");
+ }
+ } else {
+ if ($rep eq "nofont") {
+ return SetupMapFile($opt_mode, "noEmbed");
+ } elsif ($rep eq "auto") {
+ my $STATUS = GetStatus($opt_mode);
+ # first check if we have a status set and the font is installed
+ # in this case don't change anything, just make sure
+ if (defined($representatives{$opt_mode}{$STATUS}) &&
+ $representatives{$opt_mode}{$STATUS}{'available'}) {
+ return SetupMapFile($opt_mode, $STATUS);
+ } else {
+ if (!($STATUS eq "noEmbed" || $STATUS eq "")) {
+ # some unknown setting is set up currently, overwrite, but warn
+ print STDERR "Previous setting $STATUS for $opt_mode is unknown, replacing it!\n"
+ }
+ # if we are in the noEmbed or nothing set case,
+ # and if one of the supported fonts are present, then use them
+ for my $i (sort { $representatives{$opt_mode}{$a}{'priority'}
+ <=>
+ $representatives{$opt_mode}{$b}{'priority'} }
+ keys %{$representatives{$opt_mode}}) {
+ if ($representatives{$opt_mode}{$i}{'available'}) {
+ return SetupMapFile($opt_mode, $i);
+ }
+ }
+ # still here, no map file found!
+ return SetupMapFile($opt_mode, "noEmbed");
+ }
+ } else {
+ # anything else is treated as a map file name
+ return SetupMapFile($opt_mode, $rep);
+ }
+ }
+}
+
+###
+### MAIN
+###
+
+sub main {
+ # Number of arguments allowed:
+ # 0: should be only --NN=<family> lists ('=' can be omitted)
+ # 1: treated as [--mode=NN] <family> ('=' can be omitted)
+ # 2 or more: I can't handle!
+ my ($a, $b) = @_;
+ if (defined($b)) {
+ die "Number of the arguments should be at most one!\n";
+ }
+ if ($a) {
+ die "Strange argument found! >>>$a<<<\n" if (!$opt_mode_one);
+ # argument is passed to defined-but-empty language mode
+ if (defined($opt_mode_ja) && !$opt_mode_ja) {
+ $opt_mode_ja = $a;
+ } elsif (defined($opt_mode_sc) && !$opt_mode_sc) {
+ $opt_mode_sc = $a;
+ } elsif (defined($opt_mode_tc) && !$opt_mode_tc) {
+ $opt_mode_tc = $a;
+ } elsif (defined($opt_mode_ko) && !$opt_mode_ko) {
+ $opt_mode_ko = $a;
+ }
+ } else {
+ die "No family or operation is specified for $opt_mode_one!\n",
+ "Try \"$0 --help\" for more information.\n" if ($opt_mode_one);
+ }
+
+ InitDatabase();
+ ReadDatabase();
+ CheckInstallFont();
+
+ # if one of <family> arguments is "status", then
+ # all arguments are forced into "status"
+ if (($opt_mode_ja && ($opt_mode_ja eq "status")) ||
+ ($opt_mode_sc && ($opt_mode_sc eq "status")) ||
+ ($opt_mode_tc && ($opt_mode_tc eq "status")) ||
+ ($opt_mode_ko && ($opt_mode_ko eq "status"))) {
+ GetStatus("ja") if ($opt_mode_ja);
+ GetStatus("sc") if ($opt_mode_sc);
+ GetStatus("tc") if ($opt_mode_tc);
+ GetStatus("ko") if ($opt_mode_ko);
+ } else {
+ SetupReplacement("ja", $opt_mode_ja) if ($opt_mode_ja);
+ SetupReplacement("sc", $opt_mode_sc) if ($opt_mode_sc);
+ SetupReplacement("tc", $opt_mode_tc) if ($opt_mode_tc);
+ SetupReplacement("ko", $opt_mode_ko) if ($opt_mode_ko);
+ system("$updmap");
+ }
+}
+
+#
+#
+# Copyright statements:
+#
+# KOBAYASHI Taizo
+# email to preining@logic.at
+# Message-Id: <20120130.162953.59640143170594580.tkoba@cc.kyushu-u.ac.jp>
+# Message-Id: <20120201.105639.625859878546968959.tkoba@cc.kyushu-u.ac.jp>
+# --------------------------------------------------------
+# copyright statement は簡単に以下で結構です。
+#
+# Copyright 2004-2006 by KOBAYASHI Taizo
+#
+# では
+# GPL version 3 or any later version
+#
+# --------------------------------------------------------
+#
+# PREINING Norbert
+# as author and maintainer of the current file
+# Licensed under GPL version 3 or any later version
+#
+### Local Variables:
+### perl-indent-level: 2
+### tab-width: 2
+### indent-tabs-mode: nil
+### End:
+# vim: set tabstop=2 expandtab autoindent:
diff --git a/fonts/ptex-fontmaps/script/kanji-fontmap-creator.pl b/fonts/ptex-fontmaps/script/kanji-fontmap-creator.pl
new file mode 100644
index 0000000000..dd8e72970d
--- /dev/null
+++ b/fonts/ptex-fontmaps/script/kanji-fontmap-creator.pl
@@ -0,0 +1,590 @@
+#!/usr/bin/env perl
+#
+# kanji-fontmap-creator
+# (c) 2012-2014 Norbert Preining
+# Version: 20190506.0
+# Licenced under the GPLv2 or any higher version
+#
+# gui to create map files for (kanji-config-)updmap
+#
+# ptex/uptex:
+# 2 fonts (rml/gbm)
+# 2 variants
+# (ev vertical/horizontal)
+#
+# otf/otf-up:
+#
+# 2 variants
+# fonts:
+# gothic: regular, bold, heavy, maru
+# mincho: regular, bold, light
+#
+# possible improvements:
+# - allow editing current files by reading and interpreting them
+# needs better structure of the data
+# - specify output directory, automatically write to $TEXMFLOCAL ?
+# - more checks, warnings?
+#
+
+$^W = 1;
+use strict;
+
+use Tk;
+use Tk::NoteBook;
+use Tk::Dialog;
+use Cwd;
+use Getopt::Long qw(:config no_autoabbrev);
+use Pod::Usage;
+
+my $opt_lang = "en";
+my $opt_help = 0;
+my $opt_version = 0;
+
+my $prg = "kanji-fontmap-creator";
+my $version = "20190506.0";
+
+#
+# global vars configuring operation
+my $group_name = "";
+my $do_vertical = 0;
+my $do_iso2004 = 0;
+my $do_otf = 0;
+my @f_mincho_regular; my @f_gothic_regular;
+my @f_mincho_bold; my @f_gothic_bold;
+my @f_gothic_heavy;
+my @f_gothic_maru;
+my @f_mincho_light;
+my $b_save;
+
+my $iso_i = 1;
+my $vert_i = 2;
+my $isovert_i = 3;
+my @order;
+
+my $mw;
+
+$order[0] = 'Default';
+$order[$iso_i] = 'ISO2004';
+$order[$vert_i] = 'Vertical';
+$order[$isovert_i] = 'ISO2004/Vertical';
+
+
+GetOptions(
+ "lang=s" => \$opt_lang,
+ "version" => \$opt_version,
+ "help|?|h" => \$opt_help) or pod2usage(1);
+
+if (win32()) {
+ pod2usage(-exitstatus => 0,
+ -verbose => 2,
+ -noperldoc => 1,
+ -output => \*STDOUT) if $opt_help;
+} else {
+ pod2usage(-exitstatus => 0, -verbose => 2, -file => $0) if $opt_help;
+}
+
+if ($opt_version) {
+ print "$prg $version\n";
+ exit 0;
+}
+
+if ($opt_lang ne "en") {
+ print STDERR "$prg: languages other than en currently not implemented.\n";
+}
+
+&main();
+
+sub main {
+ #
+ #
+ $mw = MainWindow->new;
+ $mw->title("Kanji Fontmap Creator");
+ $mw->optionAdd("*Button.Relief", "ridge", 20);
+ my $tf = $mw->Frame;
+ my $nb = $mw->NoteBook;
+ my $bf = $mw->Frame;
+ #
+ # top frame
+ #
+ my $name_label = $tf->Label(-text => "Group name:");
+ my $name_entry = $tf->Entry(-width => 30, -textvariable => \$group_name,
+ -validate => "all", -validatecommand => \&validate_group_name);
+ my $opt_label = $tf->Label(-text => "Options:");
+ my $opt_vert = $tf->Checkbutton(-text => "separate vertical fonts",
+ -variable => \$do_vertical);
+ my $opt_iso = $tf->Checkbutton(-text => "separate ISO 2004 support",
+ -variable => \$do_iso2004 );
+ my $opt_otf = $tf->Checkbutton(-text => "OTF support",
+ -variable => \$do_otf);
+ #
+ # pack the stuff
+ $name_label->grid(-row => 0, -column => 0, -sticky => "e");
+ $name_entry->grid(-row => 0, -column => 1, -sticky => "w");
+ $opt_label->grid(-row => 1, -column => 0, -sticky => "e");
+ $opt_otf->grid(-row => 1, -column => 1, -sticky => "w");
+ $opt_iso->grid(-column => 1, -sticky => "w");
+ $opt_vert->grid(-column => 1, -sticky => "w");
+ #
+ # notebook part
+ my @p;
+ for my $i (0..$#order) {
+ $p[$i] = $nb->add($order[$i], -label => $order[$i],
+ -state => ($i > 0 ? "disabled" : "normal"));
+ }
+ #
+ # pack outer window
+ $tf->pack(-expand => 1, -fill => 'x', -padx => '4m', -pady => '4m');
+ $nb->pack(-expand => 1, -fill => 'both', -padx => '4m');
+ $bf->pack(-expand => 1, -fill => 'x', -padx => '4m', -pady => '4m');
+ #
+ #
+ my @l_mincho; my @l_gothic;
+ my @l_regular;
+ my @l_bold;
+ my @l_heavy;
+ my @l_light;
+ my @l_maru;
+ my @e_mincho_regular; my @e_gothic_regular;
+ my @e_mincho_bold; my @e_gothic_bold;
+ my @e_gothic_heavy;
+ my @e_gothic_maru;
+ my @e_mincho_light;
+ my $ew = 20;
+ for my $i (0..$#order) {
+ $l_mincho[$i] = $p[$i]->Label(-text => "Mincho");
+ $l_gothic[$i] = $p[$i]->Label(-text => "Gothic");
+ #
+ $l_regular[$i] = $p[$i]->Label(-text => "Regular");
+ $e_mincho_regular[$i] = $p[$i]->Entry(-width => $ew,
+ -textvariable => \$f_mincho_regular[$i]);
+ $e_gothic_regular[$i] = $p[$i]->Entry(-width => $ew,
+ -textvariable => \$f_gothic_regular[$i]);
+ #
+ $l_bold[$i] = $p[$i]->Label(-text => "Bold", -state => "disabled");
+ $e_mincho_bold[$i] = $p[$i]->Entry(-width => $ew,
+ -textvariable => \$f_mincho_bold[$i],
+ -state => "disabled", -relief => "flat");
+ $e_gothic_bold[$i] = $p[$i]->Entry(-width => $ew,
+ -textvariable => \$f_gothic_bold[$i],
+ -state => "disabled", -relief => "flat");
+ #
+ $l_heavy[$i] = $p[$i]->Label(-text => "Heavy", -state => "disabled");
+ $l_light[$i] = $p[$i]->Label(-text => "Light", -state => "disabled");
+ $l_maru[$i] = $p[$i]->Label(-text => "Maru", -state => "disabled");
+ $e_gothic_heavy[$i] = $p[$i]->Entry(-width => $ew,
+ -textvariable => \$f_gothic_heavy[$i],
+ -state => "disabled", -relief => "flat");
+ $e_gothic_maru[$i] = $p[$i]->Entry(-width => $ew,
+ -textvariable => \$f_gothic_maru[$i],
+ -state => "disabled", -relief => "flat");
+ $e_mincho_light[$i] = $p[$i]->Entry(-width => $ew,
+ -textvariable => \$f_mincho_light[$i],
+ -state => "disabled", -relief => "flat");
+ #
+ # grid the whole stuff
+ $l_mincho[$i]->grid(-row => 0, -column => 1);
+ $l_gothic[$i]->grid(-row => 0, -column => 2);
+ #
+ $l_regular[$i]->grid(-row => 1, -column => 0, -sticky => "e");
+ $e_mincho_regular[$i]->grid(-row => 1, -column => 1);
+ $e_gothic_regular[$i]->grid(-row => 1, -column => 2);
+ #
+ $l_bold[$i]->grid(-row => 3, -column => 0, -sticky => "e");
+ $e_mincho_bold[$i]->grid(-row => 3, -column => 1);
+ $e_gothic_bold[$i]->grid(-row => 3, -column => 2);
+ #
+ $l_heavy[$i]->grid(-row => 4, -column => 0, -sticky => "e");
+ $e_gothic_heavy[$i]->grid(-row => 4, -column => 1);
+ $l_maru[$i]->grid(-row => 5, -column => 0, -sticky => "e");
+ $e_gothic_maru[$i]->grid(-row => 5, -column => 2);
+ $l_light[$i]->grid(-row => 6, -column => 0, -sticky => "e");
+ $e_mincho_light[$i]->grid(-row => 6, -column => 2);
+ }
+ #
+ # Button frame
+ $b_save = $bf->Button(-text => "Save");
+
+ #
+ # Actions:
+ #
+ # activate tabs when options are selected
+ $opt_vert->configure(-command => sub {
+ if (!$do_vertical && ($nb->raised() =~ m/Vertical/)) {
+ $nb->raise("Default");
+ }
+ $nb->pageconfigure("Vertical",
+ -state => ($do_vertical ? "normal" : "disabled"));
+ $nb->pageconfigure("ISO2004/Vertical",
+ -state => (($do_vertical & $do_iso2004) ? "normal" : "disabled"))
+ });
+ $opt_iso->configure(-command => sub {
+ if (!$do_iso2004 && ($nb->raised() =~ m/ISO2004/)) {
+ $nb->raise("Default");
+ }
+ $nb->pageconfigure("ISO2004",
+ -state => ($do_iso2004 ? "normal" : "disabled"));
+ $nb->pageconfigure("ISO2004/Vertical",
+ -state => (($do_vertical & $do_iso2004) ? "normal" : "disabled"))
+ });
+
+ # activate lower part for when otf is selected
+ $opt_otf->configure(-command => sub {
+ for my $i (0..$#order) {
+ $l_light[$i]->configure(
+ -state => ($do_otf ? "normal" : "disabled"));
+ $e_mincho_light[$i]->configure(
+ -state => ($do_otf ? "normal" : "disabled"),
+ -relief => ($do_otf ? "sunken" : "flat"));
+ #
+ $l_bold[$i]->configure(
+ -state => ($do_otf ? "normal" : "disabled"));
+ $e_mincho_bold[$i]->configure(
+ -state => ($do_otf ? "normal" : "disabled"),
+ -relief => ($do_otf ? "sunken" : "flat"));
+ $e_gothic_bold[$i]->configure(
+ -state => ($do_otf ? "normal" : "disabled"),
+ -relief => ($do_otf ? "sunken" : "flat"));
+ #
+ $l_heavy[$i]->configure(
+ -state => ($do_otf ? "normal" : "disabled"));
+ $l_maru[$i]->configure(
+ -state => ($do_otf ? "normal" : "disabled"));
+ $e_gothic_maru[$i]->configure(
+ -state => ($do_otf ? "normal" : "disabled"),
+ -relief => ($do_otf ? "sunken" : "flat"));
+ $e_gothic_heavy[$i]->configure(
+ -state => ($do_otf ? "normal" : "disabled"),
+ -relief => ($do_otf ? "sunken" : "flat"));
+ }
+ });
+ #
+ #
+ $b_save->configure(-command => \&export_font_maps, -state => "disabled");
+ $b_save->pack;
+
+ Tk::MainLoop();
+}
+
+sub validate_group_name {
+ my ($new_val, undef, $old_val) = @_;
+ $b_save->configure(-state => ($new_val eq "" ? "disabled" : "normal"));
+ return 1;
+}
+
+sub addgroup {
+ my ($str, $fref, $i_a, $i_b, @entries) = @_;
+ my $do = 1;
+ while (@entries) {
+ my $tfm = shift @entries;
+ my $enc = shift @entries;
+ addlines($str, $tfm, $enc, ($do ? $fref->[$i_a] : $fref->[$i_b]));
+ $do = !$do;
+ }
+}
+
+sub addlines {
+ my ($strref, @entries) = @_;
+ while (@entries) {
+ my $tfm = shift @entries;
+ my $enc = shift @entries;
+ my $fn = shift @entries;
+ if (defined($fn)) {
+ $$strref .= "$tfm $enc $fn\n";
+ } else {
+ print STDERR "target file for $tfm $enc not defined!\n";
+ }
+ }
+}
+
+sub export_font_maps {
+ if ($group_name eq "") {
+ print STDERR "That should not happen!\n";
+ exit 1;
+ }
+
+ # indirections
+ my $ii = ($do_iso2004 ? $iso_i : 0);
+ my $vi = ($do_vertical ? $vert_i : 0);
+ my $ivi = (($do_vertical && $do_vertical) ? $isovert_i : 0);
+ #
+
+ my ($ptexlines, $ptex04lines, $uptexlines, $uptex04lines);
+ my ($otflines, $otfuplines);
+ addlines(\$ptexlines,
+ 'rml', 'H', $f_mincho_regular[0],
+ 'rmlv','V', $f_mincho_regular[$vi],
+ 'gbm', 'H', $f_gothic_regular[0],
+ 'gbmv','V', $f_gothic_regular[$vi]);
+ addlines(\$ptex04lines,
+ 'rml', 'H', $f_mincho_regular[$ii],
+ 'rmlv','V', $f_mincho_regular[$ivi],
+ 'gbm', 'H', $f_gothic_regular[$ii],
+ 'gbmv','V', $f_gothic_regular[$ivi]);
+ addlines(\$uptexlines,
+ 'urml', 'UniJIS-UTF16-H', $f_mincho_regular[0],
+ 'urmlv', 'UniJIS-UTF16-V', $f_mincho_regular[$vi],
+ 'ugbm', 'UniJIS-UTF16-H', $f_gothic_regular[0],
+ 'ugbmv', 'UniJIS-UTF16-V', $f_gothic_regular[$vi],
+ 'uprml-h', 'UniJIS-UTF16-H', $f_mincho_regular[0],
+ 'uprml-v', 'UniJIS-UTF16-V', $f_mincho_regular[$vi],
+ 'upgbm-h', 'UniJIS-UTF16-H', $f_gothic_regular[0],
+ 'upgbm-v', 'UniJIS-UTF16-V', $f_gothic_regular[$vi],
+ 'uprml-hq', 'UniJIS-UCS2-H', $f_mincho_regular[0],
+ 'upgbm-hq', 'UniJIS-UCS2-H', $f_gothic_regular[0]);
+ addlines(\$uptex04lines,
+ 'urml', 'UniJIS-UTF16-H', $f_mincho_regular[$ii],
+ 'urmlv', 'UniJIS-UTF16-V', $f_mincho_regular[$ivi],
+ 'ugbm', 'UniJIS-UTF16-H', $f_gothic_regular[$ii],
+ 'ugbmv', 'UniJIS-UTF16-V', $f_gothic_regular[$ivi],
+ 'uprml-h', 'UniJIS-UTF16-H', $f_mincho_regular[$ii],
+ 'uprml-v', 'UniJIS-UTF16-V', $f_mincho_regular[$ivi],
+ 'upgbm-h', 'UniJIS-UTF16-H', $f_gothic_regular[$ii],
+ 'upgbm-v', 'UniJIS-UTF16-V', $f_gothic_regular[$ivi],
+ 'uprml-hq', 'UniJIS-UCS2-H', $f_mincho_regular[$ii],
+ 'upgbm-hq', 'UniJIS-UCS2-H', $f_gothic_regular[$ii]);
+
+
+ addlines(\$otflines,
+ '%', 'mincho regular', '',
+ 'otf-ujmr-h', 'UniJIS-UTF16-H', $f_mincho_regular[0],
+ 'otf-ujmr-v', 'UniJIS-UTF16-V', $f_mincho_regular[$vi],
+ 'otf-cjmr-h', 'Identity-H', $f_mincho_regular[0],
+ 'otf-cjmr-v', 'Identity-V', $f_mincho_regular[$vi],
+ 'hminr-h', 'H', $f_mincho_regular[0],
+ 'hminr-v', 'V', $f_mincho_regular[$vi],
+ '%', 'gothic regular', '',
+ 'otf-ujgr-h', 'UniJIS-UTF16-H', $f_gothic_regular[0],
+ 'otf-ujgr-v', 'UniJIS-UTF16-V', $f_gothic_regular[$vi],
+ 'otf-cjgr-h', 'Identity-H', $f_gothic_regular[0],
+ 'otf-cjgr-v', 'Identity-V', $f_gothic_regular[$vi],
+ 'hgothr-h', 'H', $f_gothic_regular[0],
+ 'hgothr-v', 'V', $f_gothic_regular[$vi],
+ '%', 'mincho bold', '');
+ addgroup(\$otflines, ($do_otf ? \@f_mincho_bold : \@f_mincho_regular),
+ 0, $vi,
+ 'otf-ujmb-h', 'UniJIS-UTF16-H',
+ 'otf-ujmb-v', 'UniJIS-UTF16-V',
+ 'otf-cjmb-h', 'Identity-H',
+ 'otf-cjmb-v', 'Identity-V',
+ 'hminb-h', 'H',
+ 'hminb-v', 'V');
+ addlines(\$otflines, '%', 'gothic bold', '');
+ addgroup(\$otflines, ($do_otf ? \@f_gothic_bold : \@f_gothic_regular),
+ 0, $vi,
+ 'otf-ujgb-h', 'UniJIS-UTF16-H',
+ 'otf-ujgb-v', 'UniJIS-UTF16-V',
+ 'otf-cjgb-h', 'Identity-H',
+ 'otf-cjgb-v', 'Identity-V',
+ 'hgothb-h', 'H',
+ 'hgothb-v', 'V');
+ addlines(\$otflines, '%', 'gothic heavy', '');
+ addgroup(\$otflines, ($do_otf ? \@f_gothic_heavy : \@f_gothic_regular),
+ 0, $vi,
+ 'hgotheb-h', 'H',
+ 'hgotheb-v', 'V');
+ addlines(\$otflines, '%', 'gothic maru', '');
+ addgroup(\$otflines, ($do_otf ? \@f_gothic_maru : \@f_gothic_regular),
+ 0, $vi,
+ 'otf-ujmgr-h', 'UniJIS-UTF16-H',
+ 'otf-ujmgr-v', 'UniJIS-UTF16-V',
+ 'otf-cjmgr-h', 'Identity-H',
+ 'otf-cjmgr-v', 'Identity-V',
+ 'hmgothr-h', 'H',
+ 'hmgothr-v', 'V');
+ addlines(\$otflines, '%', 'mincho light', '');
+ addgroup(\$otflines, ($do_otf ? \@f_mincho_light : \@f_mincho_regular),
+ 0, $vi,
+ 'otf-ujml-h', 'UniJIS-UTF16-H',
+ 'otf-ujml-v', 'UniJIS-UTF16-V',
+ 'otf-cjml-h', 'Identity-H',
+ 'otf-cjml-v', 'Identity-V',
+ 'hminl-h', 'H',
+ 'hminl-v', 'V');
+ addlines(\$otflines, '%', 'JIS 2004', '',
+ 'otf-ujmrn-h', 'UniJIS2004-UTF16-H', $f_mincho_regular[$ii],
+ 'otf-ujmrn-v', 'UniJIS2004-UTF16-V', $f_mincho_regular[$ivi],
+ 'hminrn-h', 'H', $f_mincho_regular[$ii],
+ 'hminrn-v', 'V', $f_mincho_regular[$ivi],
+ '%', '', '',
+ 'otf-ujgrn-h', 'UniJIS2004-UTF16-H', $f_gothic_regular[$ii],
+ 'otf-ujgrn-v', 'UniJIS2004-UTF16-V', $f_gothic_regular[$ivi],
+ 'hgothrn-h', 'H' , $f_gothic_regular[$ii],
+ 'hgothrn-v', 'V' , $f_gothic_regular[$ivi],
+ '%', '', '');
+ addgroup(\$otflines, ($do_otf ? \@f_mincho_bold : \@f_mincho_regular),
+ $ii, $ivi,
+ 'otf-ujmbn-h', 'UniJIS2004-UTF16-H',
+ 'otf-ujmbn-v', 'UniJIS2004-UTF16-V',
+ 'hminbn-h', 'H',
+ 'hminbn-v', 'V');
+ addlines(\$otflines, '%', '', '');
+ addgroup(\$otflines, ($do_otf ? \@f_gothic_bold : \@f_gothic_regular),
+ $ii, $ivi,
+ 'otf-ujgbn-h', 'UniJIS2004-UTF16-H',
+ 'otf-ujgbn-v', 'UniJIS2004-UTF16-V',
+ 'hgothbn-h', 'H',
+ 'hgothbn-v', 'V');
+ addlines(\$otflines, '%', '', '');
+ addgroup(\$otflines, ($do_otf ? \@f_gothic_heavy : \@f_gothic_regular),
+ $ii, $ivi,
+ 'otf-ujmgrn-h', 'UniJIS2004-UTF16-H',
+ 'otf-ujmgrn-v', 'UniJIS2004-UTF16-V',
+ 'hmgothrn-h', 'H',
+ 'hmgothrn-v', 'V');
+ addlines(\$otflines, '%', '', '');
+ addgroup(\$otflines, ($do_otf ? \@f_mincho_light : \@f_mincho_regular),
+ $ii, $ivi,
+ 'otf-ujmln-h', 'UniJIS2004-UTF16-H',
+ 'otf-ujmln-v', 'UniJIS2004-UTF16-V',
+ 'hminln-h', 'H',
+ 'hminln-v', 'V');
+
+ addlines(\$otfuplines,
+ 'uphminr-h', 'UniJIS-UTF16-H', $f_mincho_regular[0],
+ 'uphminr-v', 'UniJIS-UTF16-V', $f_mincho_regular[$vi],
+ 'uphgothr-h', 'UniJIS-UTF16-H', $f_gothic_regular[0],
+ 'uphgothr-v', 'UniJIS-UTF16-V', $f_gothic_regular[$vi]);
+ addgroup(\$otfuplines, ($do_otf ? \@f_mincho_bold : \@f_mincho_regular),
+ 0, $vi,
+ 'uphminb-h', 'UniJIS-UTF16-H',
+ 'uphminb-v', 'UniJIS-UTF16-V');
+ addgroup(\$otfuplines, ($do_otf ? \@f_gothic_bold : \@f_gothic_regular),
+ 0, $vi,
+ 'uphgothb-h', 'UniJIS-UTF16-H',
+ 'uphgothb-v', 'UniJIS-UTF16-V');
+ addgroup(\$otfuplines, ($do_otf ? \@f_gothic_heavy : \@f_gothic_regular),
+ 0, $vi,
+ 'uphgotheb-h', 'UniJIS-UTF16-H',
+ 'uphgotheb-v', 'UniJIS-UTF16-V');
+ addgroup(\$otfuplines, ($do_otf ? \@f_gothic_maru : \@f_gothic_regular),
+ 0, $vi,
+ 'uphmgothr-h', 'UniJIS-UTF16-H',
+ 'uphmgothr-v', 'UniJIS-UTF16-V');
+ addgroup(\$otfuplines, ($do_otf ? \@f_mincho_light : \@f_mincho_regular),
+ 0, $vi,
+ 'uphminl-h', 'UniJIS-UTF16-H',
+ 'uphminl-v', 'UniJIS-UTF16-V');
+
+ # check that none of the output files are already existing:
+ if (-r "ptex-$group_name.map" ||
+ -r "ptex-${group_name}-04.map" ||
+ -r "uptex-$group_name.map" ||
+ -r "uptex-${group_name}-04.map" ||
+ -r "otf-$group_name.map" ||
+ -r "otf-up-$group_name.map" ||
+ -r "$group_name.map" ||
+ -r "${group_name}-04.map") {
+ print STDERR "Some of the output files already exist in the cwd, aborting!\n";
+ exit 1;
+ }
+
+ # generate the output files
+ open (OUT, ">ptex-$group_name.map")
+ or die("Cannot open ptex-$group_name.map for writing: $!");
+ print OUT "% generated by $prg\n$ptexlines\n";
+ close(OUT);
+
+ open (OUT, ">ptex-${group_name}-04.map")
+ or die("Cannot open ptex-${group_name}-04.map for writing: $!");
+ print OUT "% generated by $prg\n$ptex04lines\n";
+ close(OUT);
+
+ open (OUT, ">uptex-$group_name.map")
+ or die("Cannot open uptex-$group_name.map for writing: $!");
+ print OUT "% generated by $prg\n$uptexlines\n";
+ close(OUT);
+
+ open (OUT, ">uptex-${group_name}-04.map")
+ or die("Cannot open uptex-${group_name}-04.map for writing: $!");
+ print OUT "% generated by $prg\n$uptex04lines\n";
+ close(OUT);
+
+ open (OUT, ">otf-$group_name.map")
+ or die("Cannot open otf-$group_name.map for writing: $!");
+ print OUT "% generated by $prg\n$otflines\n";
+ close(OUT);
+
+ open (OUT, ">otf-up-$group_name.map")
+ or die("Cannot open otf-up-$group_name.map for writing: $!");
+ print OUT "% generated by $prg\n$otfuplines\n";
+ close(OUT);
+
+ open (OUT, ">$group_name.map")
+ or die("Cannot open $group_name.map for writing: $!");
+ print OUT "% generated by $prg\n%\n% maps for family $group_name\n\n";
+ print OUT "% ptex\n$ptexlines\n";
+ print OUT "% uptex\n$uptexlines\n";
+ print OUT "% otf\n$otflines\n";
+ print OUT "% otf-uptex\n$otfuplines\n";
+ close(OUT);
+
+ open (OUT, ">${group_name}-04.map")
+ or die("Cannot open ${group_name}-04.map for writing: $!");
+ print OUT "% generated by $prg\n%\n% maps for family $group_name ISO2004\n\n";
+ print OUT "% ptex\n$ptex04lines\n";
+ print OUT "% uptex\n$uptex04lines\n";
+ print OUT "% otf\n$otflines\n";
+ print OUT "% otf-uptex\n$otfuplines\n";
+ close(OUT);
+
+ my $cwd = cwd();
+
+ $mw->Dialog(-title => "Finished",
+ -text => "Fontmaps have been created in the $cwd.\nPlease move them to a place where dvipdfmx can find them.",
+ -buttons => [ "Finish" ])->Show();
+
+ $mw->destroy;
+ exit 0;
+}
+
+
+sub win32 { return ($^O =~ /^MSWin/i ? 1 : 0); }
+
+__END__
+
+=head1 NAME
+
+kanji-fontmap-creator - GUI to create map file collections for Kanji fonts
+
+=head1 SYNOPSIS
+
+kanji-fontmap-creator [I<option>]
+
+=head1 DESCRIPTION
+
+Create fontmap families for updmap's C<jaEmbed> setting. For details
+see the man page of B<updmap>(1) and the web page
+L<http://tug.org/texlive/updmap-kanji.html>
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-version>
+
+Output version information and exit.
+
+=item B<-help>, B<-?>, B<-h>
+
+Display this help and exit.
+
+=item B<-lang> I<llcode>
+
+By default, the GUI tries to deduce your language from the environment
+(on Windows via the registry, on Unix via C<LC_MESSAGES>). If that fails
+you can select a different language by giving this option with a
+language code (based on ISO 639-1). Currently supported is only
+English.
+
+=back
+
+=head1 AUTHORS AND COPYRIGHT
+
+This script and documentation was written by Norbert Preining
+and both are licensed under the GNU General Public License Version 2
+or later.
+
+=cut
+
+
+# vim:set tabstop=2 expandtab: #
diff --git a/fonts/ptex-fontmaps/script/updmap-otf.sh b/fonts/ptex-fontmaps/script/updmap-otf.sh
new file mode 100755
index 0000000000..0a188addd5
--- /dev/null
+++ b/fonts/ptex-fontmaps/script/updmap-otf.sh
@@ -0,0 +1,323 @@
+#!/bin/sh
+# updmap-otf: v0.9.1
+#
+# Copyright 2004-2006 by KOBAYASHI R. Taizo
+# Copyright 2011-2012 by PREINING Norbert
+#
+# WARNING: This file is NOT developed any more. TeX Live uses a version
+# rewritten in perl called updmap-setup-kanji, which is located
+# and developed in the same place as this file.
+#
+# For development see
+# http://www.tug.org/svn/texlive/trunk/Build/source/extra/jfontmaps/
+#
+# This file is licensed under GPL version 3 or any later version.
+# For copyright statements see end of file.
+#
+# 27 Jan 2012 by PREINING Norbert <preining@logic.at> v0.9.2
+# support IPA and IPAex fonts
+# improve and extended documentation
+# 11 Nov 2011 by PREINING Norbert <preining@logic.at> v0.9.1
+# use kpsewhich for finding fonts
+# use updmap-sys --setoption kanjiEmbed to select the font family
+# use current names of map files
+# use different font name for Kozuka font, as used in the map file
+# get state from updmap.cfg, not from some state file
+# 27 May 2006 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.9
+# use noEmbed.map instead of noEmbeddedFont.map
+# 10 Jun 2005 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.8
+# modified to use updmap-sys in teTeX3
+# 07 Nov 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.7
+# do not echo back the message of updmap.
+# 17 Oct 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.6
+# set hiragino map file if nofont is installed and arg is auto.
+# 04 Oct 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.5
+# handl standby map files more strictly
+# 20 Sep 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.4
+# hand over current status to map file installer
+# 19 Sep 2004 by KOBAYASHI R. Taizo <tkoba965@mac.com> v0.3
+# handl *-udvips.map in TEXMF/dvipdfm/config/otf/
+# 02 Mar 2004 by KOBAYASHI R. Taizo <tkoba@ike-dyn.ritsumei.ac.jp> v0.2
+# added noFont-udvips.map
+# 28 Feb 2004 by KOBAYASHI R. Taizo <tkoba@ike-dyn.ritsumei.ac.jp> v0.1
+
+
+###
+### Usage
+###
+
+Usage() {
+cat <<EOF
+ updmap-otf Front end to updmap.cfg configuration for Japanese fonts
+ as used in the otf package.
+
+ This script searches for some of the most common fonts
+ for embedding into pdfs by dvipdfmx.
+
+ Usage: updmap-otf {<fontname>|auto|nofont|status}
+
+ <fontname> set fonts as defined by the map file otf-<fontname>.map
+ if it exists.
+ auto: sets one of the following supported font families
+ automatically:
+ hiragino, morisawa, kozuka, ipaex, ipa
+ nofont: set no fonts are embedded
+ If your system does not have any of the supported font
+ families as specified above, this target is selected
+ automatically.
+ status: get information about current environment and usable font map
+
+EOF
+}
+
+#
+# representatives of support font families
+#
+hiragino_font=HiraMinPro-W3.otf
+morisawa_font=A-OTF-RyuminPro-Light.otf
+kozuka_font=KozMinPro-Regular.otf
+ipa_font=ipam.ttf
+ipaex_font=ipaexm.ttf
+
+
+###
+### Check Installed Font
+###
+
+CheckInstallFont() {
+ if kpsewhich $hiragino_font >/dev/null ; then
+ HIRAGINO=installed
+ else
+ HIRAGINO=""
+ fi
+
+ if kpsewhich $morisawa_font >/dev/null ; then
+ MORISAWA=installed
+ else
+ MORISAWA=""
+ fi
+
+ if kpsewhich $kozuka_font >/dev/null ; then
+ KOZUKA=installed
+ else
+ KOZUKA=""
+ fi
+
+ if kpsewhich $ipa_font >/dev/null ; then
+ IPA=installed
+ else
+ IPA=""
+ fi
+
+ if kpsewhich $ipaex_font >/dev/null ; then
+ IPAEX=installed
+ else
+ IPAEX=""
+ fi
+
+
+}
+
+###
+### GetStatus
+###
+
+GetStatus() {
+
+STATUS=$(grep ^kanjiEmbed $(kpsewhich updmap.cfg) | awk '{print$2}')
+
+if kpsewhich otf-$STATUS.map >/dev/null ; then
+ echo "CURRENT map file : otf-$STATUS.map"
+else
+ echo "WARNING: Currently selected map file cannot be found: otf-$STATUS.map"
+fi
+
+
+for MAPFILE in otf-hiragino.map otf-morisawa.map otf-kozuka.map otf-ipaex.map otf-ipa.map
+do
+ if [ "$MAPFILE" = "otf-$STATUS.map" ] ; then
+ continue
+ fi
+ mffound=`kpsewhich $MAPFILE`
+ if [ -n "$mffound" ] ; then
+ case "$MAPFILE" in
+ otf-hiragino.map)
+ if [ "$HIRAGINO" = "installed" ]; then
+ echo "Standby map file : $MAPFILE"
+ fi
+ ;;
+ otf-morisawa.map)
+ if [ "$MORISAWA" = "installed" ]; then
+ echo "Standby map file : $MAPFILE"
+ fi
+ ;;
+ otf-kozuka.map)
+ if [ "$KOZUKA" = "installed" ]; then
+ echo "Standby map file : $MAPFILE"
+ fi
+ ;;
+ otf-ipa.map)
+ if [ "$IPA" = "installed" ]; then
+ echo "Standby map file : $MAPFILE"
+ fi
+ ;;
+ otf-ipaex.map)
+ if [ "$IPAEX" = "installed" ]; then
+ echo "Standby map file : $MAPFILE"
+ fi
+ ;;
+ *)
+ echo "Should not happen!"
+ ;;
+ esac
+ fi
+done
+
+}
+
+###
+### Setup Map files
+###
+
+SetupMapFile() {
+
+MAPFILE=otf-$1.map
+
+if kpsewhich $MAPFILE >/dev/null ; then
+ echo "Setting up ... $MAPFILE"
+ updmap-sys -setoption kanjiEmbed $1
+ updmap-sys
+else
+ echo "NOT EXIST $MAPFILE"
+ return 1
+fi
+}
+
+###
+### MAIN
+###
+
+main() {
+
+# mktexlsr 2> /dev/null
+
+CheckInstallFont
+
+if [ $# != 1 ] ; then
+ eval Usage ${0##*/}
+ return -1
+fi
+
+case "$1" in
+ hiragino)
+ if [ "$HIRAGINO" = "installed" ]; then
+ SetupMapFile hiragino
+ else
+ main auto
+ fi
+ ;;
+ morisawa)
+ if [ "$MORISAWA" = "installed" ]; then
+ SetupMapFile morisawa
+ else
+ main auto
+ fi
+ ;;
+ kozuka)
+ if [ "$KOZUKA" = "installed" ]; then
+ SetupMapFile kozuka
+ else
+ main auto
+ fi
+ ;;
+ ipa)
+ if [ "$IPA" = "installed" ]; then
+ SetupMapFile ipa
+ else
+ main auto
+ fi
+ ;;
+ ipaex)
+ if [ "$IPAEX" = "installed" ]; then
+ SetupMapFile ipaex
+ else
+ main auto
+ fi
+ ;;
+ nofont)
+ SetupMapFile noEmbed
+ ;;
+ auto)
+ GetStatus
+ # first check if we have a status set and the font is installed
+ # in this case don't change anything, just make sure
+ if [ "$STATUS" = "morisawa" ] && [ "$MORISAWA" = "installed" ]; then
+ SetupMapFile morisawa
+ elif [ "$STATUS" = "kozuka" ] && [ "$KOZUKA" = "installed" ]; then
+ SetupMapFile kozuka
+ elif [ "$STATUS" = "hiragino" ] && [ "$HIRAGINO" = "installed" ]; then
+ SetupMapFile hiragino
+ elif [ "$STATUS" = "ipaex" ] && [ "$IPAEX" = "installed" ]; then
+ SetupMapFile ipaex
+ elif [ "$STATUS" = "ipa" ] && [ "$IPA" = "installed" ]; then
+ SetupMapFile ipa
+ else
+ if [ "$STATUS" = "noEmbed" ] || [ "$STATUS" = "" ]; then
+ : do nothing here, we dont have to warn
+ else
+ # some unknown setting is set up currently, overwrite
+ # but warn
+ echo "Previous setting $STATUS is unknown, replacing it!"
+ fi
+ # if we are in the noEmbed or nothing set case, but one
+ # of the three fonts hiragino/morisawa/kozuka are present
+ # then use them
+ if [ "$HIRAGINO" = "installed" ]; then
+ SetupMapFile hiragino
+ elif [ "$MORISAWA" = "installed" ]; then
+ SetupMapFile morisawa
+ elif [ "$KOZUKA" = "installed" ]; then
+ SetupMapFile kozuka
+ elif [ "$IPAEX" = "installed" ]; then
+ SetupMapFile ipaex
+ elif [ "$IPA" = "installed" ]; then
+ SetupMapFile ipa
+ else
+ SetupMapFile noEmbed
+ fi
+ fi
+ ;;
+ status)
+ GetStatus
+ return 0
+ ;;
+ *)
+ SetupMapFile $1
+ ;;
+esac
+}
+
+main $@
+
+#
+#
+# Copyright statements:
+#
+# KOBAYASHI Taizo
+# email to preining@logic.at
+# Message-Id: <20120130.162953.59640143170594580.tkoba@cc.kyushu-u.ac.jp>
+# Message-Id: <20120201.105639.625859878546968959.tkoba@cc.kyushu-u.ac.jp>
+# --------------------------------------------------------
+# copyright statement は簡単に以下で結構です。
+#
+# Copyright 2004-2006 by KOBAYASHI Taizo
+#
+# では
+# GPL version 3 or any later version
+#
+# --------------------------------------------------------
+#
+# PREINING Norbert
+# as author and maintainer of the current file
+# Licensed under GPL version 3 or any later version
+#