How do I change the font for the code of a hud?

Okay I’ve been attempting to work on a custom District 9 Non-Human themed HUD how would I be able to change the font of everything?

Heres the code so far:

function district9hud
local client = LocalPlayer()
if !client:Alive() then return end
if (client:GetActiveWeapon() == NULL or client: Get ActiveWeapon() ==“Camera”) then return end
draw.Box(3, 5, 5, 200, 100, Color (31, 31, 31, 255)
draw.SimpleText(client:Health() … “%”, “ScoreboardText”, 100, 50, Color(255, 0, 0, 255), 0, 0)
local mag_left = client:GetActiveWeapon():Clip1()
local mag_extra = client:GetAmmoCount(client:GetActiveWeapon():GetPrimaryAmmoType())
local secondary_ammo = client:GetAmmoCount(client:GetActiveWeapon():GetSecondaryAmmoType())
end
hook.Add(“HUDPaint”, “district9hud”, district9hud)
function hidehud(name)
for k, v in pairs{“CHudHealth”, “CHudBattery”, “CHudAmmo”, “CHudSecondaryAmmo”,“CHudSuitPower”} do
if name == v then return false end
end
end
hook.Add(“HUDShouldDraw”, “hidehud”, hidehud)

Use


 or [lua] tags next time.

Just a wild guess here, but maybe change this?

[lua]draw.SimpleText(client:Health() .. "%", "ScoreboardText", 100, 50, Color(255, 0, 0, 255), 0, 0)[/lua]

You could use **[Surface.CreateFont

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Surface.CreateFont)** to create a custom font, then use it in either http://wiki.garrysmod.com/?title=Surface or **[Draw.DrawText

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Draw.DrawText)**

You mean like this?

[lua]draw.SimpleText(client:Health() … “%”, “D9 non-humans”, 100, 50, Color(255, 0, 0, 255), 0, 0)[/lua]

EDIT: I’m going to make a fresh new code because I tried testing the HUD and it won’t work

Okay I made a fresh new code but the custom HUD won’t work does anyone know how to help me get it working?

[lua]district9hud - ( );

local function clr (color) return color.r, color.g, color.b, color.a; end

function district9hud:PaintBar( x, y, w, h, colors, value)

self:PaintPanel( x, y, w, h, colors );

x = x + 1; y = y + 1;
w = w - 2; h = h - 2;

local width = * math.Clamp( value, 0, 1 );
local shade = 4;

surface.SetDrawColor( clr( colors.shade ) );
surface.DrawRect( x, y + shade, width, h - shade );

end

function district9hud:PaintText( x, y, text, font, colors )

surface.SetFont ( font );

surface.SetTextPos( x + 1, y + 1);
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawRect( x, y, w, h );

end

function district9hud:PaintText( x, y, text, font, colors )

surface.SetFont( font );

surface.SetTextPos( x + 1, y + 1 );
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawText( text );

surface.SetTextPos( x + 1, y + 1);
surface.SetTextColor( clr( colors.shadow ) );
surface.DrawText( text );

surface.SetTextPos( x, y );
surface.SetTextColor( clr( colors.text ) );
surface.DrawText( text );

end

function district9hud:TextSize( text, font)

surface.SetFont( font );
return surface.GetTextSize( text );

end

local vars =
{

font = "D9 Non-Human",
padding = 10,
margin = 35,

text_spacing = 2,
bar_spacing = 5,

bar_height = 16,

width = 0.25

};

local colors =
{

background=
{

	border = Color( 25, 25, 25, 255)
	background =  Color(25, 25, 25, 255)

},

text =
{

	shadow = Color( 0, 0, 0, 200),
	text = Color( 255, 0, 0, 120)

},

health_bar =
(

	border = Color (255, 0, 0, 255),
	background = Color( 255, 0, 0, 75),
	shade = Color( 128, 0, 0, 255 ),
	fill = Color( 255, 0, 0, 120)

},

suit_bar =
{
	border = Color( 255, 128, 64, 255)
	background = Color( 255, 128, 64, 75 )
	shade = Color ( 140, 90, 0, 255 )
	fill = ( 215, 107, 0, 101)

}

};

local function HUDPaint( )

client = client or LocalPlayer( );
if( !client:Alive( ) ) then return; end

local _, th = district9hud:TextSize( "TEXT", vars.font );

local i = 2;

local width = vars.width * ScrW( );
local bar_width = width - ( vars.padding * i );
local height = ( vars.padding * 1 ) + ( th * 1 ) + ( vars.text_spacing * 1 ) + ( vars.bar_height * 1 ) + vars.bars_spacing;

local x = vars.marging;
local y = ScrH( ) - vars.margin - height;

local cx = x + vars.padding;
local cy = y + vars.padding;

district9hud:PaintPanel( x, y, width, height, colors.background );

local by = th + vars.text_spacing;

local text = string.format( *Health: %iHP", client:Health( ) );
district9hud:PaintText( cx, cy, text, vars.font, colors.text );
good_hud:PaintBar( cx, cy + by, bar_width, vars.bar_height, colors.health_bar, client:Health( ) / 100 );

by = by + vars.bar_height + vars.bar spacing;

local text = string.format( "Suit: %iSP", client:Armor( ) );
district9hud:PaintText( cx, cy + by, text, vars.font, colors.text );
district9hud:PaintBar( cx, cy + by + th + vars.text_spacing, bar_width, vars.bar_height, colors.suit_bar, client:Armor( ) / 100);

end
hook.Add( “HUDPaint”, “PaintOurHud”, HUDPaint );[/lua]

Is “D9 Non-Human” defined anywhere as a font?

Yeah, here: [lua]# local vars =
{

 font = "D9 Non-Human",  
 padding = 10,  
 margin = 35,  

 text_spacing = 2,  
 bar_spacing = 5,  

 bar_height = 16,  

 width = 0.25  [/lua]

But the problem is the custom hud won’t work at all, I’m not talking about the font this time I’m talking about the entire thing. If I can’t get it working how am I supposed to test it out?

I always thought it would be better doing **[Surface.CreateFont

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Surface.CreateFont)**

I’ll try that out that may be why its not working.

EDIT: The custom HUD I made still isn’t working, does anyone have other explanations as to why it isn’t working?