Forum

Get width of a String

Is there a reliable way to get the pixel width of a String for a given font? The dx9 text node’s sizeXY output has a few quirks which heavily limit its use:

  • ignores white-space at the end of the String
  • doesn’t update when input is a String with length = 0
  • only works when connected to a renderer

maybe glyphinfo ?

There are no such heavy limitations, beside the renderer one, which cannot be in Alt + 3 mode. Also, if you find an empty string, you could feed a space. You’ll end having zero length anyway. Quick patch, review it.

forTidensBarn.v4p (15.9 kB)

Ah yes, this will do. Thanks.