SUGGESTION: String.Width() and String.Height()

Started by monkey0506, Sat 08/04/2006 14:33:13

Previous topic - Next topic

monkey0506

Here lately I've been working with the function GetTextWidth(const string text, int font), and I've been thinking...wouldn't it make more sense if there was some sort of function like String.Width(int font) to handle this?

Of course this would mean the text would have to be stored into a String, but I don't think that would be such a big deal.

Also, String.Height(int font) could be created to take the place of GetTextHeight(const string text, int font).

Pumaman

Thinking about this logically, I don't believe that it makes sense to have these on the String class. A string is just a way of storing text, it doesn't relate to how that text might be displayed. To be properly OO, it should probably be something like Font.GetStringWidth(string text) or Screen.GetTextWidthWhenRendered(int font, strin text).

Either way, I don't see a compelling reason to change it.

edmundito

Random Ramblings:

If you're talking about the actual letter width and height, then it would have to be related to a Font object, and then of course most characters in a font don't have a fixed width, unless they're have a fixed width (aka monospace). For those properties, it would be Font.GetWidth and Font.GetSize (since most people call it a font size).

But for what we're talking about I would call it Paragraph.GetWidth or Screen.GetParagraphWidth or Screen.GetTextWidth/Height, which is what GetTextWidth/Height is anyway, so why would you change it unless you want to have a Text/Paragraph object? ???

SMF spam blocked by CleanTalk