Derma being effected by held weapon

Howdy,

I’m making a fairly detailed GUI using derma for an entity. I use a loop to spit out a bunch of image buttons on the screen, and to label them. However, if you are holding a weapon from the customizable weaponry pack, the labels shift to the left strangely.

Here’s an idea of what I’m doing:


	
	for k, v in ipairs(attachTable) do
			if k == i then
				local w = surface.GetTextSize(v)
				local DLabel = vgui.Create( "DLabel", ListItem )
				DLabel:SetPos(  128/2 - w/2, ListItem.y + 108 )
				DLabel:SetText( v )
				DLabel:SizeToContents()
			end
		end


Now I know that the pack is probably causing some kind of black-magics interference, but I can’t really figure out a workaround. It appears to move them left a specific amount, but I can’t figure out how to compare


DLabel:GetPos() with (x , y)

or something similar.

Any help, as always, is greatly appreciated!

Somewhere before calling local w = surface.GetTextSize(v) you are calling surface.SetFont(“the font you are using”) right? Because if you don’t it will calculate based on the last font used by the surface library.

Yes, of course, silly.

[editline]14th December 2013[/editline]

Actually, thanks for pointing that out, I did a doubletake at my code, and I actually didn’t define the font for that DLabel. Thank you very much!