SimpleText / SimpleTextOutlined. - Problem? ---> G:MOD 13.

Hey guys. I just got my fonts working for G:MOD 13.

But now I have another problem. I get this error in console:


[lua/includes/modules/draw.lua:75] attempt to perform arithmetic on local 'w' (a nil value)
	1. lua/includes/modules/draw.lua:75 (SimpleText)
	2. lua/includes/modules/draw.lua:121 (SimpleTextOutlined)
        3. gamemode/vgui/load.lua:112 <unknown>

This is the line it says have an error:


draw.SimpleTextOutlined(math.Clamp(math.Round(percDone * 100), 0, 100) .. "%", "HUDFont", ScrW() * .5, ScrH() * .5, Color(0, 0, 0, 255), 1, 1, 1, Color(255, 255, 255, 255));

And if I look in “draw.lua” at line 75. It tells my this:


x = x - w/2

And in “draw.lua” on line 121:


SimpleText(text, font, x + (_x), y + (_y), outlinecolour, xalign, yalign)

I got no idea what could cause this problem?
Anyone know how to fix this?

I had this problem yesterday when porting a gamemode over to GMod 13. You’re using a non-existant font. Either make sure that the font is made using font.Create, or make sure that the font actually exists in GMod already. Keep in mind that a lot of fonts have been removed in GMod 13.

Okay this is what I got:


surface.CreateFont( "HintFont", 
                    {
                    font    = "Tahoma",
                    size    = ScreenScale(8),
                    weight  = 1000,
                    antialias = true,
                    shadow = false
            })

Do I just do “Font.Create” instead of “CreateFont”.

I have the font in my content under “resource”?

You must not be creating the font properly, or not at all.

By the way, Garry’s Mod is a whole, it’s not ‘G:Mod’.

I’ve had the same problem too, and it only happens when you have both an x-align/y-align and an invalid font.
I think it has to do with surface.GetTextSize() giving an error when an invalid font is put in (i.e. something I should create a bug report for but I’m too lazy to :v:)

It’s fixed now. Thanks all. :slight_smile: