Function that returns a Formatoption class for modifying the fontsite

    This function returns a :class:`~psyplot.plotter.Formatoption` instance
    that modifies the size of the given `base` formatoption

    Parameters
    ----------
    %(label_weight.parameters)s
    children: list of str
        The childrens of the resulting formatoption class (besides the `base`
        formatoption, the ``base.key + 'size'`` and ``base.key + 'weight'``
        keys, which are included anyway (see :func:`label_size`,
        :func:`label_weight`))
    parents: list of str
        The parents of the resulting formatoption class

    Returns
    -------
    Formatoption
        The formatoption instance that modifies the fontsize of `base`

    See Also
    --------
    label_weight, label_props, Figtitle, Title

def label_props(base, label_name=None, children=[], parents=[],
                dependencies=[]):
    """
    Function that returns a Formatoption class for modifying the fontsite

    This function returns a :class:`~psyplot.plotter.Formatoption` instance
    that modifies the size of the given `base` formatoption

    Parameters
    ----------
    %(label_weight.parameters)s
    children: list of str
        The childrens of the resulting formatoption class (besides the `base`
        formatoption, the ``base.key + 'size'`` and ``base.key + 'weight'``
        keys, which are included anyway (see :func:`label_size`,
        :func:`label_weight`))
    parents: list of str
        The parents of the resulting formatoption class

    Returns
    -------
    Formatoption
        The formatoption instance that modifies the fontsize of `base`

    See Also
    --------
    label_weight, label_props, Figtitle, Title"""
    label_name = label_name or base.key
    cl_children = children
    cl_parents = parents
    cl_dependencies = dependencies

    class LabelProps(Formatoption):
        __doc__ = """
        Properties of the %s

        Specify the font properties of the figure title manually.

        Possible types
        --------------
        dict
            Items may be any valid text property

        See Also
        --------
        %s, %s, %s""" % (label_name, base.key, base.key + 'size',
                         base.key + 'weight')
        children = [base.key, base.key + 'size', base.key + 'weight'] + \
            cl_children
        parents = cl_parents
        dependencies = cl_dependencies

        group = 'labels'

        name = 'Font properties of ' + (base.name or base.key)

        def __init__(self, *args, **kwargs):
            super(LabelProps, self).__init__(*args, **kwargs)
            self.default_props = {}
            self._todefault = False

        def set_value(self, value, validate=True, todefault=False):
            self._todefault = todefault
            super(LabelProps, self).set_value(value, validate, todefault)

        def update(self, fontprops):
            fontprops = fontprops.copy()
            # store default font properties
            try:
                text = next(iter(getattr(self, base.key).texts))
            except StopIteration:
                return
            # TODO: This handling of the default management is not really
            # satisfying because you run into troubles when using alternate
            # property names (e.g. if you use 'ha' and 'horizontalalignment'
            # at the same time)
            if not self._todefault:
                for key in fontprops:
                    if key == 'bbox':
                        default = dict(facecolor='none', edgecolor='none')
                    else:
                        default = getattr(text, 'get_' + key)()
                    self.default_props.setdefault(key, default)
            else:
                fontprops = self.default_props.copy()
                self.default_props.clear()
            if 'size' not in fontprops and 'fontsize' not in fontprops:
                fontprops['size'] = getattr(self, base.key + 'size').value
            if 'weight' not in fontprops and 'fontweight' not in fontprops:
                fontprops['weight'] = getattr(self, base.key + 'weight').value
            for text in getattr(self, base.key).texts:
                text.update(fontprops)
            self._todefault = False

        def get_fmt_widget(self, parent, project):
            """Get a widget with the different font weights"""
            from psy_simple.widgets.texts import FontPropertiesWidget
            return FontPropertiesWidget(
                parent, self, next(iter(getattr(self, base.key).texts), None),
                base)

    return LabelProps(base.key + 'props')