magicpen
magicpen copied to clipboard
Support soft spacing
This idea is under construction!
I was thinking about an idea where you could insert splitters into your output and magicpen would insert newlines until the line was under the preferred width:
pen.text('Hello').split().text('beautiful').split().text('world');
If you want to control indentation of the split you can do it the following way:
pen.text('Hello').split().block(function () {
this.text('beautiful').split().text('world');
});
Resulting in:
Hello beautiful world
or
Hello beautiful
world
or
Hello
beautiful
world
The optimal solution is of cause exponential, so we need to find a good heuristic.
Damn the idea probably falls because we can't get the size of a pen at any point in time. Back to the drawing board :-S