Re: [matplotlib-devel] Embedded fonts in SVG
I've tested this approach with Firefox 2.0 and rsvg 2.16. The text alignment is actually much better since the text layout is fully under the control of matplotlib. This has been checked into SVN, and can be used by setting the rcparam "svg.embed_char_paths" to True. The following are my usual "size benchmarks" (that I used for PS and PDF as well): without character paths -> with character paths fonts_demo_kw.py: 10314 -> 69256 mathtext_demo.py: 10606 -> 37896 unicode_demo.py: 7677 -> 43473 over all demos in backend_driver.py: 17,722,815 -> 18,789,999 Cheers, Mike Michael Droettboom wrote: > Actually, it just occurred to me that you could use 'defs' and 'use' to > define characters as paths and reuse them. And that's something that > works today in virtually any SVG renderer. > > It totally blitzes the logical representation of the text (i.e. > searching and copying as text etc.), but if it was only done for math > text, then that's probably not a big deal. IMHO, math text is where > matching the exact font is most important, where a reasonable substitute > is often not installed, and where searching doesn't make a lot of > sense. In any case, editing the SVG in something like Inkscape will be > harder, since the text has become raw paths. > > Thanks to ft2font, it was fairly easy to get outlines of math characters > embedded in the SVG file. I've put up an example mathtext_demo.py SVG here: > > ftp://ftp.stsci.edu/tmp/mdroe/mathtext_demo.svg > > I'll commit this code once it's cleaned up and better tested etc. if > it's agreed this is something we want to do. I think in any case this > should be optional -- it gives the file some portability at the expense > of editability. > > Cheers, > Mike > > Carl Worth wrote: > >> On Tue, 10 Jul 2007 13:43:49 -0400, Michael Droettboom wrote: >> >> >>> "major SVG renderers" support seems to be the issue at first glance. >>> None of the big open source options -- Firefox, inkscape, rsvg -- seem >>> to support it. >>> >>> >> That's my understanding as well. >> >> >> >>> Until there's something readily available to test with, there's probably >>> not much point. >>> >>> >> It's a classic chicken-and-egg. I know the cairo-svg maintainer is >> hoping to add SVGFont stuff to cairo's SVG output to try to boostrap >> past this problem. >> >> > > > - > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ___ > Matplotlib-devel mailing list > Matplotlib-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > > - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] TTF subsetting in PDF
Michael Droettboom wrote: > Jouni K. Seppänen wrote: > >> "John Hunter" <[EMAIL PROTECTED]> writes: >> >> >> >>> On 7/10/07, Michael Droettboom <[EMAIL PROTECTED]> wrote: >>> >>> >> I'm seeing a bug on OS X, whose file system is by default >> case-preserving but not case-sensitive: >> >> 458 -> fontdictObject = self.embedTTF( >> 459 filename, self.used_characters[filename]) >> >> Here self.used_characters has a key starting with '/Users/jks/...' but >> filename is '/users/jks/...'. I'm not sure how to fix this cleanly. >> I though os.path.normcase would help, but it doesn't: >> >> >> > Thanks for that. The Ps backend has the same problem. I'll do a little > research and see what a common solution to this might be. > > I changed the code to use the file's (st_ino, st_dev) pair as a key, rather than the path. This is cached to prevent lots of little stat calls. This approach is reported to work on "Macintosh, Unix, and Windows", but I've only tested on Linux and OS-X. Please let me know if it solves your issue. Along the way, I found an interesting discussion about why normcase does what it does on OS-X. (Summary: because file names are case sensitive on OS-X, but not the default HFS+ filesystem that Macs ship with as their System volume.) http://mail.python.org/pipermail/python-list/2006-January/360098.html Cheers, Mike - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] TTF subsetting in PDF
Michael Droettboom <[EMAIL PROTECTED]> writes: > This approach is reported to work on "Macintosh, Unix, and Windows", > but I've only tested on Linux and OS-X. Please let me know if it > solves your issue. It solves my problem on OS X. Thanks! -- Jouni K. Seppänen http://www.iki.fi/jks - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] contourf masking bug
Mike, The attached file masked_interior.py illustrates masking failure in a very simple case; you can see masking working in the plot on the left, where a contour intersects the masked region, but when that contour level is removed the masked region is getting filled in. The file contourf_demo.py is slightly modified from the one in the mpl examples directory, and shows a failure of masking in a more complicated setting. The masked region at the lower-left corner is correct, but the masked region in the middle of the plot is getting filled with gray instead of being left blank. In cntr.c there is a function, print_Csite, that may be helpful for debugging the simplest case, where the array size is not too large. Note that the code path for filled contours is quite different, and more complicated, than for line contours--and in fact, even neglecting branch cuts, the two code paths don't always yield the same contours. cntr.c is somewhat unusual among contour algorithms in that it works with rectangles without subdividing them into triangles. Eric #!/usr/bin/env python ''' This is a very simple illustration of what is causing the problem with masked interior regions for filled contours. The exterior contour and the interior contour are being separated into two polygons instead of being joined by the branch cut. ''' import sys from pylab import * import matplotlib.numerix.npyma as ma rc('figure', dpi=120) x = y = arange(5) X, Y = meshgrid(x, y) Z = Y ax = (0,4,0,4) badmask = zeros(shape(X)) badmask[2, 2] = 1 Z = ma.array(Z, mask=badmask) print Z subplot(2,1,1) CS = contourf(X, Y, Z, (-0.1, 0.8, 2.0, 6.0), colors=('r', 'g', 'b')) CS.collections[0].set_edgecolor('c') CS.collections[0].set_linewidth(6) CS.collections[1].set_edgecolor('y') CS.collections[1].set_linewidth(2) CS.collections[2].set_edgecolor('m') CS.collections[2].set_linewidth(4) title('Masked correctly') subplot(2,1,2) CS = contourf(X, Y, Z, (-0.1, 0.8, 6.0), colors=('r', 'b')) CS.collections[0].set_edgecolor('c') CS.collections[0].set_linewidth(6) CS.collections[1].set_edgecolor('y') CS.collections[1].set_linewidth(2) title('Wrong: masked region filled') print "len(CS.collections)", len(CS.collections) colls = CS.collections # We want to look at the actual polygons individually. for i, coll in enumerate(colls): print "level ", i for j, T in enumerate(coll._verts): print "polygon ", j print T # The second collection has two polygons, but should only have # one; the two should be joined by a branch cut. show() #!/usr/bin/env python from pylab import * import matplotlib.numerix.npyma as ma origin = 'lower' #origin = 'upper' test_masking = True # There is a bug in filled contour masking. if test_masking: # Use a coarse grid so only a few masked points are needed. delta = 0.5 else: delta = 0.025 x = y = arange(-3.0, 3.01, delta) X, Y = meshgrid(x, y) Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) Z = 10 * (Z1 - Z2) # interior badmask doesn't work yet for filled contours if test_masking: badmask = zeros(shape(Z)) badmask[5,5] = 1 badmask[5,6] = 1 Z[5,5] = 0 Z[5,6] = 0 badmask[0,0] = 1 Z[0,0] = 0 Z = ma.array(Z, mask=badmask) # We are using automatic selection of contour levels; # this is usually not such a good idea, because they don't # occur on nice boundaries, but we do it here for purposes # of illustration. CS = contourf(X, Y, Z, 10, # [-1, -0.1, 0, 0.1], #alpha=0.5, cmap=cm.bone, origin=origin) # Note that in the following, we explicitly pass in a subset of # the contour levels used for the filled contours. Alternatively, # We could pass in additional levels to provide extra resolution. CS2 = contour(X, Y, Z, CS.levels[::2], colors = 'r', origin=origin, hold='on') title('Nonsense') xlabel('word length anomaly') ylabel('sentence length anomaly') # Make a colorbar for the ContourSet returned by the contourf call. cbar = colorbar(CS) cbar.ax.set_ylabel('verbosity coefficient') # Add the contour line levels to the colorbar cbar.add_lines(CS2) figure() # Now make a contour plot with the levels specified, # and with the colormap generated automatically from a list # of colors. levels = [-2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5] CS3 = contourf(X, Y, Z, levels, colors = ('r', 'g', 'b'), origin=origin) CS4 = contour(X, Y, Z, levels, colors = ('k',), linewidths = (3,), origin = origin) title('Listed colors') clabel(CS4, fmt = '%2.1f', colors = 'w', fontsize=14) colorbar(CS3) #savefig('contourf_demo') show() - This SF.net em
[matplotlib-devel] STIX fonts
Mike, John, I sent an inquiry to stixfonts based on http://www.stixfonts.org/swdev_geninfo.html#; I will let you know if they come back with anything. It does look like a genuine release is in sight. But are these fonts all based on Roman style, with serifs, correct? That seems unfortunate; I think that for most plotting purposes, sans-serif works better. Eric - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] STIX fonts
On Wednesday 11 July 2007 05:50:19 pm Eric Firing wrote: > Mike, John, > > I sent an inquiry to stixfonts based on > http://www.stixfonts.org/swdev_geninfo.html#; I will let you know if > they come back with anything. It does look like a genuine release is in > sight. But are these fonts all based on Roman style, with serifs, > correct? That seems unfortunate; I think that for most plotting > purposes, sans-serif works better. I thought they were going to include both serifs and sans-serifs, but I might be wrong. I'm on the list to receive the beta package when it is available, which could be any day now. Darren - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] STIX fonts
On 7/11/07, Darren Dale <[EMAIL PROTECTED]> wrote: > I thought they were going to include both serifs and sans-serifs, but I might > be wrong. I'm on the list to receive the beta package when it is available, > which could be any day now. Definitely within 6 months, heh JDH - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel