borgar / textbox

Library to layout text for display on SVG or Canvas.
Other
26 stars 6 forks source link

measureText should support different whitespace options #23

Open borgar opened 2 years ago

borgar commented 2 years ago

It would be good to have control over whitespace. Today the function assumes that you want "normal" HTML/SVG whitespace handling. But this would be so much more useful if you could control:

  1. Should the text be trimmed.
  2. Should whitespace collapse.

The measuring handlers as also not consistent on this. The string is only normalized for canvas, not for SVG or "dumb". (We should probably remove the SVG handler, there aren't really any environments where SVG exists but not canvas.)

What to do with line breaks then? What input element do: convert all "\n" to " "

borgar commented 2 years ago

Re-opening because there is still some work to be done with exposing this to the outside.