Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

font_manager.py UnicodeDecodeError when starting ipython --pylab #2307

Merged
merged 2 commits into from Aug 27, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Aug 26, 2013

I'm experiencing a UnicodeDecodeError when starting ipython --pylab.
System: Debian Sid
$apt-cache policy python-matplotlib
python-matplotlib:
Installed: 1.3.0-1

This seems to be caused by on of the font name containing non-ascii characters. The font causing the issues seems to be " Systematic TT BRK" from the ttf-aenigma package in debian sid. Error message below:

/usr/lib/pymodules/python2.7/matplotlib/font_manager.py in ttfFontProperty(font)
396 sfnt2 = ''
397 if sfnt4:
--> 398 sfnt4 = sfnt4.decode('ascii').lower()
399 else:
400 sfnt4 = ''

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc6 in position 0: ordinal
not in range(128)

@cycomanic
Copy link
Author

Seems this can be fixed by changing line 398 from
sfnt4 = sfnt4.decode('ascii').lower()
to
sfnt4 = sfnt4.decode('ascii', 'ignore').lower()

however I'm not sure if this results in any side effects.

@ghost ghost assigned mdboom Aug 26, 2013
@mdboom
Copy link
Member

mdboom commented Aug 26, 2013

@cycomanic: Can you confirm this patch resolves your issue?

This may also fix #2320.

@mdboom
Copy link
Member

mdboom commented Aug 26, 2013

Thanks -- it was helpful to know the problematic font. It contains a non-ascii character as its name -- according to this (http://www.freetype.org/freetype2/docs/reference/ft2-truetype_tables.html#TT_MAC_ID_XXX), that entry is supposed to be "macroman" and not "ascii", so I've updated matplotlib to reflect that.

@cycomanic
Copy link
Author

I will try later tonight.

Cheers
Jochen

On 27/08/13 04:26, Michael Droettboom wrote:

@cycomanic: Can you confirm this patch resolves your issue?

This may also fix #2320.


Reply to this email directly or view it on GitHub:
#2307 (comment)

@megies
Copy link
Contributor

megies commented Aug 27, 2013

👍 Tried it, works! (See #2320 (comment))

mdboom added a commit that referenced this pull request Aug 27, 2013
font_manager.py UnicodeDecodeError when starting ipython --pylab
@mdboom mdboom merged commit ffb3746 into matplotlib:v1.3.x Aug 27, 2013
@mjanikas
Copy link

I am having the same issue where my software package employs matplotlib1.3.0. We are almost about to release and I was hoping that you could confirm that in fact, the ONLY change needed to fix this issue is the movement of 'ascii' to 'macroman' in those two locations in font_manager.py.

BTW, we have a ton of harness tests across a myriad of languages and this solution had worked for us in regards to fixing the traceback. I am just being extra cautious. Thanks for the heads up ahead of time.
Cheers,

MJ

@mdboom mdboom deleted the font-name-decoding branch August 7, 2014 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants