Why doesn't Font.getHeight() work the same as Font.getWidth()?
Posted: Fri Apr 16, 2021 2:40 pm
Hello,
I just posted my first ever project in the Games and Creations forum, and I have many novice questions, but this was perhaps the major annoyance of my first project.
Font.getWidth(string) gives you the width of the string, taking embedded newlines into account.
Font.getHeight() doesn't take a string, and will only ever give you the height of one line. (Or, as I have seen in several examples, people think it takes a string and expect it to work like getWidth, but it doesn't.)
Why? Surely the logic is pretty much the same as it would be for getWidth()? In fact, it seems to be abnormally difficult to work out the print height - there's no way of getting it out of printf either, which makes printf much less useful than it could be.
It just seems like a trivial but incredibly useful change.
I guess I'm supposed to use Text now, but that seems kind of heavyweight for the context, and seems to involve rewriting all the code that nearly works, and would work with this small change. I admit I haven't really looked at Text yet. My project was a bit rushed.
I just posted my first ever project in the Games and Creations forum, and I have many novice questions, but this was perhaps the major annoyance of my first project.
Font.getWidth(string) gives you the width of the string, taking embedded newlines into account.
Font.getHeight() doesn't take a string, and will only ever give you the height of one line. (Or, as I have seen in several examples, people think it takes a string and expect it to work like getWidth, but it doesn't.)
Why? Surely the logic is pretty much the same as it would be for getWidth()? In fact, it seems to be abnormally difficult to work out the print height - there's no way of getting it out of printf either, which makes printf much less useful than it could be.
It just seems like a trivial but incredibly useful change.
I guess I'm supposed to use Text now, but that seems kind of heavyweight for the context, and seems to involve rewriting all the code that nearly works, and would work with this small change. I admit I haven't really looked at Text yet. My project was a bit rushed.