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

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to