fix handling of text scaling

Fixes #179.  This patch is very much along the lines outlined in
comments on the ticket.  There will be accompanying patches to backends, so maybe we should wait to merge until we have all the backend fixes in place.