speed optimizations for text drawing