How to get the height of a string

I am trying to use a canvas to get the height of a string, but all that I get is 0, any ideas why? Have to do with the graphics object being on the sever vs the client?

dim pp as new Picture(me.Width, me.Height, 32) pp.Graphics.TextFont = "Avinir" pp.Graphics.TextSize = 22 dim textHeightViaMethod as integer = pp.Graphics.StringHeight(me.Text, me.Width) dim textHeightViaProperty as double = pp.Graphics.TextHeight

Both textHeightViaMethod and textHeightViaProperty are 0

How might one accomplish finding the height of a wrapped string in a web app?

The Graphics drawing routines on Web rely on the fonts on the server. So your font must be installed there. Even then, chances are the size will be different to what’s actually being rendered by the user’s browser because there’s no guarantee the browser engine draws it the same way your server does.

What are you trying to do with the font height information? The answer to this could significantly change what you actually need to do.

I am trying to make labels responsive. So as screen size changes they can wrap properly and change layout. On smaller screens multi-line labels need to change their height so that other controls can move around them.

That should have absolutely nothing to do with the Graphics class :slight_smile: If you get it working, it will be a costly and unreliable system as the changes have to go all the way to the server, then draw something (which is not a fast process), then respond to the browser.

Responsive design in Xojo Web 1.0 is not easy, I think @Brock Nash has a post for how to do it. To stick within the Xojo framework and make the best app you can, you’ll need completely different pages for Mobile view.

Yeah that has been my experience in the past… I don’t know why I keep trying. For web in general one is better off staying far away from Xojo IMO, but when your paid to work on something you are paid to work on it I guess.