draw.SimpeText is causing Framedrops, any ideas why?

Okay so I recently created a swep, and in the cl_init.lua, I wrote a small piece of code to create a hud element by which I told the player how many blinks they have left.



include('shared.lua')
hook.Add( "HUDPaint", "drawsometext", function()
	surface.CreateFont( "TheDefaultSettings", {
	 font = "Arial",
	 size = 32,
	 weight = 500,
	 blursize = 0,
	 scanlines = 0,
	 antialias = true,
	 underline = false,
	 italic = false,
	 strikeout = false,
	 symbol = false,
	 rotary = false,
	 shadow = false,
	 additive = false,
	 outline = false
	} )
	draw.SimpleText("Remaining Blinks:", "TheDefaultSettings", ScrW() - 125, ScrH() - 100, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
	draw.SimpleText(blinks, "TheDefaultSettings", ScrW() - 125, ScrH() - 75, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end)


The variable “blinks” comes from shared.lua
The code causes framerate to drop from 120 to 25.

I am guessing that It is probably because the code runs too often, or it is simply inefficient, but I don’t know exactly.

Any ideas why it does that or a suggestion for a more efficient workaround?

PS: the font was an example from Gmod WIKI.

The issue is because you’re creating a font within the HUDPaint hook, create the font outside of that.

You’re making the font every frame.

[editline]26th October 2013[/editline]

Willox. >:C

I feel like a dumbass now, thanks guys!