Jump to content

TTF Font not loaded properly


hyude
 Share

Recommended Posts

I have posted it in my other thread, but it seems better to add it in new Thread, because the latter is already answered.

 

I have tried using fontface for .ttf file.

 

However strange things occured. Somehow, the font is not loaded (thus using default font) when the first time I use it. However, when I restart the game state (using Game.state.play('current_state')), the font works.

 

Setting the text manually using font.text = 'my_string' also fixed this problem.

 

My guess is, the cause for that is because the font hasn't finished loaded when phaser object created.

This is more confusing because I create phaser object at window.onload event (so, it will fired after all resources load finished).

Even more so, I go through Boot State and Preloader State before going into Play State.

 

Can anyone give me insight on that?

What might cause this behavior

 

Thank you.

Link to comment
Share on other sites

I'm not sure to be totally honest, window.onload should fire when the DOM is ready AND all images, scripts and so on are loaded (which can take a long time) but I guess there has to be a line drawn regarding what exactly is counted, as potentially a webpage could never stop loading with XHR, scripts dynamically including stuff and so on.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...