Revision: 6149 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6149&view=rev Author: jouni Date: 2008-10-05 10:02:16 +0000 (Sun, 05 Oct 2008)
Log Message: ----------- Fix problem with AFM files that don't specify the font's full name or family name Modified Paths: -------------- branches/v0_91_maint/API_CHANGES branches/v0_91_maint/CHANGELOG branches/v0_91_maint/lib/matplotlib/afm.py Modified: branches/v0_91_maint/API_CHANGES =================================================================== --- branches/v0_91_maint/API_CHANGES 2008-10-05 04:32:52 UTC (rev 6148) +++ branches/v0_91_maint/API_CHANGES 2008-10-05 10:02:16 UTC (rev 6149) @@ -1,3 +1,8 @@ + AFM.get_fullname() and get_familyname() no longer raise an + exception if the AFM file does not specify these optional + attributes, but returns a guess based on the required FontName + attribute. + Deprecated all mlab2 functions in mlab matplotlib.image.imread now no longer always returns RGBA -- if Modified: branches/v0_91_maint/CHANGELOG =================================================================== --- branches/v0_91_maint/CHANGELOG 2008-10-05 04:32:52 UTC (rev 6148) +++ branches/v0_91_maint/CHANGELOG 2008-10-05 10:02:16 UTC (rev 6149) @@ -1,3 +1,6 @@ +2008-10-05 Fix problem with AFM files that don't specify the font's + full name or family name. - JKS + 2008-09-11 Fix use of backticks in PS - MGD 2008-09-07 Changed full arrows slightly to avoid an xpdf rendering Modified: branches/v0_91_maint/lib/matplotlib/afm.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/afm.py 2008-10-05 04:32:52 UTC (rev 6148) +++ branches/v0_91_maint/lib/matplotlib/afm.py 2008-10-05 10:02:16 UTC (rev 6149) @@ -34,7 +34,7 @@ John D. Hunter <[EMAIL PROTECTED]> """ -import sys, os +import sys, os, re from _mathtext_data import uni2type1 #Convert string the a python type @@ -433,12 +433,22 @@ def get_fullname(self): "Return the font full name, eg, Times-Roman" - return self._header['FullName'] + name = self._header.get('FullName') + if name is None: # use FontName as a substitute + name = self._header['FontName'] + return name def get_familyname(self): "Return the font family name, eg, Times" - return self._header['FamilyName'] + name = self._header.get('FamilyName') + if name is not None: + return name + # FamilyName not specified so we'll make a guess + name = self.get_fullname() + extras = r'(?i)([ -](regular|plain|italic|oblique|bold|semibold|light|ultralight|extra|condensed))+$' + return re.sub(extras, '', name) + def get_weight(self): "Return the font weight, eg, 'Bold' or 'Roman'" return self._header['Weight'] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins