$OpenBSD: patch-vncserver,v 1.1.1.1 2001/09/08 00:38:11 lebel Exp $
--- vncserver.orig	Mon Jun 25 03:52:14 2001
+++ vncserver	Wed Sep  5 08:47:31 2001
@@ -48,13 +48,23 @@ $defaultXStartup
        "xterm -geometry 80x24+10+10 -ls -title \"\$VNCDESKTOP Desktop\" &\n".
        "twm &\n");
 
+$defaultFontPath
+    = (
+       "/usr/X11R6/lib/X11/fonts/Type1/,".
+       "/usr/X11R6/lib/X11/fonts/Speedo/,".
+       "/usr/X11R6/lib/X11/fonts/cyrillic/,".
+       "/usr/X11R6/lib/X11/fonts/misc/,".
+       "/usr/X11R6/lib/X11/fonts/75dpi/,".
+       "/usr/X11R6/lib/X11/fonts/100dpi/"
+       );
+
 chop($host = `uname -n`);
 
 
 # Check command line options
 
 &ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1,
-	      "-help",0,"-h",0,"--help",0);
+	      "-help",0,"-h",0,"--help",0,"-fp",1);
 
 &Usage() if ($opt{'-help'} || $opt{'-h'} || $opt{'--help'});
 
@@ -77,6 +87,25 @@ if ($opt{'-pixelformat'}) {
 
 &CheckGeometryAndDepth();
 
+# bmah: Construct font path.  Starting from a list of possible font directories
+# bmah: make up the set of those that have fonts.dir files we can read.
+# bmah: Probably there are way better methods of doing this.
+
+if (!$opt{'-fp'}) {
+    $opt{'-fp'} = $defaultFontPath;
+}
+
+@fontPathElements = split(/,/, "$opt{'-fp'}");
+
+$fontPath = '';
+
+foreach $i (0.."$#fontPathElements") {
+    if (-r "$fontPathElements[$i]/fonts.dir") {
+      $fontPath .= "$fontPathElements[$i],";
+    }
+}
+chop $fontPath;
+
 if ($opt{'-name'}) {
     $desktopName = $opt{'-name'};
 }
@@ -152,6 +181,8 @@ $cmd .= " -rfbport $vncPort";
 # $cmd .= " -fp /usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/";
 # $cmd .= " -co /usr/lib/X11/rgb";
 #
+# bmah: Bring in the fontpath we computed earlier.
+$cmd .= " -fp $fontPath";
 
 foreach $arg (@ARGV) {
     $cmd .= " " . &quotedString($arg);
@@ -193,6 +224,7 @@ if (-e "/tmp/.X11-unix/X$displayNumber")
     $ENV{DISPLAY}= "$host:$displayNumber";
 }
 $ENV{VNCDESKTOP}= $desktopName;
+$ENV{XAUTHORITY}= $xauthorityFile;
 
 system("$vncUserDir/xstartup >> " . &quotedString($desktopLog) . " 2>&1 &");
 
