Fix text measurement logic, and inherit label attributes properly.