Creates a new BabelString instance from `bs` (converted to plain unicode string), using style as typographic parameters or `e` as cascading style source. Ignore and just answer `bs` if it is already a BabelString instance and no style is forced. PageBot function. >>
(self, bs=None, style=None, w=None, h=None)
| 987 | # String. |
| 988 | |
| 989 | def newString(self, bs=None, style=None, w=None, h=None): |
| 990 | """Creates a new BabelString instance from `bs` (converted to plain |
| 991 | unicode string), using style as typographic parameters or `e` as |
| 992 | cascading style source. Ignore and just answer `bs` if it is already a |
| 993 | BabelString instance and no style is forced. PageBot function. |
| 994 | |
| 995 | >>> from pagebot.toolbox.units import pt |
| 996 | >>> from pagebot.contexts import getContext |
| 997 | >>> context = getContext() |
| 998 | >>> bs = context.newString('ABCD', dict(fontSize=pt(12))) |
| 999 | >>> bs, bs.__class__.__name__ |
| 1000 | ($ABCD$, 'BabelString') |
| 1001 | """ |
| 1002 | style = makeStyle(style=style) |
| 1003 | if not bs: |
| 1004 | bs = '' |
| 1005 | if not isinstance(bs, BabelString): |
| 1006 | # Otherwise convert bs into a BabelString, from whatever it is now. |
| 1007 | # Set the babelString.context as self. |
| 1008 | bs = BabelString(bs, style=style, w=w, h=h, context=self) |
| 1009 | assert isinstance(bs, BabelString) |
| 1010 | return bs |
| 1011 | |
| 1012 | def newBulletString(self, bullet, style=None): |
| 1013 | return self.newString(bullet, style=style) |
no test coverage detected