Hi Folks,
I vaguely remember reading somewhere that it was possible to work out the dimensions of text that had been rendered by Printf so I could draw a box around it.
I quick scan of the docs and I didn't see anything.
Anybody know how?
Dimentions of text rendered with Printf
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 3
- Joined: Fri Oct 21, 2022 1:17 am
Re: Dimentions of text rendered with Printf
Not sure if that is what you are asking for but I use Font:getWidth() and Font:getHeight()
https://love2d.org/wiki/Font:getWidth
(you have to define a font first or use https://love2d.org/wiki/love.graphics.getFont)
It's ok for text that doesn't wrap, but if it's displayed on multiple lines I suppose these won't match. I never had to deal with that case so I can't tell really.
https://love2d.org/wiki/Font:getWidth
(you have to define a font first or use https://love2d.org/wiki/love.graphics.getFont)
It's ok for text that doesn't wrap, but if it's displayed on multiple lines I suppose these won't match. I never had to deal with that case so I can't tell really.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Dimentions of text rendered with Printf
You can use Font:getWrap to get the width and number of lines, and then multiply the number of lines with Font:getHeight to get the total height.
-
- Prole
- Posts: 3
- Joined: Fri Oct 21, 2022 1:17 am
Re: Dimentions of text rendered with Printf
Thanks for the tips folks.
Who is online
Users browsing this forum: Bing [Bot] and 15 guests