Rounded Box 3D2D bug?

Hey, I got this bug on the server.

When I open the chatbox, or similar. This rounded box in the code suddently expand drasticly or contract.
Is this some sort of 3D2D bug? Is there a way to fix this?

Code:
[lua]
surface.CreateFont ( “Trebuchet20”, 20, 400, true, false, “ClearFont”, false )
function ChamberLevelText()
cam.Start3D2D( Vector(581.5540, 975.4841, -1769.0890), Angle(0, 0, 90), 0.5 )
local w, h = surface.GetTextSize(“Security Clearance
Level 01”)
draw.RoundedBox( 6, -(w/2), 0, w+1, h-10, Color( 0,0,0,255 ) )
draw.DrawText(“Security Clearance
Level 01”, “ClearFont”, 0, 0, Color(226, 40, 40, 255), TEXT_ALIGN_CENTER )
cam.End3D2D()

cam.Start3D2D( Vector(-2151.3926, -569.7755, -1596.7091), Angle(0, 270, 90), 0.5 )
	local w, h = surface.GetTextSize("Security Clearance

Level 03")
draw.RoundedBox( 6, -(w/2), 0, w+1, h+2, Color( 0,0,0,255 ) )
draw.DrawText(“Security Clearance
Level 03”, “ClearFont”, 0, 0, Color(226, 40, 40, 255), TEXT_ALIGN_CENTER )
cam.End3D2D()

end
hook.Add(“PostDrawOpaqueRenderables”, “ChamberLevelText”, ChamberLevelText )
[/lua]

I assume it has to do with the alpha multiplicator or something.

You have to set the font before you check the size of the font, otherwise it’ll use whatever font is set. In this case, when you open the chat, it uses the chat’s surface.SetFont.

Try this:
[lua]
surface.CreateFont ( “Trebuchet20”, 20, 400, true, false, “ClearFont”, false )
function ChamberLevelText()
cam.Start3D2D( Vector(581.5540, 975.4841, -1769.0890), Angle(0, 0, 90), 0.5 )
surface.SetFont(“ClearFont”)
local w, h = surface.GetTextSize(“Security Clearance
Level 01”)
draw.RoundedBox( 6, -(w/2), 0, w+1, h-10, Color( 0,0,0,255 ) )
draw.DrawText(“Security Clearance
Level 01”, “ClearFont”, 0, 0, Color(226, 40, 40, 255), TEXT_ALIGN_CENTER )
cam.End3D2D()

cam.Start3D2D( Vector(-2151.3926, -569.7755, -1596.7091), Angle(0, 270, 90), 0.5 )
    surface.SetFont("ClearFont")
    local w, h = surface.GetTextSize("Security Clearance

Level 03")
draw.RoundedBox( 6, -(w/2), 0, w+1, h+2, Color( 0,0,0,255 ) )
draw.DrawText(“Security Clearance
Level 03”, “ClearFont”, 0, 0, Color(226, 40, 40, 255), TEXT_ALIGN_CENTER )
cam.End3D2D()

end
hook.Add(“PostDrawOpaqueRenderables”, “ChamberLevelText”, ChamberLevelText )
[/lua]