diff options
author | Hironobu Yamashita <h.y.acetaminophen@gmail.com> | 2020-04-18 11:41:04 +0000 |
---|---|---|
committer | Hironobu Yamashita <h.y.acetaminophen@gmail.com> | 2020-04-18 11:41:04 +0000 |
commit | 9abea665ee5e61f6bca9dca785ba9473d0702cf1 (patch) | |
tree | 6b1daef1a83356b32492a064c07637cb89087630 | |
parent | 9c4cc7b5063be4b40dd4c17f8c9141a6b1412e5f (diff) |
haranoaji-tlpost.pl: prepare for haranoaji update (M. Hosoda)
git-svn-id: svn://tug.org/texlive/trunk@54782 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/tlpkg/tlpostcode/haranoaji-tlpost.pl | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/Master/tlpkg/tlpostcode/haranoaji-tlpost.pl b/Master/tlpkg/tlpostcode/haranoaji-tlpost.pl index 3ec52573246..1d5ee0e4cf4 100644 --- a/Master/tlpkg/tlpostcode/haranoaji-tlpost.pl +++ b/Master/tlpkg/tlpostcode/haranoaji-tlpost.pl @@ -37,6 +37,8 @@ use utf8; use feature 'state'; use Encode; +my $verbose = 0; + if (win32 ()) { # These packages are not necessarily available on non-Windows, so # read them at runtime instead of compile time. @@ -50,11 +52,12 @@ if (win32 ()) { require Win32::API; Win32::API->import (); + require File::Compare; + File::Compare->import (); } else { # for non-Windows, silently do nothing, to avoid tl-update-tlnet failure. exit 0; } -my $verbose = 0; # Font list: PostScript name => File name in TEXMF my %font_list = ( @@ -75,8 +78,11 @@ my %font_list = ( 'HaranoAjiGothic-Heavy' => 'HaranoAjiGothic-Heavy.otf' ); -# CMap list -my @cmap_list = ( +# CMap list for install +my @cmap_list_install = ('2004-H', '2004-V'); + +# CMap list for snippet +my @cmap_list_snippet = ( 'H', 'V', '2004-H', '2004-V', 'UniJIS-UTF16-H', 'UniJIS-UTF16-V', @@ -154,12 +160,24 @@ sub install_cidfont { for my $psname (sort keys %font_list) { my_log ("\nFor $psname ...\n"); + my $fontpath_in_texmf = search_fontpath ($font_list{$psname}); + if (! $fontpath_in_texmf) { + my_log ("Not found: Font in TEXMF: $font_list{$psname}\n"); + next; + } + my $fontpath_in_cidfontdir = "$cidfontdir/$psname"; if (wrapper_isfile ($fontpath_in_cidfontdir)) { my_log ("Already exists: ${fontpath_in_cidfontdir}\n"); - next; + if (file_compare ($fontpath_in_texmf, $fontpath_in_cidfontdir)) { + my_log ("Different from the file in TEXMF. Deleting.\n"); + wrapper_unlink ($fontpath_in_cidfontdir); + } else { + my_log ("Same as the file in TEXMF. Skipping.\n"); + next; + } } - my $fontpath_in_texmf = search_fontpath ($font_list{$psname}) or next; + link_or_copy ($fontpath_in_texmf, $fontpath_in_cidfontdir); } } @@ -168,15 +186,27 @@ sub install_cidfont { sub install_cmap { my_log ("\ninstall_cmap\n"); - foreach my $cmapname (@cmap_list) { + foreach my $cmapname (@cmap_list_install) { my_log ("\nFor $cmapname ...\n"); + my $cmappath_in_texmf = search_cmappath ($cmapname); + if (! $cmappath_in_texmf) { + my_log ("Not found: CMap in TEXMF: $cmapname\n"); + next; + } + my $cmappath_in_cmapdir = "$cmapdir/$cmapname"; if (wrapper_isfile ($cmappath_in_cmapdir)) { my_log ("Already exists: ${cmappath_in_cmapdir}\n"); - next; + if (file_compare ($cmappath_in_texmf, $cmappath_in_cmapdir)) { + my_log ("Different from the file in TEXMF. Deleting.\n"); + wrapper_unlink ($cmappath_in_cmapdir); + } else { + my_log ("Same as the file in TEXMF. Skipping.\n"); + next; + } } - my $cmappath_in_texmf = search_cmappath ($cmapname) or next; + link_or_copy ($cmappath_in_texmf, $cmappath_in_cmapdir); } } @@ -188,11 +218,11 @@ sub install_snippet { for my $psname (sort keys %font_list) { my_log ("\nFor $psname ...\n"); - foreach my $cmapname (@cmap_list) { + foreach my $cmapname (@cmap_list_snippet) { my $snippetpath = "$fontdir/$psname-$cmapname"; if (wrapper_isfile ($snippetpath)) { - my_log ("Already exists: ${snippetpath}\n"); - next; + my_log ("Already exists: ${snippetpath}\nDeleting.\n"); + wrapper_unlink ($snippetpath); } my $contents = <<"EOS"; @@ -239,7 +269,7 @@ sub remove_snippet { for my $psname (sort keys %font_list) { my_log ("\nFor $psname ...\n"); - foreach my $cmapname (@cmap_list) { + foreach my $cmapname (@cmap_list_snippet) { my $snippetpath = "$fontdir/$psname-$cmapname"; if (wrapper_isfile ($snippetpath)) { wrapper_unlink ($snippetpath); @@ -352,6 +382,20 @@ sub create_file_with_contents { close $fh; } +# File compare +sub file_compare { + my ($filename1, $filename2) = @_; + + # TODO: Compare file by -W API on Windows + my $result = compare (encode ('locale_fs', $filename1), + encode ('locale_fs', $filename2)); + if ($result == -1) { + die ("File compare failed: ${filename1}, ${filename2}\n"); + } + + return $result; +} + # Directory existence check sub wrapper_isdir { my ($dirname) = @_; |