WebGL + Chrome = broken webfonts?

Discussion and feedback on Construct 2

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

Post » Tue Mar 19, 2013 12:25 am

@vee41: I've noticed that icon if you are accessing your game through HTTPS and using external webfonts. Clicking that icon and giving Chrome access to the files seems to fix it (this was related to the weird localhost fix on the previous page I posted at squidster). However it doesn't seem to fix the fonts when they are local webfont files.

Edit: Forgot to mention, if you are sharing your link and you don't want people to have to click the shield icon to allow external files, send them the HTTP (not HTTPS) link. HTTPS will block any files that do not originate from the page/domain you are on, which is the case when using external webfonts.

@Ashley: The latest version of Chrome me but still noticing the problem. However, I went back and tried out what Paradox said and installed R99. In R99 I can confirm webfonts are working fine with WebGL turned on in Chrome. It seems that with R100 there is a large amount of new code in the runtime.js for shader support and that's when webfonts break.

Could something in R100 be the source of the problems? Or is R100 just making use of a feature that is bringing a bug in Chrome to light?boolean2013-03-19 13:42:50
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Tue Mar 19, 2013 7:05 am

[QUOTE=boolean]I've noticed that icon if you are accessing your game through HTTPS and using external webfonts. Clicking that icon and giving Chrome access to the files seems to fix it (this was related to the weird localhost fix on the previous page I posted at squidster). However it doesn't seem to fix the fonts when they are local webfont files.
[/QUOTE]

@boolean, that's it in my case, thank you! :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Mar 19, 2013 3:08 pm

It's difficult to track down issues from such old versions, because rolling back the code that far is difficult or breaks so many things it becomes impossible to test the original issue. We only officially support web-hosted Google Fonts which seem to be working OK at least. Am I right that only local web fonts have a problem? Can someone make a bare-bones capx to help testing?

The main change to Text in r100 was text is now rendered to a canvas which is then converted to a WebGL texture, rather than rendered to a canvas floating on top of the WebGL canvas. In theory this should not change rendering at all because the text is rendered to a canvas both ways, it's just the canvas which is treated differently after that rendering is done. It may be some complicated bug in the interaction between text rendering on a canvas and WebGL, but that would be difficult to reproduce in a minimal test case that browser vendors would require, because generally a lot of code is necessary to get even a simple WebGL view rendering in a similar way to what Construct 2 does. The fact it works in Firefox further suggests it's a Chrome bug. Can someone check if it works in Chrome with WebGL disabled?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Tue Mar 19, 2013 5:50 pm

[QUOTE=Ashley]Am I right that only local web fonts have a problem?[/QUOTE]

After the testing so far in this thread, it seems so.

[QUOTE=Ashley]Can someone make a bare-bones capx to help testing?[/QUOTE]
My original post has a link to the capx I've been using for tests. Here is the link to the capx. It's a demo created by lemo a while back so that it could be verified that it's setup correctly.

[QUOTE=Ashley]The fact it works in Firefox further suggests it's a Chrome bug.[/QUOTE]

I should point out that this thread isn't supposed to point fingers at C2 - It's entirely possible that this is a bug in Chrome. This thread shouldn't be seen as us pestering you to fix it as much as trying to determine where the bug is coming from and, if it is Chrome, what is causing it. The switch from R99 to R100 seemed to break something, but what it was, be it in C2 or Chrome, is the million dollar question.

[QUOTE=Ashley]Can someone check if it works in Chrome with WebGL disabled?[/QUOTE]

Webfonts, local and external, all work in the versions I tested with WebGL disabled.

boolean2013-03-19 17:51:33
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Wed Mar 27, 2013 6:30 am

I'm not sure if this is helpful or not, but I couldn't get the webfont to work in chrome so I just added a "preloader" (text box with the webfont set and some text in it, out of view) and then in the next layout (where I wanted it to work) it loads fine. Never had a problem with FF or IE, just Chrome being stubborn?

Also hitting F12 on chrome to bring up the developer tools would make the webfont appear also.
B
14
S
6
G
2
Posts: 136
Reputation: 3,210

Post » Fri May 24, 2013 5:18 pm

I just started work on the game I had set aside back then, and the font problem still affected it on it's first layout.

I worked around the problem by loading the font to one of the textboxes first thing in the startup event.
at the end of the startup, I put in a "wait 0.1" and then loaded the font again for the family of all the text boxes.

Apparently if the text boxes get set before the font is cached, it never switches to it. (it shows a generic serif font instead.)

You can see a flash of the wrong font, but it does that anyway when it is working correctly. It is a Google font. (Oregano)Paradox2013-05-24 17:20:33
B
201
S
52
G
30
Posts: 897
Reputation: 36,621

Post » Fri May 24, 2013 7:07 pm

Yes I also still have issues with Web Fonts when using WebGL, and I still get that flash of the wrong font even when embedding the webfont in my capx.
Fonts are the one thing I find really frusting about Construct2, I would really like a way to just embed my own font and have it work, or perhaps a built-in and robust SpriteFont plugin. I think a trigger for 'On Web Font Loaded' would be useful too
B
13
S
4
Posts: 127
Reputation: 1,479

Post » Fri May 24, 2013 7:51 pm

@seconddimension

Not sure if this will help, but I'm currently experimenting with Webfonts myself at the moment. To get rid of the annoying flash of the wrong font even after webfont has been set, I set the font to size 0 whilst being visible, then put in a wait of half a second and then set the font to the size I require (so it still acts as being invisible until the font is resized). This seems to stop the change between fonts showing on most occasions (and if it doesn't work, try a longer wait).

Hope this works for you. If not, I still have more experimentation to do and will be happy to let you know if I find something that works better.
B
12
S
3
G
1
Posts: 235
Reputation: 2,053

Post » Fri May 24, 2013 8:25 pm

Also load the webfont during a loading layout, that way it's already downloaded and cached by the time you come upon elements that would need it in game.

I seem to have good luck forcing the webfont via:
On start of layout
>Set text Web Font to FONT at FONT.CSS
>Set text Invisible
>Wait 0.01 seconds
>Set text Visible

Doing this to a textbox on your loader screen should have the text appear almost instantly with the webfont and have the font ready for the rest of the game.
You don't even have to have the textbox visible to the user, just do it on the loading layout before switching to the title.
B
15
S
4
G
4
Posts: 294
Reputation: 3,225

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: Artpunk and 11 guests