Jouni K. Seppänen <j...@iki.fi> wrote:
> You're right. I committed your patch, but there is another bug that
> makes this a little difficult to test: the font cache doesn't record
> whether it was build with pdf.use14corefonts enabled or not, and the
> font name "Helvetica" happens to match "Helvetica Narrow", whose metrics
> are included with matplotlib, and using that afm file without including
> the font itself breaks the output. I'm too busy with other things to fix
> this now, but patches are welcome. As a workaround, deleting
> ~/.matplotlib/fontList.cache helps if anyone wants to alternate between
> enabling and disabling use14corefonts.

Thanks for committing my patch! I've reproduced the font cache bug on
my machine too. Thanks for your detailed explanation. I've updated the
test case to acknowledge this issue and to set use14corefonts to True
*before* importing pylab (because importimg pylab seems to refresh the
font cache).

Those changes are in the attached patch. It's certainly not a
definitive workaround, but it's better than nothing ;-)

> Unfortunately, this functionality is deprecated in the PDF standard as
> of PDF 1.5, and many publishers require embedding all fonts in PDF
> files. Apparently not all substitutes for the standard fonts are similar
> enough. (The real fonts need to be licensed, so many Linux distributions
> ship with free look-alike substitutes, and who knows what fonts are
> installed on some publisher's systems.)

I'm aware of that deprecation. I agree we'll need to drop that feature
in a not so distant future...

--
Nicolas Grilly
Index: unit/test_pdf_use14corefonts.py
===================================================================
--- unit/test_pdf_use14corefonts.py	(révision 6904)
+++ unit/test_pdf_use14corefonts.py	(copie de travail)
@@ -1,16 +1,29 @@
 # encoding: utf-8
+"""
+Test the PDF backend with the option use14corefonts=True.
 
-import matplotlib
-matplotlib.use('PDF')
+Font cache issue
+----------------
 
+The font cache doesn't record whether it was build with pdf.use14corefonts
+enabled or not, and the font name "Helvetica" happens to match
+"Helvetica Narrow", whose metrics are included with matplotlib, and using that
+AFM file without including the font itself breaks the output.
+
+As a workaroung, please reset the font cache by deleting
+~/.matplotlib/fontList.cache each time you enable or disable use14corefonts.
+"""
+
 from matplotlib import rcParams
-import pylab
 
+rcParams['backend'] = 'pdf'
 rcParams['pdf.use14corefonts'] = True
 rcParams['font.family'] = 'sans-serif'
 rcParams['font.size'] = 8
 rcParams['font.sans-serif'] = ['Helvetica']
 
+import pylab
+
 title = u'Test PDF backend with option use14corefonts=True'
 
 text = u'''A three-line text positioned just above a blue line
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to