Posted By: DJBMASTER
Measure String - 01/18/10 07:53
Hi, Can we have a function that returns the size in pixels of a string, rendered using a given font. The width and height should be returned in a vector...
VECTOR* str_pixels(STRING* string, FONT* font).
Of course, if there are any current methods people know, then if you wouldn't mind sharing.
Thanks, David.
Posted By: Quad
Re: Measure String - 01/18/10 09:29
str_width (STRING*, FONT*);
check manual, i am not sure about the height tho.
Posted By: DJBMASTER
Re: Measure String - 01/18/10 10:41
Ahh thanks, missed that somehow. It's strange there isnt a 'str_height'.
Posted By: MrGuest
Re: Measure String - 01/21/10 01:26
hey, font.dy stores the height of the font
unfortunately str_width doesn't seem to be too accurate, and has even more problems when using bold and italic
Posted By: GorNaKosh
Re: Measure String - 01/21/10 05:54
Very nice info, thx! Didn't find the .dy property in the manual anywhere...
Posted By: DJBMASTER
Re: Measure String - 01/22/10 00:29
Does anyone know how I could measure the height/width of the text produced by a 'digits' definition?
Posted By: jcl
Re: Measure String - 01/22/10 09:49
You could simulate the digits text with a str_printf call, and then use str_width the get the pixel-precise width of that text.
Posted By: FBL
Re: Measure String - 01/22/10 10:26
Does anyone know how I could measure the height/width of the text produced by a 'digits' definition?
If you find a nifty solution, would you be willing to share the snippet?
Posted By: DJBMASTER
Re: Measure String - 01/22/10 10:40
The 'str_printf'/'str_width' method that jcl said should work. I'm currently doing this through C#, rather than lite-c, so i'm using a workaround and it works fine.
Posted By: MMike
Re: Measure String - 07/11/10 18:05
str_printf returns a string ? and divide by str_width? :s or you mean "OR" ?