SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] hashing of FontProperties

From: Jae-Joon L. <lee...@gm...> - 2009年02月28日 22:44:01
The following code show how the FontProperties is currently hashed.
 def __hash__(self):
 l = self.__dict__.items()
 l.sort()
 return hash(repr(l))
The hash does not account user's rcParams setting. And due to the font
caching, findfont(FontProperties()) returns the same font even if user
changes the rcParams["font.family"] and other parameters.
So, I propose to change it to something like below.
 def __hash__(self):
 l = [(k, getattr(self, "get" + k)()) for k in self.__dict__]
 return hash(repr(l))
The other change I want to make is the behavior of the findfont(None).
As of now, it returns "fontManager.defaultFont" which is set when
fontManager is initialized. Therefore, it returns same font even if
user change the rcParams. I prefer to have "findfont(None) ==
findfont(FontProperties())".
Unless others object, I'll commit the changes to the trunk.
Regards,
-JJ

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /