Numerous fixes for text rendering and bugfixes

Fixed text rendering and positioning; optimized positioning to avoid
full bound box calculation when possible