Refactored to reuse calculateTextWidth