skinner927
04-01-2007, 08:07 PM
I have a problem (obviously)
What I'm trying to do, is cut a string so it fits in the head of an web page.
I'm making an online test, and I want the test name to be displayed, the test name is dynamic because each test has its own name but the area the test name has to be placed in is static.
I don't have a problem chopping up the string, but I'm having a problem knowing how much to chop off.
Whats happening is that I can only have a max of ~20 'W' (meaning 20 W in a row will fill up the area) but I can have over 40 'i' in a row with room left to spare. I set the chopping to chop it off at 20, but the problem is, all titles look stupid because they're so much smaller than the alloted area.
Is there a way to know, possibly in pixels, the length of a string without going thru each individual character to get its pixel with?
Because if the only way is to examine each letter individually, I know how to do that. But if anyone knows another way, other than guessing :p I would appreciate it. Thanks!
What I'm trying to do, is cut a string so it fits in the head of an web page.
I'm making an online test, and I want the test name to be displayed, the test name is dynamic because each test has its own name but the area the test name has to be placed in is static.
I don't have a problem chopping up the string, but I'm having a problem knowing how much to chop off.
Whats happening is that I can only have a max of ~20 'W' (meaning 20 W in a row will fill up the area) but I can have over 40 'i' in a row with room left to spare. I set the chopping to chop it off at 20, but the problem is, all titles look stupid because they're so much smaller than the alloted area.
Is there a way to know, possibly in pixels, the length of a string without going thru each individual character to get its pixel with?
Because if the only way is to examine each letter individually, I know how to do that. But if anyone knows another way, other than guessing :p I would appreciate it. Thanks!