delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/12/07/12:44:34

X-Spam-Check-By: sourceware.org
From: "John W. Eaton" <jwe AT bevo DOT che DOT wisc DOT edu>
MIME-Version: 1.0
Message-ID: <17303.8050.954774.161737@frodo.bogus.domain>
Date: Wed, 7 Dec 2005 12:44:18 -0500
To: cygwin AT cygwin DOT com
cc: "James R. Phillips" <antiskid56-cygwin AT yahoo DOT com>
Subject: Re: octave-forge dependency?
In-Reply-To: <439703E8.10701@equate.dyndns.org>
References: <20051207153014 DOT 36506 DOT qmail AT web51505 DOT mail DOT yahoo DOT com> <439703E8 DOT 10701 AT equate DOT dyndns DOT org>
X-CAE-MailScanner-Information: Please contact security AT engr DOT wisc DOT edu if this message contains a virus or has been corrupted in delivery.
X-CAE-MailScanner: Found to be clean (benji)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

OK, let's back up a bit, and see why kpsexpand is needed in the first
place.

Graphics in Octave use gnuplot.  The legend function from Octave Forge
sends a "save FILE" command to gnuplot so that it can extract some
information about gnuplot's current state.  If you do the following

  mv /usr/bin/kpsexpand. /usr/bin/kpsexpand-save
  gnuplot
  ...
  gnuplot> save "foo"

you should see the errors

  sh: kpsexpand: command not found

So, why does gnuplot need kpsexpand to save state?  Looking at the
gnuplot sources, one finds

  /* Yet, no special font paths for these operating systems:
   * MSDOS, ATARI, AMIGA, MTOS, NeXT, ultrix, VMS, _IBMR2, alliant
   *
   * Environmental variables are written as $(name).
   * Commands are written as $`command`.
   */

  [...]

  #if defined(_Windows) && !defined(FONTPATHSET)
  #  define FONTPATHSET
  static const struct path_table fontpath_tbl[] =
  {
      { "$(windir)\\fonts" },
      /* Ghostscript */
      { "c:\\gs\\fonts" },
      /* X11 */
      { "$(CYGWIN_ROOT)\\usr\\X11R6\\lib\\X11\\fonts\\Type1" },
      /* fpTeX */
      { "$`kpsewhich -expand-path=$HOMETEXMF`\\fonts\\type1!" },
      { "$`kpsewhich -expand-path=$TEXMFLOCAL`\\fonts\\type1!" },
      { "$`kpsewhich -expand-path=$TEXMFMAIN`\\fonts\\type1!" },
      { "$`kpsewhich -expand-path=$TEXMFDIST`\\fonts\\type1!" },
      { NULL }
  };
  #endif

  [...]

  /* Fallback: Should work for unix */
  #ifndef FONTPATHSET
  static const struct path_table fontpath_tbl[] =
  {
      /* teTeX or TeXLive */
      { "$`kpsexpand '$HOMETEXMF'`/fonts/type1!" },
      { "$`kpsexpand '$TEXMFLOCAL'`/fonts/type1!" },
      { "$`kpsexpand '$TEXMFMAIN'`/fonts/type1!" },
      { "$`kpsexpand '$TEXMFDIST'`/fonts/type1!" },
      /* Linux paths */
      { "/usr/X11R6/lib/X11/fonts/Type1" },
      { "/usr/X11R6/lib/X11/fonts/truetype" },
      /* HP-UX */
      { "/usr/lib/X11/fonts!"},
      /* Ghostscript */
      { "/usr/share/ghostscript/fonts" },
      { "/usr/local/share/ghostscript/fonts" },
      { NULL }
  };
  #endif

  [...]

    switch (action) {
    case ACTION_CLEAR:
	/* Clear fontpath, fall through to init */
	FPRINTF((stderr, "Clear fontpath\n"));
	free(fontpath);
	fontpath = p = last = NULL;
	/* HBB 20000726: 'limit' has to be initialized to NULL, too! */
	limit = NULL;
    case ACTION_INIT:
	/* Init fontpath from environment */
	FPRINTF((stderr, "Init fontpath from environment\n"));
	assert(fontpath == NULL);
	if (!fontpath)
	{
	    char *envlib = getenv("GNUPLOT_FONTPATH");
	    if (envlib) {
		/* get paths from environment */
		int len = strlen(envlib);
		fontpath = gp_strdup(envlib);
		/* point to end of fontpath */
		last = fontpath + len;
		/* convert all PATHSEPs to \0 */
		PATHSEP_TO_NUL(fontpath);
	    }
#if defined(HAVE_DIRENT_H) || defined(_Windows)
	    else {
		/* set hardcoded paths */
		const struct path_table *curr_fontpath = fontpath_tbl;

  [...]

in src/variable.c.  The above is taken from a recent CVS checkout, but
the 4.0.0 sources for the current Cygwin package have similar lines.

So gnuplot is using kpsexpand to locate some font files.

It looks like there are a couple of options.

One is to set GNUPLOT_FONTPATH in the environment before calling
gnuplot.

Another is to make a wrapper kpsexpand that looks for the real version
and does nothing if the real version is not present:

  #! /bin/sh
  if [ -x /usr/bin/kpsexpand ]; then
    exec /usr/bin/kspexpand "$@"
  fi

(though you might want to add some comments about why this is needed).

If the real kpsexpand is not present, then chances are the font files
are not -either, so it should not matter that the corresponding
directories named in the fontpath are bogus.  You could install the
wrapper script in one of the directories in Octave's DEFAULT_EXEC_PATH
(for example, /usr/lib/octave/2.1.72/exec/i686-pc-cygwin, where a
couple of other scripts are already installed), then it would only be
found by Octave and should not introduce any other conflicts.

jwe

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019