[quote=310874:@Norman Palardy]EDIT : As well we’d need to alter the return value to be an array as well in the case it DOES wrap OR return “the maximum” of them all or something since wrapping would make measuring and returning a single width problematic
A change like this would probably break a lot of existing code[/quote]
Erm, I dont think so, you just need to return the wrapped width if a wrap width was set, the condensed width if that was set or the total width if no wrap was specified? If you made the new WrapWidth and Condense params optional I cant see why it would break any code. I cant see why you need to return multiple numbers, you can get the height with StringHeight. Dont worry about it though, you’d need to put an alignment option in there also as just returning a left justified graphics object wouldnt be that flexible.
I don’t want it to return something else I wanted StringWidth to return the widest point of the string if it were wrapped.
The problem is thus:
If you have a button what is 100 pixels wide, you specify a WrapWdith of 100 in DrawString and have two words in the string
aaaaaa bbbbbb
Lets say that the 100 is just short of the end of the b’s
______ ____|_
aaaaaa bbbbbb
This would then wrap the text like this
______ ____|_
aaaaaa
bbbbbb
Now you’re thinking that you have a nice font that will be 100 wide, so you work out your offsets to put that text in the center of your button, oh dear, its all shifted to the left because there’s massive white space on the right of that 100 wide button where the wrap took place.
| ____________________ |
| ______ ____|__ |
| aaaaaa |
| bbbbbb |
| ____________________ |
Now you have no way to work out the “actual” width that the text takes up (the bounding box of the text) because you have no feedback from the that what is happening inside of DrawString.
As I said above, its no biggie, I really just asked because I might have been missing something. I’ll get around to sorting this out with my own routine, I just keep getting sidetracked by other stuff at the moment.
Thanks for the input everyone I’ll mark this as answered as to not waste more of peoples time