From d60b32ec021c0ee2615e52e864ee6285b6512ff5 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 23 Feb 2024 16:44:23 +0000 Subject: use our own XE_* variables instead of system FONTCONFIG_PATH and FC_CACHEDIR git-svn-id: svn://tug.org/texlive/trunk@70088 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/tlpostcode/xetex.pl | 76 ++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 30 deletions(-) (limited to 'Master/tlpkg/tlpostcode') diff --git a/Master/tlpkg/tlpostcode/xetex.pl b/Master/tlpkg/tlpostcode/xetex.pl index 7b691425175..80e70fb236e 100644 --- a/Master/tlpkg/tlpostcode/xetex.pl +++ b/Master/tlpkg/tlpostcode/xetex.pl @@ -1,12 +1,12 @@ # $Id$ # post action for xetex to handle system font stuff. -# Copyright 2008, 2009, 2011 Norbert Preining +# Copyright 2008-2024 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. # -# We create the fontconfig configuration file. On Windows, +# We create the fontconfig configuration file with all TL fonts. On Windows, # we also run fc-cache to make the fonts available. -# http://www.tug.org/texlive/doc/texlive-en/texlive-en.html#xetexfontconfig +# https://tug.org/texlive/doc/texlive-en/texlive-en.html#xetexfontconfig my $texdir; my $mode; @@ -14,8 +14,8 @@ my $skip_gen; # not used for (un)install BEGIN { $^W = 1; - $mode = lc($ARGV[0]); - $texdir = $ARGV[1]; + $mode = lc(@ARGV ? $ARGV[0] : "no-argv0??"); + $texdir = $ARGV[1] || "no-argv1??"; $skip_gen = (defined $ARGV[2]) ? 1 : 0; # not used with normal installs # make Perl find our packages first: unshift (@INC, "$texdir/tlpkg"); @@ -36,14 +36,24 @@ sub do_remove { sub do_install { # fontconfig-related stuff. - chomp( my $fcache = `kpsewhich -var-value=FC_CACHEDIR` ) ; - chomp( my $fconf = `kpsewhich -var-value=FONTCONFIG_PATH` ) ; + # use these TL-specific variables, supported by TL's XeTeX on Windows, + # so we don't touch a true system directory such as /etc/fonts on Unix, + # as we would do if we used FC_CACHEDIR and FONTCONFIG_PATH. + chomp( my $fcachedir = `kpsewhich -var-value=XE_FC_CACHEDIR` ) ; + chomp( my $fconfdir = `kpsewhich -var-value=XE_FONTCONFIG_PATH` ) ; + chomp( my $fconffile = `kpsewhich -var-value=FONTCONFIG_FILE` ) ; if (-r "$texdir/bin/windows/xetex.exe") { - # we have installed w32, so put it into texmfsysvar. - mkdirhier($fcache); - mkdirhier($fconf); - TeXLive::TLUtils::rmtree($fcache); - TeXLive::TLUtils::rmtree($fconf); + # Windows binaries are installed, so copy the tlpostcode/xetex/* + # subdirs into the TL dirs above. + # + # We (weirdly) create the directories and then remove them to ensure + # that any intervening subdirs are created, but the actual dir we + # copy into is non-existent. + mkdirhier($fcachedir); + mkdirhier($fconfdir); + TeXLive::TLUtils::rmtree($fcachedir); + TeXLive::TLUtils::rmtree($fconfdir); + my @cpycmd = (); if (wndws()) { push @cpycmd, "xcopy", "/e", "/i", "/q", "/y"; @@ -55,15 +65,15 @@ sub do_install { my $postxetex = "$texdir/tlpkg/tlpostcode/xetex"; system(@cpycmd, (wndws() ? conv_to_w32_path("$postxetex/conf") : "$postxetex/conf"), - (wndws() ? conv_to_w32_path($fconf) : $fconf)); + (wndws() ? conv_to_w32_path($fconfdir) : $fconfdir)); system(@cpycmd, (wndws() ? conv_to_w32_path("$postxetex/cache") : "$postxetex/cache"), - (wndws() ? conv_to_w32_path($fcache) : $fcache)); + (wndws() ? conv_to_w32_path($fcachedir) : $fcachedir)); - if (open(FONTSCONF, "<$texdir/tlpkg/tlpostcode/xetex/conf/fonts.conf")) { + if (open(FONTSCONF, "<$postxetex/conf/fonts.conf")) { my @lines = ; close(FONTSCONF); - if (open(FONTSCONF, ">$fconf/fonts.conf")) { + if (open(FONTSCONF, ">$fconfdir/$fconffile")) { my $winfontdir; if (wndws()) { $winfontdir = $ENV{'SystemRoot'}.'/fonts'; @@ -74,24 +84,30 @@ sub do_install { $_ =~ s!c:/windows/fonts!$winfontdir! if wndws(); print FONTSCONF; } - close(FONTSCONF); + close(FONTSCONF) + || tlwarn("close($postxetex/conf/fonts.conf) failed: $!"); } else { - warn("open(>$fconf/fonts.conf) failed: $!"); + tlwarn("open(>$fconfdir/$fconffile) failed: $!"); } } else { - warn("open($texdir/tlpkg/tlpostcode/xetex/conf/fonts.conf) failed: $!"); + tlwarn("open($postxetex/conf/fonts.conf) failed: $!"); } } - if (wndws() && !$skip_gen) { - # call fc-cache but only when we install on w32! - info("Running fc-cache -v -r\n"); - log( `fc-cache -v -r 2>&1` ); # run it, log output + + if (wndws()) { + if (!$skip_gen) { + # call fc-cache -- but only if we're actually running under Windows, + # not merely installing its binaries. + info("Running fc-cache -v -r\n"); + log( `fc-cache -v -r 2>&1` ); # run it, log output + } } else { - # non-Windows: create texlive-fontconfig.conf file in $texmfsysvar. - mkdirhier("$fconf/conf"); - if (!open(FONTSCONF, ">$fconf/texlive-fontconfig.conf")) { - warn("open(>$fconf/texlive-fontconfig.conf): $!"); + # non-Windows: merely create a texlive-fontconfig.conf file, + # in (the TL directory) XE_FONTCONFIG_PATH. + mkdirhier("$fconfdir"); + if (!open(FONTSCONF, ">$fconfdir/texlive-fontconfig.conf")) { + tlwarn("open(>$fconfdir/texlive-fontconfig.conf) failed: $!"); } else { print FONTSCONF ' @@ -102,15 +118,15 @@ sub do_install { } print FONTSCONF "\n"; close(FONTSCONF) - || tlwarn("close($fconf/texlive-fontconfig.conf) failed: $!"); + || tlwarn("close($fconfdir/texlive-fontconfig.conf) failed: $!"); } - # cygwin specific warning + # cygwin-specific warning # we don't have our platform name available ... chomp(my $un = `uname`); if ($un =~ m/cygwin/i) { if (! -r "/usr/bin/cygfontconfig-1.dll") { - printf STDERR <