Drawing Strings.

I’m trying to draw a string center justified.

g.DrawString("hello", x, y)

The centering works horizontally, but how do I figure out the height of the text such that I can move the center to half the height of the text?

Checkout StringHeight from the docs.

Since fonts are seldom installed on servers, it is very possible that this won’t work at all once the app is uploaded. I am not even sure DrawString will work for that matter. It works always fine in debug mode since the development machine does have fonts handy.

See https://forum.xojo.com/15834-install-fonts-on-linux-server

There is no StringHeight on WebCanvas as it would require a round trip to the browser to get the value.

[quote=184526:@Brian O’Brien]I’m trying to draw a string center justified.

The centering works horizontally, but how do I figure out the height of the text such that I can move the center to half the height of the text?[/quote]
You can get a reasonable estimate for y by using the text size. Try this:

y = (g.Height + g.FontSize) / 2