You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
1
(12) |
2
(3) |
3
(3) |
4
(3) |
5
(6) |
6
(3) |
7
|
8
(2) |
9
|
10
(1) |
11
(2) |
12
(1) |
13
(9) |
14
(5) |
15
(7) |
16
(2) |
17
|
18
|
19
(7) |
20
(1) |
21
(2) |
22
|
23
|
24
|
25
(3) |
26
|
27
|
28
|
29
(2) |
|
Revision: 4941 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4941&view=rev Author: jdh2358 Date: 2008年02月05日 13:50:58 -0800 (2008年2月05日) Log Message: ----------- applied gael's ginput patch Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py trunk/matplotlib/lib/matplotlib/backends/backend_qt.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py trunk/matplotlib/lib/matplotlib/backends/backend_wx.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/lib/matplotlib/pyplot.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008年02月05日 07:54:01 UTC (rev 4940) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008年02月05日 21:50:58 UTC (rev 4941) @@ -1151,7 +1151,13 @@ """ return self.callbacks.disconnect(cid) + def flush_events(self): + """ Flush the GUI events for the figure. Implemented only for + backends with GUIs. + """ + raise NotImplementedError + class FigureManagerBase: """ Helper class for matlab mode, wraps everything up into a neat bundle Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008年02月05日 07:54:01 UTC (rev 4940) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008年02月05日 21:50:58 UTC (rev 4941) @@ -386,6 +386,13 @@ def get_default_filetype(self): return 'png' + def flush_events(self): + gtk.gdk.threads_enter() + while gtk.events_pending(): + gtk.main_iteration(True) + gtk.gdk.flush() + gtk.gdk.threads_leave() + class FigureManagerGTK(FigureManagerBase): """ Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008年02月05日 07:54:01 UTC (rev 4940) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008年02月05日 21:50:58 UTC (rev 4941) @@ -175,6 +175,9 @@ return key + def flush_events(self): + qt.qApp.processEvents() + class FigureManagerQT( FigureManagerBase ): """ Public attributes Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008年02月05日 07:54:01 UTC (rev 4940) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008年02月05日 21:50:58 UTC (rev 4941) @@ -13,7 +13,7 @@ from matplotlib.mathtext import MathTextParser from matplotlib.widgets import SubplotTool -from PyQt4 import QtCore, QtGui +from PyQt4 import QtCore, QtGui, Qt backend_version = "0.9.1" def fn_name(): return sys._getframe(1).f_code.co_name @@ -174,6 +174,9 @@ return key + def flush_events(self): + Qt.qApp.processEvents() + class FigureManagerQT( FigureManagerBase ): """ Public attributes Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008年02月05日 07:54:01 UTC (rev 4940) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008年02月05日 21:50:58 UTC (rev 4941) @@ -269,8 +269,9 @@ key = self._get_key(event) FigureCanvasBase.key_release_event(self, key, guiEvent=event) + def flush_events(self): + self._master.update() - class FigureManagerTkAgg(FigureManagerBase): """ Public attributes Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008年02月05日 07:54:01 UTC (rev 4940) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008年02月05日 21:50:58 UTC (rev 4941) @@ -1301,6 +1301,9 @@ wxapp.Yield() return True + def flush_events(self): + wx.Yield() + class FigureManagerWx(FigureManagerBase): """ This class contains the FigureCanvas and GUI frame Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008年02月05日 07:54:01 UTC (rev 4940) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008年02月05日 21:50:58 UTC (rev 4941) @@ -2,6 +2,7 @@ Figure class -- add docstring here! """ import numpy as npy +import time import artist from artist import Artist @@ -96,6 +97,83 @@ setattr(self, s, val) +class BlockingMouseInput(object): + """ Class that creates a callable object to retrieve mouse clicks in a + blocking way. + """ + def __init__(self, fig): + self.fig = fig + + + def on_click(self, event): + """ Event handler that will be passed to the current figure to + retrieve clicks. + """ + if event.button == 3: + # If it's a right click, pop the last coordinates. + if len(self.clicks) > 0: + self.clicks.pop() + if self.show_clicks: + mark = self.marks.pop() + mark.remove() + self.fig.canvas.draw() + elif event.button == 2 and self.n < 0: + # If it's a middle click, and we are in infinite mode, finish + self.done = True + elif event.inaxes: + # If it's a valid click, append the coordinates to the list + self.clicks.append((event.xdata, event.ydata)) + if self.verbose: + print "input %i: %f,%f" % (len(self.clicks), + event.xdata, event.ydata) + if self.show_clicks: + self.marks.extend( + event.inaxes.plot([event.xdata,], [event.ydata,], 'r+') ) + self.fig.canvas.draw() + if self.n > 0 and len(self.clicks) >= self.n: + self.done = True + + + def __call__(self, n=1, timeout=30, verbose=False, show_clicks=True): + """ Blocking call to retrieve n coordinate pairs through mouse + clicks. + """ + self.verbose = verbose + self.done = False + self.clicks = [] + self.show_clicks = True + self.marks = [] + + assert isinstance(n, int), "Requires an integer argument" + self.n = n + + # Ensure that the figure is shown + self.fig.show() + # connect the click events to the on_click function call + self.callback = self.fig.canvas.mpl_connect('button_press_event', + self.on_click) + # wait for n clicks + counter = 0 + while not self.done: + self.fig.canvas.flush_events() + time.sleep(0.01) + + # check for a timeout + counter += 1 + if timeout > 0 and counter > timeout/0.01: + print "ginput timeout"; + break; + + # Disconnect the event, clean the figure, and return what we have + self.fig.canvas.mpl_disconnect(self.callback) + self.callback = None + if self.show_clicks: + for mark in self.marks: + mark.remove() + self.fig.canvas.draw() + return self.clicks + + class Figure(Artist): def __str__(self): @@ -892,8 +970,24 @@ ax.update_params() ax.set_position(ax.figbox) + def ginput(self, n=1, timeout=30, verbose=False, show_clicks=True): + """ + ginput(self, n=1, timeout=30, verbose=False, show_clicks=True) + + Blocking call to interact with the figure. + This will wait for n clicks from the user and return a list of the + coordinates of each click. If timeout is negative, does not + timeout. If n is negative, accumulate clicks until a middle + click terminates the input. Right clicking cancels last input. + """ + blocking_mouse_input = BlockingMouseInput(self) + return blocking_mouse_input(n=n, timeout=timeout, + verbose=verbose, show_clicks=True) + + + def figaspect(arg): """ Create a figure with specified aspect ratio. If arg is a number, Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2008年02月05日 07:54:01 UTC (rev 4940) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008年02月05日 21:50:58 UTC (rev 4941) @@ -272,6 +272,20 @@ if Figure.savefig.__doc__ is not None: savefig.__doc__ = dedent(Figure.savefig.__doc__) +def ginput(*args, **kwargs): + """ + Blocking call to interact with the figure. + + This will wait for n clicks from the user and return a list of the + coordinates of each click. + + If timeout is negative, does not timeout. + """ + return gcf().ginput(*args, **kwargs) +if Figure.ginput.__doc__ is not None: + ginput.__doc__ = dedent(Figure.ginput.__doc__) + + # Putting things in figures def figtext(*args, **kwargs): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4940 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4940&view=rev Author: efiring Date: 2008年02月04日 23:54:01 -0800 (2008年2月04日) Log Message: ----------- New example to illustrate log scale for contour levels. Added Paths: ----------- trunk/matplotlib/examples/contourf_log.py Added: trunk/matplotlib/examples/contourf_log.py =================================================================== --- trunk/matplotlib/examples/contourf_log.py (rev 0) +++ trunk/matplotlib/examples/contourf_log.py 2008年02月05日 07:54:01 UTC (rev 4940) @@ -0,0 +1,48 @@ +''' +Demonstrate use of a log color scale in contourf +''' + +from matplotlib import pyplot as P +import numpy as npy +from numpy import ma +from matplotlib import colors, ticker +from matplotlib.mlab import bivariate_normal + +N = 100 +x = npy.linspace(-3.0, 3.0, N) +y = npy.linspace(-2.0, 2.0, N) + +X, Y = npy.meshgrid(x, y) + +# A low hump with a spike coming out of the top right. +# Needs to have z/colour axis on a log scale so we see both hump and spike. +# linear scale only shows the spike. +z = (bivariate_normal(X, Y, 0.1, 0.2, 1.0, 1.0) + + 0.1 * bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)) + +# Put in some negative values (lower left corner) to cause trouble with logs: +z[:5, :5] = -1 + +# The following is not strictly essential, but it will eliminate +# a warning. Comment it out to see the warning. +z = ma.masked_where(z<= 0, z) + + +# Automatic selection of levels works; setting the +# log locator tells contourf to use a log scale: +cs = P.contourf(X, Y, z, locator=ticker.LogLocator()) + +# Alternatively, you can manually set the levels +# and the norm: +#lev_exp = npy.arange(npy.floor(npy.log10(z.min())-1), +# npy.ceil(npy.log10(z.max())+1)) +#levs = npy.power(10, lev_exp) +#cs = P.contourf(X, Y, z, levs, norm=colors.LogNorm()) + +#The 'extend' kwarg does not work yet with a log scale. + +cbar = P.colorbar() + +P.show() + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4939 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4939&view=rev Author: efiring Date: 2008年02月04日 23:34:39 -0800 (2008年2月04日) Log Message: ----------- Bugfix in contour auto level selection via locator Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/contour.py Modified: trunk/matplotlib/lib/matplotlib/contour.py =================================================================== --- trunk/matplotlib/lib/matplotlib/contour.py 2008年02月04日 19:53:07 UTC (rev 4938) +++ trunk/matplotlib/lib/matplotlib/contour.py 2008年02月05日 07:34:39 UTC (rev 4939) @@ -514,12 +514,11 @@ self.locator = ticker.LogLocator() else: self.locator = ticker.MaxNLocator(N+1) - self.locator.create_dummy_axis() - locator = self.locator + self.locator.create_dummy_axis() zmax = self.zmax zmin = self.zmin - locator.set_bounds(zmin, zmax) - lev = locator() + self.locator.set_bounds(zmin, zmax) + lev = self.locator() zmargin = (zmax - zmin) * 0.000001 # so z < (zmax + zmargin) if zmax >= lev[-1]: lev[-1] += zmargin This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4938 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4938&view=rev Author: mdboom Date: 2008年02月04日 11:53:07 -0800 (2008年2月04日) Log Message: ----------- Fix Postscript graphics context bug (Thanks Paul Novak for finding this) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年02月04日 07:25:08 UTC (rev 4937) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年02月04日 19:53:07 UTC (rev 4938) @@ -759,6 +759,15 @@ fill = (fill and rgbFace is not None and (len(rgbFace) <= 3 or rgbFace[3] != 0.0)) + if stroke or gc.get_linewidth() > 0.0: + self.set_linewidth(gc.get_linewidth()) + jint = gc.get_joinstyle() + self.set_linejoin(jint) + cint = gc.get_capstyle() + self.set_linecap(cint) + self.set_linedash(*gc.get_dashes()) + self.set_color(*gc.get_rgb()[:3]) + cliprect = gc.get_clip_rectangle() if cliprect: x,y,w,h=cliprect.bounds @@ -782,14 +791,7 @@ self.set_color(store=0, *rgbFace[:3]) write("fill\ngrestore\n") - if stroke and gc.get_linewidth() > 0.0: - self.set_linewidth(gc.get_linewidth()) - jint = gc.get_joinstyle() - self.set_linejoin(jint) - cint = gc.get_capstyle() - self.set_linecap(cint) - self.set_linedash(*gc.get_dashes()) - self.set_color(*gc.get_rgb()[:3]) + if stroke or gc.get_linewidth() > 0.0: write("stroke\n") else: write("newpath\n") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4937 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4937&view=rev Author: efiring Date: 2008年02月03日 23:25:08 -0800 (2008年2月03日) Log Message: ----------- Raise ValueError if legend is called with invalid numpoints (Paul Novak) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/legend.py Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008年02月04日 06:50:00 UTC (rev 4936) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008年02月04日 07:25:08 UTC (rev 4937) @@ -122,6 +122,8 @@ if value is None: value=rcParams["legend."+name] setattr(self,name,value) + if self.numpoints <= 0: + raise ValueError("numpoints must be >= 0; it was %d"% numpoints) if prop is None: self.prop=FontProperties(size=rcParams["legend.fontsize"]) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4936 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4936&view=rev Author: efiring Date: 2008年02月03日 22:50:00 -0800 (2008年2月03日) Log Message: ----------- Add AxesImage.interpnames (based on old request by fr...@gm...) Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/image.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年02月03日 21:38:20 UTC (rev 4935) +++ trunk/matplotlib/CHANGELOG 2008年02月04日 06:50:00 UTC (rev 4936) @@ -1,3 +1,6 @@ +2008年02月03日 Expose interpnames, a list of valid interpolation + methods, as an AxesImage class attribute. - EF + 2008年02月03日 Added BoundaryNorm, with examples in colorbar_only.py and image_masked.py. - EF Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2008年02月03日 21:38:20 UTC (rev 4935) +++ trunk/matplotlib/lib/matplotlib/image.py 2008年02月04日 06:50:00 UTC (rev 4936) @@ -24,7 +24,32 @@ class AxesImage(martist.Artist, cm.ScalarMappable): zorder = 1 + # map interpolation strings to module constants + _interpd = { + 'nearest' : _image.NEAREST, + 'bilinear' : _image.BILINEAR, + 'bicubic' : _image.BICUBIC, + 'spline16' : _image.SPLINE16, + 'spline36' : _image.SPLINE36, + 'hanning' : _image.HANNING, + 'hamming' : _image.HAMMING, + 'hermite' : _image.HERMITE, + 'kaiser' : _image.KAISER, + 'quadric' : _image.QUADRIC, + 'catrom' : _image.CATROM, + 'gaussian' : _image.GAUSSIAN, + 'bessel' : _image.BESSEL, + 'mitchell' : _image.MITCHELL, + 'sinc' : _image.SINC, + 'lanczos' : _image.LANCZOS, + 'blackman' : _image.BLACKMAN, + } + # reverse interp dict + _interpdr = dict([ (v,k) for k,v in _interpd.items()]) + + interpnames = _interpd.keys() + def __init__(self, ax, cmap = None, norm = None, @@ -59,30 +84,7 @@ self.set_filterrad(filterrad) - # map interpolation strings to module constants - self._interpd = { - 'nearest' : _image.NEAREST, - 'bilinear' : _image.BILINEAR, - 'bicubic' : _image.BICUBIC, - 'spline16' : _image.SPLINE16, - 'spline36' : _image.SPLINE36, - 'hanning' : _image.HANNING, - 'hamming' : _image.HAMMING, - 'hermite' : _image.HERMITE, - 'kaiser' : _image.KAISER, - 'quadric' : _image.QUADRIC, - 'catrom' : _image.CATROM, - 'gaussian' : _image.GAUSSIAN, - 'bessel' : _image.BESSEL, - 'mitchell' : _image.MITCHELL, - 'sinc' : _image.SINC, - 'lanczos' : _image.LANCZOS, - 'blackman' : _image.BLACKMAN, - } - # reverse interp dict - self._interpdr = dict([ (v,k) for k,v in self._interpd.items()]) - self.set_interpolation(interpolation) self.axes = ax This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4935 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4935&view=rev Author: efiring Date: 2008年02月03日 13:38:20 -0800 (2008年2月03日) Log Message: ----------- Fixed right-hand y tick label positioning bug reported by Darren Dale Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年02月03日 21:26:42 UTC (rev 4934) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年02月03日 21:38:20 UTC (rev 4935) @@ -687,7 +687,7 @@ need to place axis elements in different locations. """ return (self._yaxis_transform + - mtransforms.ScaledTranslation(-1 * pad_points / 72.0, 0, + mtransforms.ScaledTranslation(pad_points / 72.0, 0, self.figure.dpi_scale_trans), "center", "left") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4934 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4934&view=rev Author: efiring Date: 2008年02月03日 13:26:42 -0800 (2008年2月03日) Log Message: ----------- Modified BoundaryNorm, examples, colorbar support Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/colorbar_only.py trunk/matplotlib/examples/image_masked.py trunk/matplotlib/lib/matplotlib/colorbar.py trunk/matplotlib/lib/matplotlib/colors.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年02月03日 21:10:22 UTC (rev 4933) +++ trunk/matplotlib/CHANGELOG 2008年02月03日 21:26:42 UTC (rev 4934) @@ -1,3 +1,6 @@ +2008年02月03日 Added BoundaryNorm, with examples in colorbar_only.py + and image_masked.py. - EF + 2008年02月03日 Force dpi=72 in pdf backend to fix picture size bug. - JKS 2008年02月01日 Fix reference leak in ft2font Glyph objects. - MGD Modified: trunk/matplotlib/examples/colorbar_only.py =================================================================== --- trunk/matplotlib/examples/colorbar_only.py 2008年02月03日 21:10:22 UTC (rev 4933) +++ trunk/matplotlib/examples/colorbar_only.py 2008年02月03日 21:26:42 UTC (rev 4934) @@ -35,7 +35,7 @@ # one greater than the length of the color list. The bounds must be # monotonically increasing. bounds = [1, 2, 4, 7, 8] -norm = mpl.colors.BoundaryNorm(bounds) +norm = mpl.colors.BoundaryNorm(bounds, cmap.N) cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=cmap, norm=norm, # to use 'extend', you must Modified: trunk/matplotlib/examples/image_masked.py =================================================================== --- trunk/matplotlib/examples/image_masked.py 2008年02月03日 21:10:22 UTC (rev 4933) +++ trunk/matplotlib/examples/image_masked.py 2008年02月03日 21:26:42 UTC (rev 4934) @@ -1,6 +1,8 @@ #!/usr/bin/env python '''imshow with masked array input and out-of-range colors. + The second subplot illustrates the use of BoundaryNorm to + get a filled contour effect. ''' from pylab import * @@ -31,10 +33,23 @@ # range to which the regular palette color scale is applied. # Anything above that range is colored based on palette.set_over, etc. +subplot(1,2,1) im = imshow(Zm, interpolation='bilinear', cmap=palette, norm = colors.Normalize(vmin = -1.0, vmax = 1.0, clip = False), origin='lower', extent=[-3,3,-3,3]) title('Green=low, Red=high, Blue=bad') -colorbar(im, extend='both', shrink=0.8) +colorbar(im, extend='both', orientation='horizontal', shrink=0.8) + +subplot(1,2,2) +im = imshow(Zm, interpolation='nearest', + cmap=palette, + norm = colors.BoundaryNorm([-1, -0.5, -0.2, 0, 0.2, 0.5, 1], + ncolors=256, clip = False), + origin='lower', extent=[-3,3,-3,3]) +title('With BoundaryNorm') +colorbar(im, extend='both', spacing='proportional', + orientation='horizontal', shrink=0.8) + show() + Modified: trunk/matplotlib/lib/matplotlib/colorbar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colorbar.py 2008年02月03日 21:10:22 UTC (rev 4933) +++ trunk/matplotlib/lib/matplotlib/colorbar.py 2008年02月03日 21:26:42 UTC (rev 4934) @@ -323,6 +323,9 @@ nv = len(self._values) base = 1 + int(nv/10) locator = ticker.IndexLocator(base=base, offset=0) + elif isinstance(self.norm, colors.BoundaryNorm): + b = self.norm.boundaries + locator = ticker.FixedLocator(b, nbins=10) elif isinstance(self.norm, colors.LogNorm): locator = ticker.LogLocator() else: @@ -389,6 +392,23 @@ self._boundaries = b self._values = v return + elif isinstance(self.norm, colors.BoundaryNorm): + b = list(self.norm.boundaries) + if self.extend in ('both', 'min'): + b = [b[0]-1] + b + if self.extend in ('both', 'max'): + b = b + [b[-1] + 1] + b = npy.array(b) + v = npy.zeros((len(b)-1,), dtype=float) + bi = self.norm.boundaries + v[self._inside] = 0.5*(bi[:-1] + bi[1:]) + if self.extend in ('both', 'min'): + v[0] = b[0] - 1 + if self.extend in ('both', 'max'): + v[-1] = b[-1] + 1 + self._boundaries = b + self._values = v + return else: if not self.norm.scaled(): self.norm.vmin = 0 Modified: trunk/matplotlib/lib/matplotlib/colors.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colors.py 2008年02月03日 21:10:22 UTC (rev 4933) +++ trunk/matplotlib/lib/matplotlib/colors.py 2008年02月03日 21:26:42 UTC (rev 4934) @@ -685,13 +685,41 @@ return vmin * pow((vmax/vmin), value) class BoundaryNorm(Normalize): - def __init__(self, boundaries, clip=False): + ''' + Generate a colormap index based on discrete intervals. + + Unlike Normalize or LogNorm, BoundaryNorm maps values + to integers instead of to the interval 0-1. + + Mapping to the 0-1 interval could have been done via + piece-wise linear interpolation, but using integers seems + simpler, and reduces the number of conversions back and forth + between integer and floating point. + ''' + def __init__(self, boundaries, ncolors, clip=False): + ''' + args: + boundaries: a monotonically increasing sequence + ncolors: number of colors in the colormap to be used + + If b[i] <= v < b[i+1] then v is mapped to color j; + as i varies from 0 to len(boundaries)-2, + j goes from 0 to ncolors-1. + + Out-of-range values are mapped to -1 if low and ncolors + if high; these are converted to valid indices by + Colormap.__call__. + ''' self.clip = clip self.vmin = boundaries[0] self.vmax = boundaries[-1] self.boundaries = npy.asarray(boundaries) - self.midpoints = 0.5 *(self.boundaries[:-1] + self.boundaries[1:]) self.N = len(self.boundaries) + self.Ncmap = ncolors + if self.N-1 == self.Ncmap: + self._interp = False + else: + self._interp = True def __call__(self, x, clip=None): if clip is None: @@ -704,15 +732,17 @@ iret = npy.zeros(x.shape, dtype=npy.int16) for i, b in enumerate(self.boundaries): iret[xx>=b] = i + if self._interp: + iret = (iret * (float(self.Ncmap-1)/(self.N-2))).astype(npy.int16) iret[xx<self.vmin] = -1 - iret[xx>=self.vmax] = self.N - ret = ma.array(iret / float(self.N-1), mask=mask) + iret[xx>=self.vmax] = self.Ncmap + ret = ma.array(iret, mask=mask) if ret.shape == () and not mask: - ret = float(ret) # assume python scalar + ret = int(ret) # assume python scalar return ret def inverse(self, value): - return self.midpoints[int(value*(self.N-1))] + return ValueError("BoundaryNorm is not invertible") class NoNorm(Normalize): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4933 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4933&view=rev Author: jouni Date: 2008年02月03日 13:10:22 -0800 (2008年2月03日) Log Message: ----------- Force the pdf backend to always use 72 as the dpi value. This fixes the size problem of the resulting files (since the size is measured in units of 1/72 inch). TODO: the user now has no control over the dpi of images. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年02月02日 21:32:21 UTC (rev 4932) +++ trunk/matplotlib/CHANGELOG 2008年02月03日 21:10:22 UTC (rev 4933) @@ -1,3 +1,5 @@ +2008年02月03日 Force dpi=72 in pdf backend to fix picture size bug. - JKS + 2008年02月01日 Fix reference leak in ft2font Glyph objects. - MGD 2008年01月31日 Don't use unicode strings with usetex by default - DSD Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年02月02日 21:32:21 UTC (rev 4932) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年02月03日 21:10:22 UTC (rev 4933) @@ -1853,8 +1853,9 @@ return 'pdf' def print_pdf(self, filename, **kwargs): - dpi = kwargs.get('dpi', 72) - self.figure.set_dpi(dpi) # Override the dpi kwarg + dpi = 72 # there are 72 Postscript points to an inch + # TODO: use the dpi kwarg for images + self.figure.set_dpi(dpi) width, height = self.figure.get_size_inches() file = PdfFile(width, height, dpi, filename) renderer = MixedModeRenderer( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4932 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4932&view=rev Author: jdh2358 Date: 2008年02月02日 13:32:21 -0800 (2008年2月02日) Log Message: ----------- added manual axis example Added Paths: ----------- trunk/matplotlib/examples/manual_axis.py Added: trunk/matplotlib/examples/manual_axis.py =================================================================== --- trunk/matplotlib/examples/manual_axis.py (rev 0) +++ trunk/matplotlib/examples/manual_axis.py 2008年02月02日 21:32:21 UTC (rev 4932) @@ -0,0 +1,57 @@ +""" +matplotlib is fairly rigid about how and where it draws it xaxis and +yaxis, and it is a frequent request to be able to place these in other +locations. While it is not possible to customize matplotlib's +internal axis objects in this way, it is not too hard to simply turn +them off and draw your own axis lines, tick lines, and tick labels +where and how you want them +""" + +import numpy as np +from pylab import figure, show +import matplotlib.lines as lines + +def make_xaxis(ax, yloc, offset=0.05, **props): + xmin, xmax = ax.get_xlim() + locs = [loc for loc in ax.xaxis.get_majorticklocs() + if loc>=xmin and loc<=xmax] + tickline, = ax.plot(locs, [yloc]*len(locs),linestyle='', + marker=lines.TICKDOWN, **props) + axline, = ax.plot([xmin, xmax], [yloc, yloc], **props) + tickline.set_clip_on(False) + axline.set_clip_on(False) + for loc in locs: + ax.text(loc, yloc-offset, '%1.1f'%loc, + horizontalalignment='center', + verticalalignment='top') + +def make_yaxis(ax, xloc=0, offset=0.05, **props): + ymin, ymax = ax.get_ylim() + locs = [loc for loc in ax.yaxis.get_majorticklocs() + if loc>=ymin and loc<=ymax] + tickline, = ax.plot([xloc]*len(locs), locs, linestyle='', + marker=lines.TICKLEFT, **props) + axline, = ax.plot([xloc, xloc], [ymin, ymax], **props) + tickline.set_clip_on(False) + axline.set_clip_on(False) + + for loc in locs: + ax.text(xloc-offset, loc, '%1.1f'%loc, + verticalalignment='center', + horizontalalignment='right') + + +props = dict(color='black', linewidth=2, markeredgewidth=2) +x = np.arange(200.) +y = np.sin(2*np.pi*x/200.) + np.random.rand(200)-0.5 +fig = figure(facecolor='white') +ax = fig.add_subplot(111, frame_on=False) +ax.axison = False +ax.plot(x, y, 'd', markersize=8, markerfacecolor='blue') +ax.set_xlim(0, 200) +ax.set_ylim(-1.5, 1.5) +make_xaxis(ax, 0, offset=0.1, **props) +make_yaxis(ax, 0, offset=5, **props) +fig.savefig('manual_axis.png', dpi=100, facecolor='white', edgecolor='white') +show() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4931 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4931&view=rev Author: efiring Date: 2008年02月02日 00:21:41 -0800 (2008年2月02日) Log Message: ----------- Fixed bug in vlines: it was not expanding scalar ymin, ymax Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年02月02日 07:53:03 UTC (rev 4930) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年02月02日 08:21:41 UTC (rev 4931) @@ -2569,14 +2569,14 @@ if not iterable(xmin): xmin = [xmin] if not iterable(xmax): xmax = [xmax] y = npy.asarray(y) + xmin = npy.asarray(xmin) + xmax = npy.asarray(xmax) if len(xmin)==1: xmin = xmin*npy.ones(y.shape, y.dtype) if len(xmax)==1: xmax = xmax*npy.ones(y.shape, y.dtype) - xmin = npy.asarray(xmin) - xmax = npy.asarray(xmax) if len(xmin)!=len(y): raise ValueError, 'xmin and y are unequal sized sequences' @@ -2640,8 +2640,11 @@ x = npy.asarray(x) ymin = npy.asarray(ymin) ymax = npy.asarray(ymax) + if len(ymin)==1: + ymin = ymin*npy.ones(x.shape, x.dtype) + if len(ymax)==1: + ymax = ymax*npy.ones(x.shape, x.dtype) - if len(ymin)!=len(x): raise ValueError, 'ymin and x are unequal sized sequences' if len(ymax)!=len(x): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4930 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4930&view=rev Author: efiring Date: 2008年02月01日 23:53:03 -0800 (2008年2月01日) Log Message: ----------- Added BoundaryNorm to support irregular discrete color intervals Modified Paths: -------------- trunk/matplotlib/examples/colorbar_only.py trunk/matplotlib/lib/matplotlib/colorbar.py trunk/matplotlib/lib/matplotlib/colors.py Modified: trunk/matplotlib/examples/colorbar_only.py =================================================================== --- trunk/matplotlib/examples/colorbar_only.py 2008年02月01日 20:15:59 UTC (rev 4929) +++ trunk/matplotlib/examples/colorbar_only.py 2008年02月02日 07:53:03 UTC (rev 4930) @@ -2,12 +2,12 @@ Make a colorbar as a separate figure. ''' -import pylab -import matplotlib as mpl +from matplotlib import pyplot, mpl # Make a figure and axes with dimensions as desired. -fig = pylab.figure(figsize=(8,1.5)) -ax = fig.add_axes([0.05, 0.4, 0.9, 0.5]) +fig = pyplot.figure(figsize=(8,3)) +ax1 = fig.add_axes([0.05, 0.65, 0.9, 0.15]) +ax2 = fig.add_axes([0.05, 0.25, 0.9, 0.15]) # Set the colormap and norm to correspond to the data for which # the colorbar will be used. @@ -19,10 +19,33 @@ # standalone colorbar. There are many more kwargs, but the # following gives a basic continuous colorbar with ticks # and labels. -cb = mpl.colorbar.ColorbarBase(ax, cmap=cmap, +cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cmap, norm=norm, orientation='horizontal') -cb.set_label('Some Units') +cb1.set_label('Some Units') -pylab.show() +# The second example illustrates the use of a ListedColormap, a +# BoundaryNorm, and extended ends to show the "over" and "under" +# value colors. +cmap = mpl.colors.ListedColormap(['r', 'g', 'b', 'c']) +cmap.set_over('0.25') +cmap.set_under('0.75') +# If a ListedColormap is used, the length of the bounds array must be +# one greater than the length of the color list. The bounds must be +# monotonically increasing. +bounds = [1, 2, 4, 7, 8] +norm = mpl.colors.BoundaryNorm(bounds) +cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=cmap, + norm=norm, + # to use 'extend', you must + # specify two extra boundaries: + boundaries=[0]+bounds+[13], + extend='both', + ticks=bounds, # optional + spacing='proportional', + orientation='horizontal') +cb2.set_label('Discrete intervals, some other units') + +pyplot.show() + Modified: trunk/matplotlib/lib/matplotlib/colorbar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colorbar.py 2008年02月01日 20:15:59 UTC (rev 4929) +++ trunk/matplotlib/lib/matplotlib/colorbar.py 2008年02月02日 07:53:03 UTC (rev 4930) @@ -356,7 +356,7 @@ if b is None: b = self.boundaries if b is not None: - self._boundaries = npy.array(b) + self._boundaries = npy.asarray(b, dtype=float) if self.values is None: self._values = 0.5*(self._boundaries[:-1] + self._boundaries[1:]) @@ -456,7 +456,12 @@ Return colorbar data coordinates for the boundaries of a proportional colorbar. ''' - y = self.norm(self._boundaries.copy()) + if isinstance(self.norm, colors.BoundaryNorm): + b = self._boundaries[self._inside] + y = (self._boundaries - self._boundaries[0]) + y = y / (self._boundaries[-1] - self._boundaries[0]) + else: + y = self.norm(self._boundaries.copy()) if self.extend in ('both', 'min'): y[0] = -0.05 if self.extend in ('both', 'max'): @@ -492,7 +497,7 @@ within range, together with their corresponding colorbar data coordinates. ''' - if isinstance(self.norm, colors.NoNorm): + if isinstance(self.norm, (colors.NoNorm, colors.BoundaryNorm)): b = self._boundaries xn = x xout = x Modified: trunk/matplotlib/lib/matplotlib/colors.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colors.py 2008年02月01日 20:15:59 UTC (rev 4929) +++ trunk/matplotlib/lib/matplotlib/colors.py 2008年02月02日 07:53:03 UTC (rev 4930) @@ -684,7 +684,37 @@ else: return vmin * pow((vmax/vmin), value) +class BoundaryNorm(Normalize): + def __init__(self, boundaries, clip=False): + self.clip = clip + self.vmin = boundaries[0] + self.vmax = boundaries[-1] + self.boundaries = npy.asarray(boundaries) + self.midpoints = 0.5 *(self.boundaries[:-1] + self.boundaries[1:]) + self.N = len(self.boundaries) + def __call__(self, x, clip=None): + if clip is None: + clip = self.clip + x = ma.asarray(x) + mask = ma.getmaskarray(x) + xx = x.filled(self.vmax+1) + if clip: + npy.clip(xx, self.vmin, self.vmax) + iret = npy.zeros(x.shape, dtype=npy.int16) + for i, b in enumerate(self.boundaries): + iret[xx>=b] = i + iret[xx<self.vmin] = -1 + iret[xx>=self.vmax] = self.N + ret = ma.array(iret / float(self.N-1), mask=mask) + if ret.shape == () and not mask: + ret = float(ret) # assume python scalar + return ret + + def inverse(self, value): + return self.midpoints[int(value*(self.N-1))] + + class NoNorm(Normalize): ''' Dummy replacement for Normalize, for the case where we This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4929 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4929&view=rev Author: mdboom Date: 2008年02月01日 12:15:59 -0800 (2008年2月01日) Log Message: ----------- Fix tick-alignment problem (Thanks J?195円?182円rgen Stenarson) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/lines.py trunk/matplotlib/src/_backend_agg.cpp Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008年02月01日 19:15:20 UTC (rev 4928) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008年02月01日 20:15:59 UTC (rev 4929) @@ -875,7 +875,7 @@ path, path_trans) - _tickhoriz_path = Path([[0.0, 0.5], [1.0, 0.5]]) + _tickhoriz_path = Path([[0.0, 0.0], [1.0, 0.0]]) def _draw_tickleft(self, renderer, gc, path, path_trans): offset = renderer.points_to_pixels(self._markersize) marker_transform = Affine2D().scale(-offset, 1.0) @@ -890,7 +890,7 @@ path, path_trans) - _tickvert_path = Path([[-0.5, 0.0], [-0.5, 1.0]]) + _tickvert_path = Path([[-0.0, 0.0], [-0.0, 1.0]]) def _draw_tickup(self, renderer, gc, path, path_trans): offset = renderer.points_to_pixels(self._markersize) marker_transform = Affine2D().scale(1.0, offset) Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2008年02月01日 19:15:20 UTC (rev 4928) +++ trunk/matplotlib/src/_backend_agg.cpp 2008年02月01日 20:15:59 UTC (rev 4929) @@ -465,7 +465,7 @@ RendererAgg::draw_markers(const Py::Tuple& args) { typedef agg::conv_transform<PathIterator> transformed_path_t; typedef SimplifyPath<transformed_path_t> simplify_t; - typedef agg::conv_curve<transformed_path_t> curve_t; + typedef agg::conv_curve<simplify_t> curve_t; typedef agg::conv_stroke<curve_t> stroke_t; typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; @@ -488,15 +488,15 @@ trans *= agg::trans_affine_translation(0.0, (double)height); PathIterator marker_path(marker_path_obj); + bool marker_snap = should_snap(marker_path, marker_trans); transformed_path_t marker_path_transformed(marker_path, marker_trans); - curve_t marker_path_curve(marker_path_transformed); + simplify_t marker_path_simplified(marker_path_transformed, marker_snap, false, width, height); + curve_t marker_path_curve(marker_path_simplified); PathIterator path(path_obj); - bool snap = should_snap(path, trans); transformed_path_t path_transformed(path, trans); GCAgg gc = GCAgg(gc_obj, dpi); - simplify_t path_simplified(path_transformed, snap, false, width, height); - path_simplified.rewind(0); + path_transformed.rewind(0); facepair_t face = _get_rgba_face(face_obj, gc.alpha); @@ -549,7 +549,7 @@ agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl; if (has_clippath) { - while (path_simplified.vertex(&x, &y) != agg::path_cmd_stop) { + while (path_transformed.vertex(&x, &y) != agg::path_cmd_stop) { pixfmt_amask_type pfa(*pixFmt, *alphaMask); amask_ren_type r(pfa); amask_aa_renderer_type ren(r); @@ -564,7 +564,7 @@ agg::render_scanlines(sa, sl, ren); } } else { - while (path_simplified.vertex(&x, &y) != agg::path_cmd_stop) { + while (path_transformed.vertex(&x, &y) != agg::path_cmd_stop) { if (face.first) { rendererAA->color(face.second); sa.init(fillCache, fillSize, x, y); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4928 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4928&view=rev Author: mdboom Date: 2008年02月01日 11:15:20 -0800 (2008年2月01日) Log Message: ----------- Merged revisions 4926-4927 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r4927 | mdboom | 2008年02月01日 14:13:09 -0500 (2008年2月01日) | 2 lines Fix doubly-included fonts in Postscript files. ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mathtext.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-4925 + /branches/v0_91_maint:1-4927 Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2008年02月01日 19:13:09 UTC (rev 4927) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008年02月01日 19:15:20 UTC (rev 4928) @@ -552,7 +552,6 @@ A generic base class for all font setups that use Truetype fonts (through ft2font) """ - basepath = os.path.join( get_data_path(), 'fonts' ) _fonts = {} class CachedFont: @@ -686,7 +685,7 @@ TruetypeFonts.__init__(self, *args, **kwargs) if not len(self.fontmap): for key, val in self._fontmap.iteritems(): - fullpath = os.path.join(self.basepath, 'ttf', val + ".ttf") + fullpath = findfont(val) self.fontmap[key] = fullpath self.fontmap[val] = fullpath @@ -913,7 +912,7 @@ TruetypeFonts.__init__(self, *args, **kwargs) if not len(self.fontmap): for key, name in self._fontmap.iteritems(): - fullpath = os.path.join(self.basepath, 'ttf', name + ".ttf") + fullpath = findfont(name) self.fontmap[key] = fullpath self.fontmap[name] = fullpath This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4927 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4927&view=rev Author: mdboom Date: 2008年02月01日 11:13:09 -0800 (2008年2月01日) Log Message: ----------- Fix doubly-included fonts in Postscript files. Modified Paths: -------------- branches/v0_91_maint/lib/matplotlib/mathtext.py Modified: branches/v0_91_maint/lib/matplotlib/mathtext.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/mathtext.py 2008年02月01日 18:39:59 UTC (rev 4926) +++ branches/v0_91_maint/lib/matplotlib/mathtext.py 2008年02月01日 19:13:09 UTC (rev 4927) @@ -552,7 +552,6 @@ A generic base class for all font setups that use Truetype fonts (through ft2font) """ - basepath = os.path.join( get_data_path(), 'fonts' ) _fonts = {} class CachedFont: @@ -686,7 +685,7 @@ TruetypeFonts.__init__(self, *args, **kwargs) if not len(self.fontmap): for key, val in self._fontmap.iteritems(): - fullpath = os.path.join(self.basepath, 'ttf', val + ".ttf") + fullpath = findfont(val) self.fontmap[key] = fullpath self.fontmap[val] = fullpath @@ -913,7 +912,7 @@ TruetypeFonts.__init__(self, *args, **kwargs) if not len(self.fontmap): for key, name in self._fontmap.iteritems(): - fullpath = os.path.join(self.basepath, 'ttf', name + ".ttf") + fullpath = findfont(name) self.fontmap[key] = fullpath self.fontmap[name] = fullpath This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4926 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4926&view=rev Author: mdboom Date: 2008年02月01日 10:39:59 -0800 (2008年2月01日) Log Message: ----------- Merged revisions 4921-4925 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r4922 | mdboom | 2008年02月01日 13:02:14 -0500 (2008年2月01日) | 3 lines Backing out Glyph object leak fix, since it causes segfaults with PDF backend. Will look into it further. ........ r4924 | mdboom | 2008年02月01日 13:03:52 -0500 (2008年2月01日) | 2 lines Oops in last commit. ........ r4925 | mdboom | 2008年02月01日 13:36:38 -0500 (2008年2月01日) | 2 lines Hopefully fixing the Glyph memory leak properly now. ........ Modified Paths: -------------- trunk/matplotlib/src/ft2font.cpp trunk/matplotlib/src/ft2font.h Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-4920 + /branches/v0_91_maint:1-4925 Modified: trunk/matplotlib/src/ft2font.cpp =================================================================== --- trunk/matplotlib/src/ft2font.cpp 2008年02月01日 18:36:38 UTC (rev 4925) +++ trunk/matplotlib/src/ft2font.cpp 2008年02月01日 18:39:59 UTC (rev 4926) @@ -749,10 +749,6 @@ for (size_t i=0; i<glyphs.size(); i++) { FT_Done_Glyph( glyphs[i] ); } - - for (size_t i=0; i<gms.size(); i++) { - Py_DECREF(gms[i]); - } } int @@ -792,13 +788,8 @@ FT_Done_Glyph( glyphs[i] ); } - for (size_t i=0; i<gms.size(); i++) { - Py_DECREF(gms[i]); - } + glyphs.clear(); - glyphs.resize(0); - gms.resize(0); - return Py::Object(); } @@ -1020,26 +1011,6 @@ return xys; } - -char FT2Font::get_glyph__doc__[] = -"get_glyph(num)\n" -"\n" -"Return the glyph object with num num\n" -; -Py::Object -FT2Font::get_glyph(const Py::Tuple & args){ - _VERBOSE("FT2Font::get_glyph"); - - args.verify_length(1); - int num = Py::Int(args[0]); - - if ( (size_t)num >= gms.size()) - throw Py::ValueError("Glyph index out of range"); - - Py_INCREF(gms[num]); - return Py::asObject(gms[num]); -} - char FT2Font::get_num_glyphs__doc__[] = "get_num_glyphs()\n" "\n" @@ -1093,9 +1064,7 @@ size_t num = glyphs.size(); //the index into the glyphs list glyphs.push_back(thisGlyph); Glyph* gm = new Glyph(face, thisGlyph, num); - gms.push_back(gm); - Py_INCREF(gm); - return Py::asObject( gm); + return Py::asObject(gm); } char FT2Font::get_width_height__doc__[] = @@ -1763,8 +1732,6 @@ add_varargs_method("get_xys", &FT2Font::get_xys, FT2Font::get_xys__doc__); - add_varargs_method("get_glyph", &FT2Font::get_glyph, - FT2Font::get_glyph__doc__); add_varargs_method("get_num_glyphs", &FT2Font::get_num_glyphs, FT2Font::get_num_glyphs__doc__); add_keyword_method("load_char", &FT2Font::load_char, Modified: trunk/matplotlib/src/ft2font.h =================================================================== --- trunk/matplotlib/src/ft2font.h 2008年02月01日 18:36:38 UTC (rev 4925) +++ trunk/matplotlib/src/ft2font.h 2008年02月01日 18:39:59 UTC (rev 4926) @@ -30,11 +30,11 @@ void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y); void write_bitmap(const char* filename) const; - void draw_rect(unsigned long x0, unsigned long y0, + void draw_rect(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1); - void draw_rect_filled(unsigned long x0, unsigned long y0, + void draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1); - + unsigned int get_width() const { return _width; }; unsigned int get_height() const { return _height; }; const unsigned char *const get_buffer() const { return _buffer; }; @@ -94,7 +94,6 @@ Py::Object set_size(const Py::Tuple & args); Py::Object set_charmap(const Py::Tuple & args); Py::Object set_text(const Py::Tuple & args, const Py::Dict & kwargs); - Py::Object get_glyph(const Py::Tuple & args); Py::Object get_kerning(const Py::Tuple & args); Py::Object get_num_glyphs(const Py::Tuple & args); Py::Object load_char(const Py::Tuple & args, const Py::Dict & kws); @@ -124,7 +123,6 @@ FT_Error error; std::vector<FT_Glyph> glyphs; std::vector<FT_Vector> pos; - std::vector<Glyph*> gms; double angle; double ptsize; double dpi; @@ -168,16 +166,16 @@ Glyph::init_type(); FT2Font::init_type(); - add_varargs_method("FT2Font", &ft2font_module::new_ft2font, + add_varargs_method("FT2Font", &ft2font_module::new_ft2font, "FT2Font"); - add_varargs_method("FT2Image", &ft2font_module::new_ft2image, + add_varargs_method("FT2Image", &ft2font_module::new_ft2image, "FT2Image"); initialize( "The ft2font module" ); } - - ~ft2font_module(); + + ~ft2font_module(); //static FT_Library ft2Library; - + private: Py::Object new_ft2font (const Py::Tuple &args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4925 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4925&view=rev Author: mdboom Date: 2008年02月01日 10:36:38 -0800 (2008年2月01日) Log Message: ----------- Hopefully fixing the Glyph memory leak properly now. Modified Paths: -------------- branches/v0_91_maint/src/ft2font.cpp branches/v0_91_maint/src/ft2font.h Modified: branches/v0_91_maint/src/ft2font.cpp =================================================================== --- branches/v0_91_maint/src/ft2font.cpp 2008年02月01日 18:03:52 UTC (rev 4924) +++ branches/v0_91_maint/src/ft2font.cpp 2008年02月01日 18:36:38 UTC (rev 4925) @@ -749,10 +749,6 @@ for (size_t i=0; i<glyphs.size(); i++) { FT_Done_Glyph( glyphs[i] ); } - - for (size_t i=0; i<gms.size(); i++) { - Py_DECREF(gms[i]); - } } int @@ -792,13 +788,8 @@ FT_Done_Glyph( glyphs[i] ); } - for (size_t i=0; i<gms.size(); i++) { - Py_DECREF(gms[i]); - } + glyphs.clear(); - glyphs.resize(0); - gms.resize(0); - return Py::Object(); } @@ -1021,25 +1012,6 @@ } -char FT2Font::get_glyph__doc__[] = -"get_glyph(num)\n" -"\n" -"Return the glyph object with num num\n" -; -Py::Object -FT2Font::get_glyph(const Py::Tuple & args){ - _VERBOSE("FT2Font::get_glyph"); - - args.verify_length(1); - int num = Py::Int(args[0]); - - if ( (size_t)num >= gms.size()) - throw Py::ValueError("Glyph index out of range"); - - Py_INCREF(gms[num]); - return Py::asObject(gms[num]); -} - char FT2Font::get_num_glyphs__doc__[] = "get_num_glyphs()\n" "\n" @@ -1093,9 +1065,7 @@ size_t num = glyphs.size(); //the index into the glyphs list glyphs.push_back(thisGlyph); Glyph* gm = new Glyph(face, thisGlyph, num); - gms.push_back(gm); - Py_INCREF(gm); - return Py::asObject( gm); + return Py::asObject(gm); } char FT2Font::get_width_height__doc__[] = @@ -1763,8 +1733,6 @@ add_varargs_method("get_xys", &FT2Font::get_xys, FT2Font::get_xys__doc__); - add_varargs_method("get_glyph", &FT2Font::get_glyph, - FT2Font::get_glyph__doc__); add_varargs_method("get_num_glyphs", &FT2Font::get_num_glyphs, FT2Font::get_num_glyphs__doc__); add_keyword_method("load_char", &FT2Font::load_char, Modified: branches/v0_91_maint/src/ft2font.h =================================================================== --- branches/v0_91_maint/src/ft2font.h 2008年02月01日 18:03:52 UTC (rev 4924) +++ branches/v0_91_maint/src/ft2font.h 2008年02月01日 18:36:38 UTC (rev 4925) @@ -30,11 +30,11 @@ void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y); void write_bitmap(const char* filename) const; - void draw_rect(unsigned long x0, unsigned long y0, + void draw_rect(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1); - void draw_rect_filled(unsigned long x0, unsigned long y0, + void draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1); - + unsigned int get_width() const { return _width; }; unsigned int get_height() const { return _height; }; const unsigned char *const get_buffer() const { return _buffer; }; @@ -94,7 +94,6 @@ Py::Object set_size(const Py::Tuple & args); Py::Object set_charmap(const Py::Tuple & args); Py::Object set_text(const Py::Tuple & args, const Py::Dict & kwargs); - Py::Object get_glyph(const Py::Tuple & args); Py::Object get_kerning(const Py::Tuple & args); Py::Object get_num_glyphs(const Py::Tuple & args); Py::Object load_char(const Py::Tuple & args, const Py::Dict & kws); @@ -124,7 +123,6 @@ FT_Error error; std::vector<FT_Glyph> glyphs; std::vector<FT_Vector> pos; - std::vector<Glyph*> gms; double angle; double ptsize; double dpi; @@ -168,16 +166,16 @@ Glyph::init_type(); FT2Font::init_type(); - add_varargs_method("FT2Font", &ft2font_module::new_ft2font, + add_varargs_method("FT2Font", &ft2font_module::new_ft2font, "FT2Font"); - add_varargs_method("FT2Image", &ft2font_module::new_ft2image, + add_varargs_method("FT2Image", &ft2font_module::new_ft2image, "FT2Image"); initialize( "The ft2font module" ); } - - ~ft2font_module(); + + ~ft2font_module(); //static FT_Library ft2Library; - + private: Py::Object new_ft2font (const Py::Tuple &args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4924 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4924&view=rev Author: mdboom Date: 2008年02月01日 10:03:52 -0800 (2008年2月01日) Log Message: ----------- Oops in last commit. Modified Paths: -------------- branches/v0_91_maint/src/ft2font.cpp Modified: branches/v0_91_maint/src/ft2font.cpp =================================================================== --- branches/v0_91_maint/src/ft2font.cpp 2008年02月01日 18:03:04 UTC (rev 4923) +++ branches/v0_91_maint/src/ft2font.cpp 2008年02月01日 18:03:52 UTC (rev 4924) @@ -1036,7 +1036,7 @@ if ( (size_t)num >= gms.size()) throw Py::ValueError("Glyph index out of range"); - Py_INCREF(gm); + Py_INCREF(gms[num]); return Py::asObject(gms[num]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4923 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4923&view=rev Author: mdboom Date: 2008年02月01日 10:03:04 -0800 (2008年2月01日) Log Message: ----------- Backing out Glyph object leak fix, since it causes segfaults with PDF backend. Will look into it further. Modified Paths: -------------- trunk/matplotlib/src/ft2font.cpp Modified: trunk/matplotlib/src/ft2font.cpp =================================================================== --- trunk/matplotlib/src/ft2font.cpp 2008年02月01日 18:02:14 UTC (rev 4922) +++ trunk/matplotlib/src/ft2font.cpp 2008年02月01日 18:03:04 UTC (rev 4923) @@ -1036,6 +1036,7 @@ if ( (size_t)num >= gms.size()) throw Py::ValueError("Glyph index out of range"); + Py_INCREF(gms[num]); return Py::asObject(gms[num]); } @@ -1093,6 +1094,7 @@ glyphs.push_back(thisGlyph); Glyph* gm = new Glyph(face, thisGlyph, num); gms.push_back(gm); + Py_INCREF(gm); return Py::asObject( gm); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4922 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4922&view=rev Author: mdboom Date: 2008年02月01日 10:02:14 -0800 (2008年2月01日) Log Message: ----------- Backing out Glyph object leak fix, since it causes segfaults with PDF backend. Will look into it further. Modified Paths: -------------- branches/v0_91_maint/src/ft2font.cpp Modified: branches/v0_91_maint/src/ft2font.cpp =================================================================== --- branches/v0_91_maint/src/ft2font.cpp 2008年02月01日 17:36:48 UTC (rev 4921) +++ branches/v0_91_maint/src/ft2font.cpp 2008年02月01日 18:02:14 UTC (rev 4922) @@ -1036,6 +1036,7 @@ if ( (size_t)num >= gms.size()) throw Py::ValueError("Glyph index out of range"); + Py_INCREF(gm); return Py::asObject(gms[num]); } @@ -1093,6 +1094,7 @@ glyphs.push_back(thisGlyph); Glyph* gm = new Glyph(face, thisGlyph, num); gms.push_back(gm); + Py_INCREF(gm); return Py::asObject( gm); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4921 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4921&view=rev Author: mdboom Date: 2008年02月01日 09:36:48 -0800 (2008年2月01日) Log Message: ----------- Merged revisions 4919-4920 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r4920 | mdboom | 2008年02月01日 12:24:56 -0500 (2008年2月01日) | 3 lines Change "delete" to "delete []" for arrays on the heap. (It's technically more correct, but also pleases valgrind.) ........ Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-4918 + /branches/v0_91_maint:1-4920 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4920 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4920&view=rev Author: mdboom Date: 2008年02月01日 09:24:56 -0800 (2008年2月01日) Log Message: ----------- Change "delete" to "delete []" for arrays on the heap. (It's technically more correct, but also pleases valgrind.) Modified Paths: -------------- branches/v0_91_maint/src/_backend_agg.cpp Modified: branches/v0_91_maint/src/_backend_agg.cpp =================================================================== --- branches/v0_91_maint/src/_backend_agg.cpp 2008年02月01日 17:23:41 UTC (rev 4919) +++ branches/v0_91_maint/src/_backend_agg.cpp 2008年02月01日 17:24:56 UTC (rev 4920) @@ -1110,10 +1110,10 @@ newXCoords[k] += newXOffsets[k]; newYCoords[k] += newYOffsets[k]; } - delete xOffsets; - delete yOffsets; - delete newXOffsets; - delete newYOffsets; + delete[] xOffsets; + delete[] yOffsets; + delete[] newXOffsets; + delete[] newYOffsets; } for(q=0; q < Nverts; q++) @@ -1129,8 +1129,8 @@ Py_XDECREF(xCoords); Py_XDECREF(yCoords); Py_XDECREF(colors); - delete newXCoords; - delete newYCoords; + delete[] newXCoords; + delete[] newYCoords; //printf("#2: %d\n", clock()); return Py::Object(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4919 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4919&view=rev Author: mdboom Date: 2008年02月01日 09:23:41 -0800 (2008年2月01日) Log Message: ----------- Merged revisions 4915-4918 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r4916 | dsdale | 2008年01月31日 14:05:28 -0500 (2008年1月31日) | 2 lines fixed a bug in ticker, unicode string passed to tex ........ r4917 | dsdale | 2008年01月31日 14:14:20 -0500 (2008年1月31日) | 2 lines forgot to change unicode string to raw string ........ r4918 | mdboom | 2008年02月01日 12:19:02 -0500 (2008年2月01日) | 2 lines Fix reference leak on Glyph objects. ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/src/ft2font.cpp Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-4914 + /branches/v0_91_maint:1-4918 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年02月01日 17:19:02 UTC (rev 4918) +++ trunk/matplotlib/CHANGELOG 2008年02月01日 17:23:41 UTC (rev 4919) @@ -1,3 +1,7 @@ +2008年02月01日 Fix reference leak in ft2font Glyph objects. - MGD + +2008年01月31日 Don't use unicode strings with usetex by default - DSD + 2008年01月31日 Fix text spacing problems in PDF backend with *some* fonts, such as STIXGeneral. Modified: trunk/matplotlib/src/ft2font.cpp =================================================================== --- trunk/matplotlib/src/ft2font.cpp 2008年02月01日 17:19:02 UTC (rev 4918) +++ trunk/matplotlib/src/ft2font.cpp 2008年02月01日 17:23:41 UTC (rev 4919) @@ -8,9 +8,9 @@ /** To improve the hinting of the fonts, this code uses a hack presented here: - + http://antigrain.com/research/font_rasterization/index.html - + The idea is to limit the effect of hinting in the x-direction, while preserving hinting in the y-direction. Since freetype does not support this directly, the dpi in the x-direction is set higher than @@ -20,7 +20,7 @@ hinting, whereas the global transform does not, this is documented behavior of freetype, and therefore hopefully unlikely to change. The freetype 2 tutorial says: - + NOTE: The transformation is applied to every glyph that is loaded through FT_Load_Glyph and is completely independent of any hinting process. This means that you won't get the same @@ -42,7 +42,7 @@ FT_Library _ft2Library; -// FT2Image::FT2Image() : +// FT2Image::FT2Image() : // _isDirty(true), // _buffer(NULL), // _width(0), _height(0), @@ -53,7 +53,7 @@ FT2Image::FT2Image(unsigned long width, unsigned long height) : _isDirty(true), - _buffer(NULL), + _buffer(NULL), _width(0), _height(0), _rgbCopy(NULL), _rgbaCopy(NULL) { @@ -61,10 +61,10 @@ resize(width, height); } -FT2Image::~FT2Image() { +FT2Image::~FT2Image() { _VERBOSE("FT2Image::~FT2Image"); - delete [] _buffer; - _buffer=NULL; + delete [] _buffer; + _buffer=NULL; delete _rgbCopy; delete _rgbaCopy; } @@ -151,7 +151,7 @@ } void -FT2Image::draw_rect(unsigned long x0, unsigned long y0, +FT2Image::draw_rect(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1) { if ( x0<0 || y0<0 || x1<0 || y1<0 || x0>_width || x1>_width || @@ -195,7 +195,7 @@ return Py::Object(); } -void FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0, +void FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1) { x0 = CLAMP(x0, 0, _width); y0 = CLAMP(y0, 0, _height); @@ -209,7 +209,7 @@ } _isDirty = true; -} +} char FT2Image::draw_rect_filled__doc__[] = "draw_rect_filled(x0, y0, x1, y1)\n" @@ -245,7 +245,7 @@ args.verify_length(0); return Py::asObject - (PyString_FromStringAndSize((const char *)_buffer, + (PyString_FromStringAndSize((const char *)_buffer, _width*_height) ); } @@ -284,7 +284,7 @@ args.verify_length(0); makeRgbCopy(); - + return _rgbCopy->py_as_str(args); } @@ -321,7 +321,7 @@ args.verify_length(0); makeRgbaCopy(); - + return _rgbaCopy->py_as_str(args); } @@ -671,7 +671,7 @@ } // set a default fontsize 12 pt at 72dpi -#ifdef VERTICAL_HINTING +#ifdef VERTICAL_HINTING error = FT_Set_Char_Size( face, 12 * 64, 0, 72 * HORIZ_HINTING, 72 ); static FT_Matrix transform = { 65536 / HORIZ_HINTING, 0, 0, 65536 }; FT_Set_Transform( face, &transform, 0 ); @@ -829,7 +829,7 @@ int error = FT_Set_Char_Size( face, (long)(ptsize * 64), 0, (unsigned int)dpi, (unsigned int)dpi ); -#endif +#endif if (error) throw Py::RuntimeError("Could not set the fontsize"); return Py::Object(); @@ -1036,7 +1036,6 @@ if ( (size_t)num >= gms.size()) throw Py::ValueError("Glyph index out of range"); - Py_INCREF(gms[num]); return Py::asObject(gms[num]); } @@ -1078,7 +1077,7 @@ long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_FORCE_AUTOHINT); if (kwargs.hasKey("flags")) flags = Py::Long(kwargs["flags"]); - + int error = FT_Load_Char( face, (unsigned long)charcode, flags); if (error) @@ -1094,7 +1093,6 @@ glyphs.push_back(thisGlyph); Glyph* gm = new Glyph(face, thisGlyph, num); gms.push_back(gm); - Py_INCREF(gm); //todo: refcount correct? return Py::asObject( gm); } @@ -1659,7 +1657,7 @@ } } -char FT2Font::get_image__doc__ [] = +char FT2Font::get_image__doc__ [] = "get_image()\n" "\n" "Returns the underlying image buffer for this font object.\n"; @@ -1669,7 +1667,7 @@ if (image) { Py_XINCREF(image); return Py::asObject(image); - } + } throw Py::RuntimeError("You must call .set_text() before .get_image()"); } @@ -1684,7 +1682,7 @@ args.verify_length(1); std::string filename = Py::String(args[0]); - FT_Error error = + FT_Error error = FT_Attach_File(face, filename.c_str()); if (error) { @@ -1884,7 +1882,7 @@ d["KERNING_DEFAULT"] = Py::Int(FT_KERNING_DEFAULT); d["KERNING_UNFITTED"] = Py::Int(FT_KERNING_UNFITTED); d["KERNING_UNSCALED"] = Py::Int(FT_KERNING_UNSCALED); - + d["LOAD_DEFAULT"] = Py::Long(FT_LOAD_DEFAULT); d["LOAD_NO_SCALE"] = Py::Long(FT_LOAD_NO_SCALE); d["LOAD_NO_HINTING"] = Py::Long(FT_LOAD_NO_HINTING); @@ -1894,7 +1892,7 @@ d["LOAD_FORCE_AUTOHINT"] = Py::Long(FT_LOAD_FORCE_AUTOHINT); d["LOAD_CROP_BITMAP"] = Py::Long(FT_LOAD_CROP_BITMAP); d["LOAD_PEDANTIC"] = Py::Long(FT_LOAD_PEDANTIC); - d["LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH"] = + d["LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH"] = Py::Long(FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); d["LOAD_NO_RECURSE"] = Py::Long(FT_LOAD_NO_RECURSE); d["LOAD_IGNORE_TRANSFORM"] = Py::Long(FT_LOAD_IGNORE_TRANSFORM); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4918 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4918&view=rev Author: mdboom Date: 2008年02月01日 09:19:02 -0800 (2008年2月01日) Log Message: ----------- Fix reference leak on Glyph objects. Modified Paths: -------------- branches/v0_91_maint/CHANGELOG branches/v0_91_maint/src/ft2font.cpp Modified: branches/v0_91_maint/CHANGELOG =================================================================== --- branches/v0_91_maint/CHANGELOG 2008年01月31日 19:14:20 UTC (rev 4917) +++ branches/v0_91_maint/CHANGELOG 2008年02月01日 17:19:02 UTC (rev 4918) @@ -1,3 +1,5 @@ +2008年02月01日 Fix reference leak in ft2font Glyph objects. - MGD + 2008年01月31日 Don't use unicode strings with usetex by default - DSD 2008年01月31日 Fix text spacing problems in PDF backend with *some* fonts, Modified: branches/v0_91_maint/src/ft2font.cpp =================================================================== --- branches/v0_91_maint/src/ft2font.cpp 2008年01月31日 19:14:20 UTC (rev 4917) +++ branches/v0_91_maint/src/ft2font.cpp 2008年02月01日 17:19:02 UTC (rev 4918) @@ -8,9 +8,9 @@ /** To improve the hinting of the fonts, this code uses a hack presented here: - + http://antigrain.com/research/font_rasterization/index.html - + The idea is to limit the effect of hinting in the x-direction, while preserving hinting in the y-direction. Since freetype does not support this directly, the dpi in the x-direction is set higher than @@ -20,7 +20,7 @@ hinting, whereas the global transform does not, this is documented behavior of freetype, and therefore hopefully unlikely to change. The freetype 2 tutorial says: - + NOTE: The transformation is applied to every glyph that is loaded through FT_Load_Glyph and is completely independent of any hinting process. This means that you won't get the same @@ -42,7 +42,7 @@ FT_Library _ft2Library; -// FT2Image::FT2Image() : +// FT2Image::FT2Image() : // _isDirty(true), // _buffer(NULL), // _width(0), _height(0), @@ -53,7 +53,7 @@ FT2Image::FT2Image(unsigned long width, unsigned long height) : _isDirty(true), - _buffer(NULL), + _buffer(NULL), _width(0), _height(0), _rgbCopy(NULL), _rgbaCopy(NULL) { @@ -61,10 +61,10 @@ resize(width, height); } -FT2Image::~FT2Image() { +FT2Image::~FT2Image() { _VERBOSE("FT2Image::~FT2Image"); - delete [] _buffer; - _buffer=NULL; + delete [] _buffer; + _buffer=NULL; delete _rgbCopy; delete _rgbaCopy; } @@ -151,7 +151,7 @@ } void -FT2Image::draw_rect(unsigned long x0, unsigned long y0, +FT2Image::draw_rect(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1) { if ( x0<0 || y0<0 || x1<0 || y1<0 || x0>_width || x1>_width || @@ -195,7 +195,7 @@ return Py::Object(); } -void FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0, +void FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1) { x0 = CLAMP(x0, 0, _width); y0 = CLAMP(y0, 0, _height); @@ -209,7 +209,7 @@ } _isDirty = true; -} +} char FT2Image::draw_rect_filled__doc__[] = "draw_rect_filled(x0, y0, x1, y1)\n" @@ -245,7 +245,7 @@ args.verify_length(0); return Py::asObject - (PyString_FromStringAndSize((const char *)_buffer, + (PyString_FromStringAndSize((const char *)_buffer, _width*_height) ); } @@ -284,7 +284,7 @@ args.verify_length(0); makeRgbCopy(); - + return _rgbCopy->py_as_str(args); } @@ -321,7 +321,7 @@ args.verify_length(0); makeRgbaCopy(); - + return _rgbaCopy->py_as_str(args); } @@ -671,7 +671,7 @@ } // set a default fontsize 12 pt at 72dpi -#ifdef VERTICAL_HINTING +#ifdef VERTICAL_HINTING error = FT_Set_Char_Size( face, 12 * 64, 0, 72 * HORIZ_HINTING, 72 ); static FT_Matrix transform = { 65536 / HORIZ_HINTING, 0, 0, 65536 }; FT_Set_Transform( face, &transform, 0 ); @@ -829,7 +829,7 @@ int error = FT_Set_Char_Size( face, (long)(ptsize * 64), 0, (unsigned int)dpi, (unsigned int)dpi ); -#endif +#endif if (error) throw Py::RuntimeError("Could not set the fontsize"); return Py::Object(); @@ -1036,7 +1036,6 @@ if ( (size_t)num >= gms.size()) throw Py::ValueError("Glyph index out of range"); - Py_INCREF(gms[num]); return Py::asObject(gms[num]); } @@ -1078,7 +1077,7 @@ long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_FORCE_AUTOHINT); if (kwargs.hasKey("flags")) flags = Py::Long(kwargs["flags"]); - + int error = FT_Load_Char( face, (unsigned long)charcode, flags); if (error) @@ -1094,7 +1093,6 @@ glyphs.push_back(thisGlyph); Glyph* gm = new Glyph(face, thisGlyph, num); gms.push_back(gm); - Py_INCREF(gm); //todo: refcount correct? return Py::asObject( gm); } @@ -1659,7 +1657,7 @@ } } -char FT2Font::get_image__doc__ [] = +char FT2Font::get_image__doc__ [] = "get_image()\n" "\n" "Returns the underlying image buffer for this font object.\n"; @@ -1669,7 +1667,7 @@ if (image) { Py_XINCREF(image); return Py::asObject(image); - } + } throw Py::RuntimeError("You must call .set_text() before .get_image()"); } @@ -1684,7 +1682,7 @@ args.verify_length(1); std::string filename = Py::String(args[0]); - FT_Error error = + FT_Error error = FT_Attach_File(face, filename.c_str()); if (error) { @@ -1884,7 +1882,7 @@ d["KERNING_DEFAULT"] = Py::Int(FT_KERNING_DEFAULT); d["KERNING_UNFITTED"] = Py::Int(FT_KERNING_UNFITTED); d["KERNING_UNSCALED"] = Py::Int(FT_KERNING_UNSCALED); - + d["LOAD_DEFAULT"] = Py::Long(FT_LOAD_DEFAULT); d["LOAD_NO_SCALE"] = Py::Long(FT_LOAD_NO_SCALE); d["LOAD_NO_HINTING"] = Py::Long(FT_LOAD_NO_HINTING); @@ -1894,7 +1892,7 @@ d["LOAD_FORCE_AUTOHINT"] = Py::Long(FT_LOAD_FORCE_AUTOHINT); d["LOAD_CROP_BITMAP"] = Py::Long(FT_LOAD_CROP_BITMAP); d["LOAD_PEDANTIC"] = Py::Long(FT_LOAD_PEDANTIC); - d["LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH"] = + d["LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH"] = Py::Long(FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); d["LOAD_NO_RECURSE"] = Py::Long(FT_LOAD_NO_RECURSE); d["LOAD_IGNORE_TRANSFORM"] = Py::Long(FT_LOAD_IGNORE_TRANSFORM); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.