Wrapping text in draw.DrawText in cam2d3d

Hello all;

I want to make a textscreen, Easy, but I have an issue.
If the text on the first line get’s too long then it will pop out the screen.

What I want to do is when the first line of words get too long, the words which fell out get moved to the second line, and with the second line the same. And with all the other lines, how can I do this?

Is 3d derma better to use instead?


Use this http://wiki.garrysmod.com/page/markup/Parse


[editline]12th July 2014[/editline]


surface.CreateFont( “Sfont”, {
font = “Arial”,
size = 100,
weight = 10000,
blursize = 0,
scanlines = 0,
antialias = true
} )

local parsed = markup.Parse( “<font=Sfont>Here is a long text which should be nicely parsed trough several lines.</font>” )

function ENT:Draw()

local DrawPos = self:LocalToWorld(Vector(5.99, -28, 36))

local DrawAngles = self:GetAngles()
DrawAngles:RotateAroundAxis(self:GetAngles():Forward(), 90)
DrawAngles:RotateAroundAxis(self:GetAngles():Up(), 90)

cam.Start3D2D(DrawPos, DrawAngles, 0.05)
	draw.RoundedBox(0, 0, 0, 1150, 700, Color(0,0,0,255))
	parsed:Draw( 10, 60, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )


How does it work?

Try using a DLabel with a fixed with DLabel.SetWrap(true).

Is there no way with the draw function?

You will have to do the wrapping manually.

How could I make that possible?

By manually checking the whole string for overflow and rendering another string if there is any overflow.

second parameter is width, tune it.