Problem with fonts

Hey guys, I’m trying to change a font for some text contained in a DLabel. However I’m having no luck.

I defined the font in the same file beforehand by doing:


surface.CreateFont( "fontone", {font = "ChatFont", size = 20, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = true, additive = false, outline = false } )

Then in the DLabel I did,


myLabel:SetFont("fontone")
myLabel:SetText("blahblah")

It just changes to the default font (Ariel I think); however if I change the size of the predefined font it changed it in the DLabel, this confirms its actually using the font.

Thanks in advance.

I assume you are doing something wrong in a bigger context, please post the whole code.


surface.CreateFont( "crazy", { font = "BudgetLabel", size = 20, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false , italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false } )
 
 

local rules = vgui.Create("DLabel", Rulestab)
rules:SetPos(5,75)
rules:SetColor(Color(255,255,255,255))
rules:SetFont("crazy")
rules:SetPos(5,75)
rules:SetText("blah ")
 
rules:SizeToContents()
 
                       
        end
        Rulestab:Update()
        return Rulestab
end

I never hear of BudgetLable so make sure you have it on your PC. If it’s custom then make sure is located in resources/fonts/
If it exist in gmod then I have no idea. But also if you use a custom one restart the server.

[editline]4th June 2013[/editline]

And the surface.CreateFont has to be outside the function.

“Outside of the function” it already is in the main scope that’s fine.

I’m more concerned about the fact that BudgetLabel is not an actual system font but one that is created by the game.

[editline]4th June 2013[/editline]

resource/ClientScheme.res

line 345 to 354



BudgetLabel
		{
			"1"
			{
				"name"		"Courier New"
				"tall"		"14"
				"weight"	"400"
				"outline"	"1"
			}
		}


Can you supply me with a list of fonts I can actually use?

resource/ClientScheme.res

Thanks, I’ve solved the issue. I appreciate the help.

However I’m bumping into another problem, I’d like to include a Derma object (a DProgressBar) to be specific into the HUD. I’d like to object to be seen but not interacted with, so the user can play normally but have this derma object in the top right of their screen.

Any way to do this?

First of all don’t put the DProgressBar in to the function because it will lag, put it outside and add a hook to it and to change the position where is
[lua]
SetPos(10,ScrH()-75)
[/lua]