>>
>>You can calculate the size of the word when rendered in a specified font using:
>>
>>FONTMETRIC(6,"<font name>",<font size>, <font style>) * TXTWIDTH("<text string>","<font name>",<font size>, <font style>)
>>
>
>Hi Paul,
>
>I thought that was what I was doing with the len() / len(), and then setting the width * (len() / len()).
Not quite. The problem is that most of the fonts you use today are proportional width. That means that a W is a fair bit wider than an I. Changing the width of the label based on the ratio of the number of letters assumes that the average width of the letters in each string are the same. As you have observed, sometimes they are not.
The code above combines two VFP functions to get the actual size of the text string as rendered in a given font.
FONTMETRIC(6,...) returns the average character width of characters in the specified font.
TXTWIDTH() returns the length of a given string in "average font widths".
Taken together, this will give you a much more accurate pixel size to render a string.