]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
[Bug 233] problems with Ghostscript Fontmap.GS file
authorDarren Nickerson <darren.nickerson@ifax.com>
Fri, 15 Feb 2002 04:52:20 +0000 (04:52 +0000)
committerDarren Nickerson <darren.nickerson@ifax.com>
Fri, 15 Feb 2002 04:52:20 +0000 (04:52 +0000)
Added runtime Fontpath/Fontmap detection, and check for ghostscript's
newer Fontmap.GS convention, with Fontmap as a fallback. Thanks Lee & Giulio!

etc/faxsetup.sh.in
util/TextFmt.c++

index 85e1817fcce7f7b9262691741a20a2d6c1c7075a..ae0006e70b1dc6f7311bb70bcc8feaa157f6f349 100644 (file)
@@ -1094,6 +1094,46 @@ EOF
     }
 fi
 
+#
+# Runtime Fontpath/Fontmap detection
+#
+if onClient; then
+       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
+                               }
+                       }       
+               '
+       }
+       RUNTIME_PATH_AFM=`getGSFonts`
+       if [ -n "$RUNTIME_PATH_AFM" \
+                               -a "$RUNTIME_PATH_AFM" != "$PATH_AFM" ]; then 
+           Note ""
+           Note "Setting Ghostscript font path in $DIR_LIBDATA/hyla.conf."
+           Note ""
+           if [ -f $DIR_LIBDATA/hyla.conf ]; then
+               $AWK '!/^FontMap|^FontPath|\/FontPath added by/ { print }' \
+                       $DIR_LIBDATA/hyla.conf > $DIR_LIBDATA/hyla.conf.tmp
+           fi
+           echo "# FontMap/FontPath added by faxsetup (`date 2>/dev/null`)" \
+                                               >> $DIR_LIBDATA/hyla.conf.tmp
+           echo "FontMap:   $RUNTIME_PATH_AFM" >> $DIR_LIBDATA/hyla.conf.tmp
+           echo "FontPath:  $RUNTIME_PATH_AFM" >> $DIR_LIBDATA/hyla.conf.tmp
+           $MV $DIR_LIBDATA/hyla.conf.tmp $DIR_LIBDATA/hyla.conf
+           PATH_AFM=$RUNTIME_PATH_AFM
+       fi
+fi
+
 #
 # Installation of Adobe Font Metric files
 #
index 36faf65a80f2b63eaf337b59807ec785025aab04..97729440695d1945ba4d0865336f9faad38a569d 100644 (file)
@@ -1145,7 +1145,17 @@ TextFont::decodeFontName(const char* name, fxStr& filename, fxStr& emsg)
     fxStr path = fontMap;
     u_int index = path.next(0, ':');
     while (index > 0) {
-        fxStr fontMapFile = path.head(index) | "/" | "Fontmap";
+
+        /* Newer versions of Ghostscript use "Fontmap.GS"
+         * whereas older ones omit the ".GS" extension.
+         * If the Fontmap.GS file isn't available default
+         * to the older convention.
+         */
+        filename = path.head(index) | "/" | "Fontmap.GS";
+        if (stat(filename, &junk) != 0)
+            filename = path.head(index) | "/" | "Fontmap";
+        fxStr fontMapFile = filename;
+
         path.remove(0, index);
         if (path.length() > 0) path.remove(0, 1);
         FILE* fd = Sys::fopen(fontMapFile, "r");