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



All times are UTC + 1 hour


Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 11 Jun 2011, 17:18 
User avatar

Joined: 26 Dec 2008, 14:26
Location: Sweden
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:
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?


Top
 Offline Profile  
 
PostPosted: 12 Jun 2011, 13:24 
User avatar

Joined: 26 Dec 2008, 14:26
Location: Sweden
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:
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)


Top
 Offline Profile  
 
PostPosted: 12 Jun 2011, 14:42 
Moderator
User avatar

Joined: 26 Oct 2007, 15:21
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.


Top
 Offline Profile  
 
PostPosted: 12 Jun 2011, 16:15 
User avatar

Joined: 26 Dec 2008, 14:26
Location: Sweden
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.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.