Font issues

Hi John,

I'm trying to finish off the basic features of the font manager module, so we can get the next release out. I'm currently working on the fonts_demo.py example, which has brought to light some deficiencies in the basic implementation of font_manager. I would like to get your opinion on the following issues:

1. Currently, the relative font size strings ('smaller' and 'larger') are not implemented. This is because these sizes depend on the parent font size: a feature which is not yet implemented. Note that the font_manager only has a default_size, which is used by the absolute font size strings (xx-small, x-small, small, medium, etc.).

For this to work, it would seem that each FontProperties instance would need a pointer to its parent FontProperties instance. When get_size_in_points() is called, it would asks its parent font what size it is in order to determine its absolute size. If the parent is also a relative size, then the parent would ask its parent what size it is, etc. This would handle the case where set_size() is called twice using a relative font size.

What do you think of this approach? It has its problems, mainly with the possibility of circular references, but checks for such situations could be added in later. If this feature (of relative font sizes) isn't that important, then we could defer it until after the release.

2. The above problem has also highlighted an issue with the current font manager design. Currently, the fontManager class has attributes of default_size and default_weight that are set at initialization. If we pulled these attributes out of the class and replaced them with a default FontProperties instance, then this instance could be used as the root parent FontProperties instance. What do you think?

Also, since there is often only one instance of the fontManager class, this class could be eliminated and be replace with some initialization code and a findfont() function, unless you think that several instances of this class might be used in future versions of matplotlib.

3. Finally, Perry and I were discussing how one might use Traits in matplotlib. The Traits module is being used in the Chaco plotting package for checking the type and value of class attributes, such as the color and size of fonts or the color and width of lines. (See the Chaco page at the ScyPy web site for an overview.) It would appear that matplotlib's rcParams has a similar purpose, though on a more limited scale than Traits. I think it should still be possible to have the matplotlibrc file for customization, and to feed this information to the Traits module on start up. Traits may not be able to handle the link attribute problem discussed above, but this can probably be implemented separately if necessary.

Note that all these issues are not critical and could be deferred until after the release.

Cheers,
Paul

ยทยทยท

--
Paul Barrett, PhD Space Telescope Science Institute
Phone: 410-338-4475 ESS/Science Software Branch
FAX: 410-338-4767 Baltimore, MD 21218