devongovett/pdfkit — pull request #309 by ef4 (2014-09-12 20:44:07+00:00)
Title: Infinite loop when first word is longer than line

It's possible to trigger an infinite loop if the first words in a string are too long for the line. We end up trying to use `@spaceLeft` before it's initialized, which then causes us to break off too big a piece of the word, which causes `@spaceLeft` to go negative, which makes this loop run forever:

````coffeescript
while w > @spaceLeft
w = @wordWidth word.slice(0, --l)
````

To see the bug try running:

doc.text("COMPRESSION STOCKINGS KNEE-HIGH", {width: 64});