AFMPATH environmental variable

H:\00work\00cvs\matplotlib\matplotlib\examples>python subplot_demo.py -dPS
  ['E:\\Py23\\share\\matplotlib', 'E', '\\Py23e\\share\\matplotlib']

Oh, I see the bug. The reason the lines are there that you commented
out is to allow you to specify multiple font dirs in your path, as in

  set AFMPATH = c:\somepath\fonts;e:\some\other\path\fonts

But I wasn't properly doing a platform independent path split.

The code should read

    def _get_afm_filenames(self):
        paths = [os.path.join(distutils.sysconfig.PREFIX, 'share', 'matplotlib')]
        if os.environ.has_key('AFMPATH'):
            afmpath = os.environ['AFMPATH']
            paths.extend(afmpath.split(os.pathsep))

        fnames = [fname for fname in get_recursive_filelist(paths)
                  if fname.lower().find('.afm')>0 and
                  os.path.exists(fname)]

        return fnames

Thanks for helping me diagnose it. Please let me know if the above
works on your system!

John Hunter

John Hunter wrote:

"LUK" == LUK ShunTim <shuntim.luk@...34...> writes:

  H:\00work\00cvs\matplotlib\matplotlib\examples>python subplot_demo.py -dPS
  ['E:\\Py23\\share\\matplotlib', 'E', '\\Py23e\\share\\matplotlib']

Oh, I see the bug. The reason the lines are there that you commented
out is to allow you to specify multiple font dirs in your path, as in

Yes, the previous version caught the ":" in the drive letter specification.

  set AFMPATH = c:\somepath\fonts;e:\some\other\path\fonts

But I wasn't properly doing a platform independent path split.

The code should read

    def _get_afm_filenames(self):
        paths = [os.path.join(distutils.sysconfig.PREFIX, 'share', 'matplotlib')]
        if os.environ.has_key('AFMPATH'):
            afmpath = os.environ['AFMPATH']
            paths.extend(afmpath.split(os.pathsep))

        fnames = [fname for fname in get_recursive_filelist(paths) if fname.lower().find('.afm')>0 and
                  os.path.exists(fname)]

        return fnames

Yes, it works. I had thought of testing for "if OS == win" sort of stuff instead of testing for the presence of ";" or ":". But it appears that Python has the foresight to provide os.pathsep. I learnt a bit more and love Python a bit more. :slight_smile:

Thanks for helping me diagnose it. Please let me know if the above
works on your system!

John Hunter

You deserve much thanks for developing such a nice package.

An afterthought: perhaps an EPS backend instead of/additional to a PS backend would be more convenient for inclusion into publications. I know very little about postscript programming so I don't know what's the effort involved, though.

Best regards,
ST

···

--