WebGL + Chrome = broken webfonts?

Discussion and feedback on Construct 2

Post » Sat Mar 02, 2013 4:03 am

@Ashley @sqiddster

So I found a way around this, at least for published versions. Try publishing the capx above and then before the closing head tag (in index.html) add:

<script>
    WebFontConfig = {
      custom: { families: ['Conv_VAGRundschriftD'],
      urls: ['fonts.css']
    }
};

(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +   
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script>


This seems to force the font to load and all works fine. However, while that works for published games it doesn't help during preview mode (just because it's not as easy to edit the files).

Test page using this technique

Using the above code (with the "families" property changed to my own font family) I was able to publish my game and get it running. It still doesn't really answer why it's not working in the first place though. What technique is C2 using to load webfonts at the moment?
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Sat Mar 02, 2013 12:57 pm

Works for me.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Mar 04, 2013 5:56 pm

What made me think it was working was that i have a game that worked. However, returning to the game, it doesn't work in Chrome anymore, for the first layout, (title screen) but it does work when it reloaded the font for the second layout. (level 1)

Edit:
Here, I used the example and made a second layout, when you click, it switches to layer 2 and you can see the font switches to the proper one.

https://dl.dropbox.com/u/85412219/forumposts/chromefontlayer2.capx

Would this offer a lead to solving @Ashley? (@sqiddster)Paradox2013-03-04 20:59:06
B
200
S
51
G
30
Posts: 896
Reputation: 36,494

Post » Tue Mar 12, 2013 4:22 am

@Paradox : Oh weird that actually works!

I would be curious to know when switching layouts if C2 restarts WebGL - If so it might point towards the theory that the webfonts are not loading fully before it kicks in.

@Ashley: Any thoughts on this? We have two workarounds now. Any thoughts on where the problem might be originating?
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Tue Mar 12, 2013 5:25 am

I edited the example to jump back to layer 1 on another click, and 1 works after it loads for 2.

I just noticed I have another game that has the font not showing in one text box, but is showing in another right under the first.
However I haven't gotten it to repeat that in the example. (it's a complicated setup, with included event sheets, font names stored in Variables, and lots of other setups before the second text is written in a function...)
B
200
S
51
G
30
Posts: 896
Reputation: 36,494

Post » Tue Mar 12, 2013 11:33 am

I just noticed old Arcade games still seem to show Web Fonts properly, but the latest builds don't. This suggests we broke it somehow. Does anyone know exactly which release first broke it? It would help track down the change that broke it.
Scirra Founder
B
359
S
214
G
72
Posts: 22,948
Reputation: 178,532

Post » Tue Mar 12, 2013 7:35 pm

I had r99 on a machine I don't use often, and it worked. I skipped ahead to r102 thinking the font problem would be more recent, but blew it, as r102 didn't work.

edit: @AshleyParadox2013-03-12 19:36:07
B
200
S
51
G
30
Posts: 896
Reputation: 36,494

Post » Sun Mar 17, 2013 4:46 pm

@Ashley

I seem to have run into this as well, here is the project it appeared in: Problem project

Seems that allowing the security stuff in chrome does load the fonts, posted about it in the thread I linked.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sun Mar 17, 2013 4:55 pm

The latest builds of C2 are showing webfonts again for me - are you using the latest Chrome? Might have been a Chrome bug they quickly fixed.
Scirra Founder
B
359
S
214
G
72
Posts: 22,948
Reputation: 178,532

Post » Mon Mar 18, 2013 7:06 am

[QUOTE=Ashley] The latest builds of C2 are showing webfonts again for me - are you using the latest Chrome? Might have been a Chrome bug they quickly fixed.[/QUOTE]

@Ashley

I tested on 2 different computers, both running latest chrome update. this is what happens:

The font does not load, untill

Here is the wrong font:



Here is what appears after I press that little shield icon at top right:



Perhaps this is some security setting I've enabled, but pressing this shield icon fixes it:
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: Elliott, supreme676, zenox98 and 12 guests