From d6821bf1949982f9fd42652024a4adbbcf2ad137 Mon Sep 17 00:00:00 2001 From: DRC Date: Thu, 26 Mar 2009 18:17:49 +0000 Subject: [PATCH] Attempt to build a reasonable font path for the system and start Xvnc with this font path. Failing that, attempt to use the X Font Server (xfs.) Note that XFS is not generally available on SuSE and Ubuntu, so it cannot be used as the default font path. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3725 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- unix/vncserver | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/unix/vncserver b/unix/vncserver index a861f586..32857160 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -81,6 +81,34 @@ $defaultXStartup chop($host = `uname -n`); +@fontpaths = ('/usr/share/X11/fonts', '/usr/share/fonts', '/usr/share/fonts/X11/'); +if (! -l "/usr/lib/X11") {push(@fontpaths, '/usr/lib/X11/fonts');} +if (! -l "/usr/X11") {push(@fontpaths, '/usr/X11/lib/X11/fonts');} +if (! -l "/usr/X11R6") {push(@fontpaths, '/usr/X11R6/lib/X11/fonts');} +push(@fontpaths, '/usr/share/fonts/default'); + +@fonttypes = ('misc', + '75dpi', + '100dpi', + 'Speedo', + 'Type1'); + +foreach $_fpath (@fontpaths) { + foreach $_ftype (@fonttypes) { + if (-f "$_fpath/$_ftype/fonts.dir") { + if (! -l "$_fpath/$_ftype") { + $fontPath .= "$_fpath/$_ftype,"; + } + } + } +} +if ($fontPath) { + if (substr($fontPath, -1, 1) == ',') { + chop $fontPath; + } +} + +$defFontPath = "unix/:7100"; # Check command line options @@ -178,11 +206,11 @@ $cmd .= " -pixelformat $pixelformat" if ($pixelformat); $cmd .= " -rfbwait 30000"; $cmd .= " -rfbauth $vncUserDir/passwd"; $cmd .= " -rfbport $vncPort"; +$cmd .= " -fp $fontPath" if ($fontPath); $cmd .= " -pn"; -# Add font path and color database stuff here, e.g.: +# Add color database stuff here, e.g.: # -# $cmd .= " -fp /usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/"; # $cmd .= " -co /usr/lib/X11/rgb"; # @@ -199,6 +227,22 @@ system("$cmd & echo \$! >$pidFile"); # Give Xvnc a chance to start up sleep(3); +unless (kill 0, `cat $pidFile`) { + warn "\nWARNING: The first attempt to start Xvnc failed, possibly because the vncserver\n"; + warn "script was not able to figure out an appropriate X11 font path for this system.\n"; + warn "Attempting to restart Xvnc using the X Font Server (xfs) ...\n"; + $cmd =~ s@-fp [^ ]+@@; + $cmd .= " -fp $defFontPath" if ($defFontPath); + system("$cmd & echo \$! >$pidFile"); + sleep(3); +} +unless (kill 0, `cat $pidFile`) { + warn "Could not start Xvnc.\n\n"; + open(LOG, "<$desktopLog"); + while () { print; } + close(LOG); + die "\n"; +} warn "\nNew '$desktopName' desktop is $host:$displayNumber\n\n"; -- 2.39.5