I downloaded DejaVu Sans and pointed to that ttf file, and no love :(...
Again, the default font seems to work for English, French, German, Spanish,
Italian other Euros etal... but Chinese and Arabic either come out blank
(default font, DejaVu Sans) or choke on the glyphs (MS Unicode).
MJ
From: Michael Droettboom [mailto:md...@stsci.edu]
Sent: Tuesday, February 07, 2012 6:56 AM
To: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] rendering unicode using the PDF backend
It looks like perhaps we'll need to "synthesize" glyph names if they aren't
provided in the font (though it's not clear to me why they are not). This will
be difficult to test for, as that's a proprietary font. Have you tried using
another Unicode font, such as DejaVu Sans?
Mike
On 02/06/2012 06:53 PM, Mark Janikas wrote:
Hi All,
I am having trouble rendering my Unicode strings in matplotlib using the PDF
backend. When I use certain fonts (like the Win 7 default), I get no
complaints but the characters are not rendered.... When I use a font like Arial
Unicode MS, that I know contains all the chars, then I get the error message
below. I did in fact, find a tty file that would work with Chinese ("Microsoft
YaHei"), but I would like to avoid trying to map font files to languages. Any
info on this subject would be greatly appreciated. Here is a snippet that
reproduces the error below... if you remove the fontproperties option to the
PYLAB.xlabel() call then the error is avoided but the result is not rendered.
Thanks so much!
MJ
import matplotlib.pyplot as PLT
import pylab as PYLAB
from matplotlib.backends.backend_pdf import PdfPages as PDF
import matplotlib.font_manager as fm
fontFile = r'C:\Windows\Fonts\ARIALUNI.TTF'
fp1 = fm.FontProperties(fname=fontFile)
reportFile = r'C:\Temp\TestUnicode.pdf'
pdfOutput = PDF(reportFile)
vals = range(100)
PLT.plot(vals, vals, color = "r", linestyle = "-")
mess = u'\u6B63\u5728\u8BFB\u53D6\u6570\u636E...'
PYLAB.xlabel(mess, fontproperties = fp1)
PLT.savefig(pdfOutput, format='pdf')
PLT.close()
pdfOutput.close()
Traceback (most recent call last):
File "C:\Data\CRs\10.1\MemLeak\matplotlib\Scripts\matplotlib_unicode.py",
line 27, in <module>
PLT.savefig(pdfOutput, format='pdf')
File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 472, in
savefig
return fig.savefig(*args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 1173, in
savefig
self.canvas.print_figure(*args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\backend_bases.py", line 2027,
in print_figure
**kwargs)
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line
2181, in print_pdf
self.figure.draw(renderer)
File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 886, in draw
func(*args)
File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1983, in draw
a.draw(renderer)
File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\axis.py", line 1054, in draw
self.label.draw(renderer)
File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "C:\Python27\lib\site-packages\matplotlib\text.py", line 587, in draw
ismath=ismath)
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line
1784, in draw_text
return draw_text_woven(chunks)
File "C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.py", line
1754, in draw_text_woven
glyph_name = font.get_glyph_name(gind)
RuntimeError: Face has no glyph names
PS. I cannot use a different backend.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net<mailto:Matplotlib-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users