John, Michael - Now that we are talking about a new release, did you guys ever manage to fix the bug described below. It had to do with greek symbols not showing up in postscript files on windows. John seemed to have tracked down the source of the problem, but I never heard of a solution. Thanks, Mark On Tue, Mar 25, 2008 at 7:50 PM, John Hunter <jd...@gm...> wrote: > On Tue, Mar 25, 2008 at 12:02 PM, Michael Droettboom <md...@st...> > wrote: > > > The *intention* is that the fonts *should* be included (with the > > exception of ps.useafm == True). That was definitely not a deliberate > > change. > > > > However, as one of the ones who hasn't been able to reproduce this > > problem, I'm afraid I'm not of much help. From reading the code, I'm > > still completely stumped as to why the font is not embedded. Someone > > will have to step through with a debugger on one of the broken systems > > to figure this out, I'm afraid. > > I was able to replicate the bug and find the source of the problem. I > am not 100% sure how to fix it, but someone who knows os.stat better > might. The problem is that matplotlib.cbook.get_realpath_and_stat > > class GetRealpathAndStat: > def __init__(self): > self._cache = {} > > def __call__(self, path): > result = self._cache.get(path) > if result is None: > realpath = os.path.realpath(path) > stat = os.stat(realpath) > stat_key = (stat.st_ino, stat.st_dev) > result = realpath, stat_key > self._cache[path] = result > return result > get_realpath_and_stat = GetRealpathAndStat() > > > is returning the same stat ino and dev for all the font files, and > thus the renderer.used_characters dictionary is getting improper keys > -- always (0,0). So the first font in the gate, in this case Vera, is > getting a place in the dict and subsequent fonts (the cm* ones) are > not. The basic problem is that the inode and dev appear to be unix > only. > > Michael: if you let me know better what this key is supposed to be > doing (can we not simply use the filename for windows?) then I can > attempt or test some fixes. > > JDH >
Hi, John Hunter wrote: > I've done a fair amount of testing on the branch (0.91.3), > particularly looking at all the PDF and SVG output from backend > driver, and these backends are in the best shape I've ever seen them. > [...] > I think we should take a crack at fixing these since the branch is > otherwise in such good shape that we could perhaps go a long time w/o > another maintenance release. Before the branches and releases are all frozen for the foreseeable future, I might mention a minor but long-lived bug that has been around since at least the end of 2006... Please excuse me if this is old news, as I haven't checked the archives recently for any progress on this. I've noticed that the bug is still around in r5314 of trunk. On Mac OS X (both Tiger and Leopard), there is a small misalignment between grid lines and tick marks on the standard plot (as well as loglog and semilog) with the PS backend. I did not check which one of the lines is in the correct place. The problem does not occur with the PDF backend. I attach a ps and pdf file produced by the following snippet: import pylab as pl pl.plot([1,2,3,4,5]) pl.grid() pl.savefig('grid_misaligned_with_ticks.ps') pl.savefig('grid_misaligned_with_ticks.pdf') The pdf file is fine, but the ps file shows a misalignment. To view this in Mac OS X, I used Preview (which converts the PS to PDF first). To eliminate Preview as the problem, I also saved the file as an EPS and used epstopdf from MacTeX to convert it for Preview. Viewed on Linux with acroread, the PS file produced on the Mac also shows misalignment (I haven't verified this recently). The same code snippet produces no problems on Linux. I realise this might not be a problem with matplotlib itself, but I'm just curious if anyone picked it up and whether it is fixable before the next release. Thanks! Ludwig
I suspect on Windows it is safe enough (in most cases) to use the realpath as the key, in lieu of anything better. But that would require testing on Windows to make sure. Can you try replacing the GetRealpathAndStat in mplutil.py with the following? class GetRealpathAndStat: def __init__(self): self._cache = {} def __call__(self, path): result = self._cache.get(path) if result is None: realpath = os.path.realpath(path) if sys.platform == "win32": stat_key = realpath else: stat = os.stat(realpath) stat_key = (stat.st_ino, stat.st_dev) result = realpath, stat_key self._cache[path] = result return result get_realpath_and_stat = GetRealpathAndStat() Cheers, Mike Mark Bakker wrote: > John, Michael - > > Now that we are talking about a new release, did you guys ever manage > to fix the bug described below. It had to do with greek symbols not > showing up in postscript files on windows. John seemed to have tracked > down the source of the problem, but I never heard of a solution. > > Thanks, > > Mark > > On Tue, Mar 25, 2008 at 7:50 PM, John Hunter <jd...@gm... > <mailto:jd...@gm...>> wrote: > > On Tue, Mar 25, 2008 at 12:02 PM, Michael Droettboom > <md...@st... <mailto:md...@st...>> wrote: > > > The *intention* is that the fonts *should* be included (with the > > exception of ps.useafm == True). That was definitely not a > deliberate > > change. > > > > However, as one of the ones who hasn't been able to reproduce this > > problem, I'm afraid I'm not of much help. From reading the > code, I'm > > still completely stumped as to why the font is not embedded. > Someone > > will have to step through with a debugger on one of the broken > systems > > to figure this out, I'm afraid. > > I was able to replicate the bug and find the source of the problem. I > am not 100% sure how to fix it, but someone who knows os.stat better > might. The problem is that matplotlib.cbook.get_realpath_and_stat > > class GetRealpathAndStat: > def __init__(self): > self._cache = {} > > def __call__(self, path): > result = self._cache.get(path) > if result is None: > realpath = os.path.realpath(path) > stat = os.stat(realpath) > stat_key = (stat.st_ino, stat.st_dev) > result = realpath, stat_key > self._cache[path] = result > return result > get_realpath_and_stat = GetRealpathAndStat() > > > is returning the same stat ino and dev for all the font files, and > thus the renderer.used_characters dictionary is getting improper keys > -- always (0,0). So the first font in the gate, in this case Vera, is > getting a place in the dict and subsequent fonts (the cm* ones) are > not. The basic problem is that the inode and dev appear to be unix > only. > > Michael: if you let me know better what this key is supposed to be > doing (can we not simply use the filename for windows?) then I can > attempt or test some fixes. > > JDH > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA
That fixes it on my machine. Except that the function GetRealpathAndStat is in cbook.py (I don't even have a mplutil.py file). Thanks, Mark On Tue, May 13, 2008 at 7:21 PM, Michael Droettboom <md...@st...> wrote: > I suspect on Windows it is safe enough (in most cases) to use the realpath > as the key, in lieu of anything better. But that would require testing on > Windows to make sure. Can you try replacing the GetRealpathAndStat in > mplutil.py with the following? > > class GetRealpathAndStat: > def __init__(self): > self._cache = {} > > def __call__(self, path): > result = self._cache.get(path) > if result is None: > realpath = os.path.realpath(path) > if sys.platform == "win32": > stat_key = realpath > else: > stat = os.stat(realpath) > stat_key = (stat.st_ino, stat.st_dev) > result = realpath, stat_key > self._cache[path] = result > return result > get_realpath_and_stat = GetRealpathAndStat() > > > Cheers, > Mike > > Mark Bakker wrote: > > > John, Michael - > > > > Now that we are talking about a new release, did you guys ever manage to > > fix the bug described below. It had to do with greek symbols not showing up > > in postscript files on windows. John seemed to have tracked down the source > > of the problem, but I never heard of a solution. > > > > Thanks, > > > > Mark > > > > On Tue, Mar 25, 2008 at 7:50 PM, John Hunter <jd...@gm... <mailto: > > jd...@gm...>> wrote: > > > > On Tue, Mar 25, 2008 at 12:02 PM, Michael Droettboom > > <md...@st... <mailto:md...@st...>> wrote: > > > > > The *intention* is that the fonts *should* be included (with the > > > exception of ps.useafm == True). That was definitely not a > > deliberate > > > change. > > > > > > However, as one of the ones who hasn't been able to reproduce this > > > problem, I'm afraid I'm not of much help. From reading the > > code, I'm > > > still completely stumped as to why the font is not embedded. > > Someone > > > will have to step through with a debugger on one of the broken > > systems > > > to figure this out, I'm afraid. > > > > I was able to replicate the bug and find the source of the problem. > > I > > am not 100% sure how to fix it, but someone who knows os.stat better > > might. The problem is that matplotlib.cbook.get_realpath_and_stat > > > > class GetRealpathAndStat: > > def __init__(self): > > self._cache = {} > > > > def __call__(self, path): > > result = self._cache.get(path) > > if result is None: > > realpath = os.path.realpath(path) > > stat = os.stat(realpath) > > stat_key = (stat.st_ino, stat.st_dev) > > result = realpath, stat_key > > self._cache[path] = result > > return result > > get_realpath_and_stat = GetRealpathAndStat() > > > > > > is returning the same stat ino and dev for all the font files, and > > thus the renderer.used_characters dictionary is getting improper keys > > -- always (0,0). So the first font in the gate, in this case Vera, > > is > > getting a place in the dict and subsequent fonts (the cm* ones) are > > not. The basic problem is that the inode and dev appear to be unix > > only. > > > > Michael: if you let me know better what this key is supposed to be > > doing (can we not simply use the filename for windows?) then I can > > attempt or test some fixes. > > > > JDH > > > > > > > -- > Michael Droettboom > Science Software Branch > Operations and Engineering Division > Space Telescope Science Institute > Operated by AURA for NASA > >
You're right. Just a typo on my part. I'll commit these changes to SVN so they'll make it into the next release. Cheers, Mike Mark Bakker wrote: > That fixes it on my machine. > Except that the function GetRealpathAndStat is in cbook.py (I don't > even have a mplutil.py file). > Thanks, > Mark > > On Tue, May 13, 2008 at 7:21 PM, Michael Droettboom <md...@st... > <mailto:md...@st...>> wrote: > > I suspect on Windows it is safe enough (in most cases) to use the > realpath as the key, in lieu of anything better. But that would > require testing on Windows to make sure. Can you try replacing > the GetRealpathAndStat in mplutil.py with the following? > > > class GetRealpathAndStat: > def __init__(self): > self._cache = {} > > def __call__(self, path): > result = self._cache.get(path) > if result is None: > realpath = os.path.realpath(path) > if sys.platform == "win32": > stat_key = realpath > else: > > stat = os.stat(realpath) > stat_key = (stat.st_ino, stat.st_dev) > result = realpath, stat_key > self._cache[path] = result > return result > get_realpath_and_stat = GetRealpathAndStat() > > > Cheers, > Mike > > Mark Bakker wrote: > > John, Michael - > > Now that we are talking about a new release, did you guys ever > manage to fix the bug described below. It had to do with greek > symbols not showing up in postscript files on windows. John > seemed to have tracked down the source of the problem, but I > never heard of a solution. > > Thanks, > > Mark > > On Tue, Mar 25, 2008 at 7:50 PM, John Hunter > <jd...@gm... <mailto:jd...@gm...> > <mailto:jd...@gm... <mailto:jd...@gm...>>> wrote: > > On Tue, Mar 25, 2008 at 12:02 PM, Michael Droettboom > <md...@st... <mailto:md...@st...> > <mailto:md...@st... <mailto:md...@st...>>> wrote: > > > The *intention* is that the fonts *should* be included > (with the > > exception of ps.useafm == True). That was definitely not a > deliberate > > change. > > > > However, as one of the ones who hasn't been able to > reproduce this > > problem, I'm afraid I'm not of much help. From reading the > code, I'm > > still completely stumped as to why the font is not embedded. > Someone > > will have to step through with a debugger on one of the > broken > systems > > to figure this out, I'm afraid. > > I was able to replicate the bug and find the source of the > problem. I > am not 100% sure how to fix it, but someone who knows > os.stat better > might. The problem is that > matplotlib.cbook.get_realpath_and_stat > > class GetRealpathAndStat: > def __init__(self): > self._cache = {} > > def __call__(self, path): > result = self._cache.get(path) > if result is None: > realpath = os.path.realpath(path) > stat = os.stat(realpath) > stat_key = (stat.st_ino, stat.st_dev) > result = realpath, stat_key > self._cache[path] = result > return result > get_realpath_and_stat = GetRealpathAndStat() > > > is returning the same stat ino and dev for all the font > files, and > thus the renderer.used_characters dictionary is getting > improper keys > -- always (0,0). So the first font in the gate, in this > case Vera, is > getting a place in the dict and subsequent fonts (the cm* > ones) are > not. The basic problem is that the inode and dev appear to > be unix > only. > > Michael: if you let me know better what this key is > supposed to be > doing (can we not simply use the filename for windows?) > then I can > attempt or test some fixes. > > JDH > > > > -- > Michael Droettboom > Science Software Branch > Operations and Engineering Division > Space Telescope Science Institute > Operated by AURA for NASA > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA