@classmethod
def newString(cls, s, context, e=None, style=None, w=None, h=None, **kwargs):
    """Answers a FlatString instance from valid attributes in *style*. Sets
        all values after testing their existence so they can inherit from
        previous style formats. If target width *w* or height *h* is defined,
        then *fontSize* is scaled to make the string fit *w* or *h*.

        * FIXME: implement pixelFit for Flat.
        * TODO: implement GSUB feature compile in Flat; make the transformed
        string using Tal's Compositor::

            https://github.com/typesupply/compositor

        >>> from pagebot.toolbox.units import pt
        >>> from pagebot import getContext
        >>> context = getContext('Flat')
        >>> bs = context.newString('AAA', style=dict(fontSize=pt(30)))
        >>> str(bs) == 'AAA'
        True
        """
    assert isinstance(s, str)
    if style is None:
        style = {}
    else:
        assert isinstance(style, dict)
    s = cls.addCaseToString(s, e, style)
    style = cls.getStringAttributes(s, e=e, style=style, w=w, h=h)
    return cls(s, context=context, style=style)
