Imperfect, but workable, implementation for calculating the width based on preferred width.