Font Machine Aligned Text (Multi Line)
Monkey Forums/Monkey Code/Font Machine Aligned Text (Multi Line)| 
 | ||
| Hi all, I could not find a way to center or right align multi line text in font machine (I wanted each line to be centered - Not as an entire block). So I coded one :) Align Values: 0 = LeftAlign 1 = Centered 2 = RightAlign 
Function DrawAlignedText(Font:BitmapFont, X, Y, Text:String, Align = 0)
	Local YY = Y
	For Local line:String = EachIn Text.Split("~n")
		Local XX = X
		If Align = 1 Then XX = XX + ( (Font.GetTxtWidth(Text) - Font.GetTxtWidth(line)) / 2)
		If Align = 2 Then XX = XX + Font.GetTxtWidth(Text) - Font.GetTxtWidth(line)
		Font.DrawText(line, XX, YY)
		YY = YY + Font.GetTxtHeight(line)
	Next
End Function
I know this is prety basic, but I hope it helps someone |