text width calculation helper