pcl2fax: setting of 'PCLFONTSOURCE'

Bram <[email protected]> Wed, 11 Sep 2013 14:06:42 +0200
Newsgroups gmane.comp.telephony.fax.hylafax.devel
Message-ID <[email protected]>
Hi,

[I'm cross-posting this to both '[email protected]' and  
'[email protected]' since I'm unsure how they  
related to each other - apologies if this is not appropriate]


There exists a problem with the setting of the 'PCLFONTSOURCE'  
variable in the 'pcl2fax' script.
This script sets 'PCLFONTSOURCE' to the value of 'FONTPATH' as set in  
the 'setup.cache' file.

Code from 'pcl2fax':
	if [ ! "$PCLFONTSOURCE" -a -n "$FONTPATH" ] ; then
	    PCLFONTSOURCE=$FONTPATH
	fi
	if [ -n "$PCLFONTSOURCE" ] ; then
	    export PCLFONTSOURCE
	fi

It then runs the '$PCL6CMD'.

The problem however is that FONTPATH appears to be separated by ':'  
while pcl6 *seems to* expect the 'PCLFONTSOURCE' to be separated by  
';' [note: this is determined by looking at the source of pcl6].
This causes an error when multiple paths are set in FONTPATH: it fails  
to find fonts.

The easiest way to see this is by using strace:

Separated by using ':'
	$ export PCLFONTSOURCE='/tmp/aa/:/tmp/bb/:/tmp/cc/:/tmp/dd/' ;    
strace -f /usr/bin/pcl6  -sOutputFile="output" input 2>&1 | grep  
'/tmp/[abcd]'
	openat(AT_FDCWD, "/tmp/aa/:/tmp/bb/:/tmp/cc/:/tmp/dd",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No  
such file or directory)
	openat(AT_FDCWD, "/tmp/aa/:/tmp/bb/:/tmp/cc/:/tmp/dd",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No  
such file or directory)

Separated by using ';'
	export PCLFONTSOURCE='/tmp/aa/;/tmp/bb/;/tmp/cc/;/tmp/dd/' ;   strace  
-f /usr/bin/pcl6  -sOutputFile="output" input 2>&1 | grep '/tmp/[abcd]'
	openat(AT_FDCWD, "/tmp/aa",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
	openat(AT_FDCWD, "/tmp/bb",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
	openat(AT_FDCWD, "/tmp/cc",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
	openat(AT_FDCWD, "/tmp/dd",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
	openat(AT_FDCWD, "/tmp/aa",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 4
	openat(AT_FDCWD, "/tmp/bb",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 4
	openat(AT_FDCWD, "/tmp/cc",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 4
	openat(AT_FDCWD, "/tmp/dd",  
O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 4


I'm not entirely sure how many ways there exists in the 'faxsetup'  
script to set the 'FONTPATH' variable.
One method at least - and the method that appears to be used in our  
case - is the 'getGSFonts()' function:
         getGSFonts()
         {
                 $PATH_GSRIP -h 2>/dev/null | $AWK -F '[ ]' '
                         BEGIN { start = 0; }
                         /Search path:/ { start = 1 }
                         {
                                 if (start == 1) {
                                                 if ($1 == "") {
                                                 gsub(" ","")
                                                 gsub("^[.]","")
                                                 gsub("^:","")
                                                 printf "%s", $0
                                         } else if ($1 != "Search") start = 0
                                 }
                         }
                 '
         }

PATH_GSRIP is set to /usr/bin/gs.
Running the command:
	$ /usr/bin/gs -h
	GNU Ghostscript 7.07 (2003-05-17)
	...
	Search path:
	   /usr/share/ghostscript/7.07/lib : /usr/share/ghostscript/fonts :
	   /usr/share/ghostpcl/fonts


(Note: this is an older version of gs but I don't think the output changed)


Looking at the source of ghostpcl/ghostpdl shows that it at one point  
did use ':' to separate paths.

http://git.ghostscript.com/?p=ghostpdl.git;a=commit;f=pl/pjparse.c;h=64a01c3a07371098ac4eecab0df66081f638b0a4
	author	Henry Stiles <[email protected]>
		Sun, 3 Sep 2000 20:42:24 +0200 (18:42 +0000)
	committer	Henry Stiles <[email protected]>
		Sun, 3 Sep 2000 20:42:24 +0200 (18:42 +0000)
	commit	64a01c3a07371098ac4eecab0df66081f638b0a4

	Change to use `;' instead of ':' as a separator for the font path.

	git-svn-id: http://svn.ghostscript.com/ghostpcl/trunk/ghostpcl@1189  
06663e23-700e-0410-b217-a244a6096597


Best regards,

Bram


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


____________________ HylaFAX(tm) Developers Mailing List ____________________
  To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
On UNIX: mail -s unsubscribe [email protected] < /dev/null