Simple way to calculate pixel width of a string?
BlitzMax Forums/BlitzMax Beginners Area/Simple way to calculate pixel width of a string?
| ||
I'm trying to calculate the width of a string with default font. I was thinking of assigning a width value for each characters but I have a question: How to calculate how many of a character you have in a string? Like how many "e" or what not. I tried doing this: Local length:Int = Len text:string width = length*9 hmm or maybe there's an easier way? |
| ||
Width = TextWidth(text) |
| ||
Width = TextWidth(text) Do note that this does not take any scale into consideration, so if you've done a setscale 2,2 then you'll also need to multiply the result of TextWidth with that '2' to get the true width if you were to draw it at that point. |
| ||
for scale: |