Fix an infinite loop in text rendering