Page 1 of 1

gl.LoadFont() tempry freezes game when loading widget ingame

Posted: 11 Jun 2011, 18:18
by Pithikos
I am done with a widget but I just noticed that if I disable it ingame and then enable it, the screem will freeze for 3-5 secs. After a lot if trial and error I came to the conclusion that this is due to loading four different fonts:

Code: Select all

local gl, GL            = gl, GL
local header1FontSize      = 20
local header1Font        = gl.LoadFont("fonts/texgyreheros-bold.otf", header1FontSize, 45, 25)
local header2FontSize      = 20
local header2Font      = gl.LoadFont("fonts/texgyreheros-bold.otf", header2FontSize)
local header3FontSize      = 20
local header3Font        = gl.LoadFont("fonts/UnDotum.ttf", header3FontSize)
local toolTipFontSize      = 12
local toolTipFont          = gl.LoadFont("fonts/UnDotum.ttf", toolTipFontSize, 12)
Is this to be expected? Some way to fix this?

Re: gl.LoadFont() tempry freezes game when loading widget ingame

Posted: 12 Jun 2011, 14:24
by Pithikos
Ok so the problem seems to depend on the extra parameters given to LoadFont(). Taking off the outline parameters fixes this. For small outline numbers it lags less. The higher the number, the longer the game stays frozen.

Thus this will load instantly without any lag:

Code: Select all

local gl, GL            = gl, GL
local header1FontSize      = 20
local header1Font        = gl.LoadFont("fonts/texgyreheros-bold.otf", header1FontSize)
local header2FontSize      = 20
local header2Font      = gl.LoadFont("fonts/texgyreheros-bold.otf", header2FontSize)
local header3FontSize      = 20
local header3Font        = gl.LoadFont("fonts/UnDotum.ttf", header3FontSize)
local toolTipFontSize      = 12
local toolTipFont          = gl.LoadFont("fonts/UnDotum.ttf", toolTipFontSize)

Re: gl.LoadFont() tempry freezes game when loading widget ingame

Posted: 12 Jun 2011, 15:42
by Beherith
I believe loadfont renders the whole font to a static buffer, so it doesnt have to render fonts later. Rendering with large outlines can take a while.

Re: gl.LoadFont() tempry freezes game when loading widget ingame

Posted: 12 Jun 2011, 17:15
by Pithikos
Well one weird thing is that I don't see any optical difference with the parameters applied or not. The text always looks the same no matter if I give an outline of 50 or 2.