- Local time
- Today, 16:59
- Joined
- Feb 28, 2001
- Messages
- 30,566
Problem: In order to make certain things look a little bit neater and more professional, I'm trying to dynamically resize text boxes on my forms. But the trick isn't doing the resizing, it is know when it is necessary to do so.
Is there some reasonable way to know that a given text string in a given font in a given font-size will take up 1.5 inches (therefore only needing one line in the displayed 2-inch text box) or that it will take up 2.3 inches (therefore needing two lines in the 2-inch text box)?
I am currently using a variable-width format so I can't just compute this width based on the font size times the number of characters. I.e. for Courier New or Lucida Console, which are non-proportional fonts, I could compute text size as font width times string character count. But with proportional fonts, that math doesn't quite work. Lower-case I and L in proportional fonts can get pretty skinny.
Any suggestions?
Is there some reasonable way to know that a given text string in a given font in a given font-size will take up 1.5 inches (therefore only needing one line in the displayed 2-inch text box) or that it will take up 2.3 inches (therefore needing two lines in the 2-inch text box)?
I am currently using a variable-width format so I can't just compute this width based on the font size times the number of characters. I.e. for Courier New or Lucida Console, which are non-proportional fonts, I could compute text size as font width times string character count. But with proportional fonts, that math doesn't quite work. Lower-case I and L in proportional fonts can get pretty skinny.
Any suggestions?