craftyjs/Crafty — pull request #620 by starwed (2013-11-15 22:53:31+00:00)
Title: Make "Text" work better with canvas

This is based on @kcaze's patch #499.

The major change is that a "Canvas, Text" entity will automatically resize when either its font or text are changed.
This is accomplished by using measureText() to get the width, and estimating the font size in pixels for the height.
Currently the width is adjusted *after* drawing, and the height not at all. This often caused the text to be rendered with portions cut-off.

Text is now also drawn at the (x,y) coordinate of the entity, with the baseline set to "top". Previously text was translated to the bottom left corner of the entity, resulting in descenders getting cut-off.

Tests were added for the new resizing feature.