In the C# DrawString method Horizontal Alignment appears to have no effect

Godot Version

4.2.1

Question

Script is being written in C#. Text is rendered to a control node using DrawString. Properties of Drawstring include Horizontal alignment. I have set Horizontal alignment to center and also tried setting it to left and both result in the same result. The text is always left aligned. Is this a bug or am I missing something?

                this.DrawString(CompassLabelsFont,
                labelPos, _dialLabelsTxt[n],
                alignment: HorizontalAlignment.Center,
                width: -1, fontSize: CompassLabelsFontSize,
                modulate: null,
                justificationFlags: TextServer.JustificationFlag.None,
                orientation: TextServer.Orientation.Horizontal);

You need to give it a width for the horizontal alignment to work or it will always use the smallest value that fits the string

1 Like