Dynamic font size

So I would like to make a font that changes its size when you resize your window.
Can I do it like this: check if player has another resolution than he had before and create that font again with another size? or what? help :<
is there a concommand or something to reload fonts?
thanks

Kind of a very rigged way to do it, but I divided the font size by the width of my montior’s resolution, and then in the font declaration, put size = ScrW() * thevalueyougot

Just realized you wanted to do this upon screen resize–this only works if you want fonts to scale to every screen resolution that there is; players would have to rejoin the server in order for the font to change size.

Here’s a method I came up with. When you create your fonts inside of whatever function you define to create them (I named mine CreateGameFonts() as you should be able to see), make sure you are multiplying / dividing the font size by the screen width.



hook.Add("PostRender", "RedrawFonts", function()
	if _OLDSCRW then
		if ScrW() ~= _OLDSCRW then
			CreateGameFonts()
			print("Recreating fonts due to screen resolution change.")
			_OLDSCRW = ScrW()
		end
	else
		_OLDSCRW = ScrW()
	end
end)


ScreenScale

Yea ikr that i have to divide/multiply it by something, but I just wanted to do it upon screen resize and I asked if it would not be a laggy way (creating multiple fonts?)