Word-Wrap-It
You can use this library to wrap texts.
Usage
;// L o r e m I p s u m; // character widths for variable font;console.loglines;console.logranges;console.logsizes;
The result will be
[ 'Lor', 'em', 'Ips', 'um' ] // the resulting lines
[
{ start: 0, length: 3 },
{ start: 3, length: 3 },
{ start: 5, length: 4 },
{ start: 9, length: 2 }
] // the actual character ranges
[ 21, 19, 17, 20 ] // the trimmed line widths