On Wednesday 22 August 2007 03:09:30 pm Michael Droettboom wrote: > This was an attempt to do a direct translation from what I had in the > "classic" rcsetup.py. (The previous version in mplconfig.py was > semantically incorrect.) I had tested this with settings in my > matplotlib.conf, but didn't realise that the default wasn't validated > (and thus not interpreted into a FontPropertiesProxy object). > > Darren Dale wrote: > > I am trying to work out some way to make rcdefaults() work with the > > traited config. Along the way, I discovered this in mplconfig: > > > > class mathtext(TConfig): > > cal = T.Trait("['cursive']", mplT.FontPropertiesHandler()) > > rm = T.Trait("['serif']", mplT.FontPropertiesHandler()) > > tt = T.Trait("['monospace']", mplT.FontPropertiesHandler()) > > it = T.Trait("['serif'], style='oblique'", > > mplT.FontPropertiesHandler()) > > bf = T.Trait("['serif'], weight='bold'", > > mplT.FontPropertiesHandler()) sf = T.Trait("['sans-serif']", > > mplT.FontPropertiesHandler()) use_cm = T.true > > fallback_to_cm = T.true > > > > I dont think that will work. One of the highlights of the new config > > files is that when a file says: > > > > [mathtext] > > rm = ['serif', 'sans-serif'] > > > > you actually get a list, not a string, to pass to > > mplT.FontPropertiesHandler(). > > Right. But it works like: > > rm = "['serif', 'sans-serif']" > > I realize it's hacky. The most obvious alternative is to expect a > dictionary here, e.g.: > > rm = { 'family': ['serif'], 'style': 'oblique' } > > But that's less like the FontProperties constructor.
Why do you say that? Here is the constructor: def __init__(self, family = None, style = None, variant= None, weight = None, stretch= None, size = None, fname = None, ): wouldnt FontProperties(**rm) work? > My goal was to > make specifying fonts as similar as possible to the FontProperties > object so the user doesn't have to learn a new syntax. Is there a > better way to do this with Traits? Can the user specify the arguments > (with keyword arguments) to a constructor? I think this is getting a little out of hand, isnt it?: #mathtext.cal : ['cursive'] #mathtext.rm : ['serif'] #mathtext.tt : ['monospace'] #mathtext.it : ['serif'], style='oblique' #mathtext.bf : ['serif'], weight='bold' #mathtext.sf : ['sans-serif'] That means we have comma-separated strings for lists of fonts, but bracket-enclosed comma-separated quoted strings for mathtext properties. If you want all that flexibility, why not do it in the usual way: #mathtext.it.family : 'serif' #mathtext.it.style : 'oblique' But is that much flexibility needed? Darren ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel