groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/01: [gropdf]: Changes to BuildFoundries.


From: Deri James
Subject: [groff] 01/01: [gropdf]: Changes to BuildFoundries.
Date: Fri, 10 Jun 2022 16:15:16 -0400 (EDT)

deri pushed a commit to branch master
in repository groff.

commit 4ae4aeb6555f4f16c28fcb03eb1f56577826054c
Author: Deri James <deri@chuzzlewit.myzen.co.uk>
AuthorDate: Fri Jun 10 21:13:24 2022 +0100

    [gropdf]: Changes to BuildFoundries.
    
    * font/devpdf/util/BuildFoundries.pl: Collect search paths into
    an array rather than a colon delimited string, this allows
    the @PATH_SEPARATOR@ character (':' or ';') to be used to
    delimit paths yielded by the command 'gs -h' but still use ':'
    to delimit paths in the Foundry file. This means the same
    Foundry file can be used on all systems.
    
    * font/devpdf/Foundry.in: Add more likely paths to find the URW
    fonts.
---
 ChangeLog                          |  14 ++++
 font/devpdf/Foundry.in             |   2 +-
 font/devpdf/util/BuildFoundries.pl | 153 ++++++++++++++++++++-----------------
 3 files changed, 98 insertions(+), 71 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ce454eb9..0cc3bfb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2022-06-10  Deri James  <deri@chuzzlewit.myzen.co.uk>
+
+       [gropdf]: Changes to BuildFoundries.
+
+       * font/devpdf/util/BuildFoundries.pl: Collect search paths into
+       an array rather than a colon delimited string, this allows
+       the @PATH_SEPARATOR@ character (':' or ';') to be used to
+       delimit paths yielded by the command 'gs -h' but still use ':'
+       to delimit paths in the Foundry file. This means the same
+       Foundry file can be used on all systems.
+
+       * font/devpdf/Foundry.in: Add more likely paths to find the URW
+       fonts.
+
 2022-06-09  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [build]: Weaken dependency on TeX, instead using it (to generate
diff --git a/font/devpdf/Foundry.in b/font/devpdf/Foundry.in
index beab4221..4aa52303 100644
--- a/font/devpdf/Foundry.in
+++ b/font/devpdf/Foundry.in
@@ -72,7 +72,7 @@ EURO|N||||*../devps/freeeuro.pfa
 # URW fonts are typically shipped with Ghostscript, but can be replaced.
 
 #Foundry|Name|Search path
-foundry|U|(gs):@urwfontsdir@:/usr/share/fonts/type1/gsfonts:/opt/local/share/fonts/urw-fonts
+foundry|U|@urwfontsdir@:/usr/share/fonts/type1/gsfonts:/usr/share/fonts/default/Type1:/usr/share/fonts/default/Type1/adobestd35:/usr/share/fonts/type1/urw-base35:/opt/local/share/fonts/urw-fonts:(gs)
 
 # Define flags for afmtodit.
 
diff --git a/font/devpdf/util/BuildFoundries.pl 
b/font/devpdf/util/BuildFoundries.pl
index 33ec7add..9bf6fb0e 100644
--- a/font/devpdf/util/BuildFoundries.pl
+++ b/font/devpdf/util/BuildFoundries.pl
@@ -33,7 +33,8 @@ GetOptions("check" => \$check, "dirURW=s" => \$dirURW);
 
 (my $progname = $0) =~s @.*/@@;
 my $where=shift||'';
-my $devps=shift||'../devps';
+my @d=(split(':',shift||'../devps'));
+my $devps=\@d;
 chdir $where if $where ne '';
 my (%flg,@downloadpreamble,%download);
 my $GSpath=FindGSpath();
@@ -59,7 +60,7 @@ exit 0;
 sub LoadFoundry
 {
     my $fn=shift;
-    my $foundrypath='';
+    my $foundrypath;
     $notFoundFont=0;
 
     open(F,"<$fn") or Die("file '$fn' not found or not readable");
@@ -85,12 +86,18 @@ sub LoadFoundry
 
        if (lc($r[0]) eq 'foundry')
        {
-           Warn("\nThe path(s) used for searching:\n$foundrypath\n") if 
$notFoundFont;
+           Warn("\nThe path(s) used for 
searching:\n".join(':',$foundrypath)."\n") if $notFoundFont;
            $foundry=uc($r[1]);
-           $foundrypath='';
-           $foundrypath.="$dirURW:" if $dirURW;
-           $foundrypath.=$r[2].':'.$devps;
-           $foundrypath=~s/\(gs\)/$GSpath/;
+           $foundrypath=[];
+           push(@{$foundrypath},$dirURW) if $dirURW;
+           push(@{$foundrypath},(split(':',$r[2])),@{$devps});
+           foreach my $j (0..$#{$foundrypath})
+           {
+               if ($foundrypath->[$j]=~m'\s*\(gs\)')
+               {
+                   splice(@{$foundrypath},$j,1,@{$GSpath});
+               }
+           }
            $notFoundFont=0;
        }
        else
@@ -159,7 +166,7 @@ sub LoadFoundry
     }
 
     close(F);
-    Warn("\nThe path(s) used for searching:\n$foundrypath\n") if $notFoundFont;
+    Warn("\nThe path(s) used for searching:\n".join(':',$foundrypath)."\n") if 
$notFoundFont;
 }
 
 sub RunAfmtodit
@@ -238,68 +245,66 @@ sub LocateFile
     my $tryafm=shift;
     return(substr($files,1)) if substr($files,0,1) eq '*';
 
-    foreach my $file (split('!',$files))
+    foreach my $p (@{$path})
     {
-        if ($tryafm)
+        next if !defined($p) or $p eq ';' or $p eq ':';
+        $p=~s/^\s+//;
+        $p=~s/\s+$//;
+
+        next if $p=~m/^\%rom\%/;       # exclude %rom% paths (from (gs))
+
+        foreach my $file (reverse(split('!',$files)))
         {
-            if (!($file=~s/\..+$/.afm/))
+            if ($tryafm)
             {
-                # no extenaion
-                $file.='.afm';
+                if (!($file=~s/\..+$/.afm/))
+                {
+                    # no extenaion
+                    $file.='.afm';
+                }
             }
-        }
-
-    if ($file=~m'/')
-    {
-       # path given with file name so no need to search the paths
-
-       if (-r $file)
-       {
-           return($file);
-       }
-
-       if ($tryafm and $file=~s'type1/'afm/'i)
-       {
-           if (-r "$file")
-           {
-               return($file);
-           }
-       }
-
-       return('');
-    }
-
-       if ($path eq '(tex)')
-    {
-       my $res=`kpsewhich $file`;
-       return '' if $?;
-       chomp($res);
-       return($res);
-    }
-
-       my (@paths)=split(/$pathsep/,$path);
 
-    foreach my $p (@paths)
-    {
-           next if !defined($p) or $p eq ';' or $p eq ':';
-       $p=~s/^\s+//;
-       $p=~s/\s+$//;
+            if ($file=~m'/')
+            {
+                # path given with file name so no need to search the paths
+
+                if (-r $file)
+                {
+                    return($file);
+                }
+
+                if ($tryafm and $file=~s'type1/'afm/'i)
+                {
+                    if (-r "$file")
+                    {
+                        return($file);
+                    }
+                }
+
+                return('');
+            }
 
-       next if $p=~m/^\%rom\%/;        # exclude %rom% paths (from (gs))
+            if ($path eq '(tex)')
+            {
+                my $res=`kpsewhich $file`;
+                return '' if $?;
+                chomp($res);
+                return($res);
+            }
 
-       if (-r "$p/$file")
-       {
-           return("$p/$file");
-       }
+            if (-r "$p/$file")
+            {
+                return("$p/$file");
+            }
 
-       if ($tryafm and $p=~s'type1/'afm/'i)
-       {
-           if (-r "$p/$file")
-           {
-               return("$p/$file");
-           }
-       }
-    }
+            if ($tryafm and $p=~s'type1/'afm/'i)
+            {
+                if (-r "$p/$file")
+                {
+                    return("$p/$file");
+                }
+            }
+        }
     }
 
     return('');
@@ -309,7 +314,7 @@ sub FindGSpath
 {
     my (@res)=`@GROFF_GHOSTSCRIPT_INTERPRETERS@ -h 2>/dev/null`;
     return '' if $?;
-    my $buildpath='';
+    my $buildpath=[];
     my $stg=1;
 
     foreach my $l (@res)
@@ -329,7 +334,8 @@ sub FindGSpath
            else
            {
                $l=~s/^\s+//;
-               $buildpath.=$l;
+                $pathsep=';' if substr($l,-1) eq ';';
+                push(@{$buildpath},(split("$pathsep",$l)));
            }
        }
     }
@@ -471,7 +477,7 @@ sub Msg {
 sub CheckFoundry
 {
     my $fn=shift;
-    my $foundrypath='';
+    my $foundrypath=[];
     $notFoundFont=0;
 
     open(F,"<$fn") or Die("file '$fn' not found or not readable");
@@ -495,10 +501,17 @@ sub CheckFoundry
        if (lc($r[0]) eq 'foundry')
        {
            $foundry=uc($r[1]);
-           $foundrypath='';
-           $foundrypath.="$dirURW:" if $dirURW;
-           $foundrypath.=$r[2].':'.$devps;
-           $foundrypath=~s/\(gs\)/$GSpath/;
+           $foundrypath=[];
+           push(@{$foundrypath},$dirURW) if $dirURW;
+           push(@{$foundrypath},(split(':',$r[2])),$devps);
+           foreach my $j (0..$#{$foundrypath})
+           {
+               if ($foundrypath->[$j]=~m'\s*\(gs\)')
+               {
+                   splice(@{$foundrypath},$j,1,@{$GSpath});
+               }
+           }
+           $notFoundFont=0;
        }
        else
        {
@@ -516,7 +529,7 @@ sub CheckFoundry
                # Don't run afmtodit, just copy the grops font file
 
                my $gotf=1;
-               my $gropsfnt=LocateFile($devps,$r[0],0);
+               my $gropsfnt=LocateFile([$devps],$r[0],0);
 
                if ($gropsfnt ne '' and -r "$gropsfnt")
                {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]