magicpen icon indicating copy to clipboard operation
magicpen copied to clipboard

Support soft spacing

Open sunesimonsen opened this issue 9 years ago • 2 comments

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

sunesimonsen avatar Sep 10 '15 20:09 sunesimonsen

The optimal solution is of cause exponential, so we need to find a good heuristic.

sunesimonsen avatar Sep 11 '15 07:09 sunesimonsen

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

sunesimonsen avatar Sep 11 '15 08:09 sunesimonsen