Jump to content

Can't change fontsize of custom .ttf font


farzher
 Share

Recommended Posts

@font-face {font-family:"8bit"; src: url("assets/retro.ttf");}
game.add.text gameWidth - 4, 32, '0', {fontSize: '32px', fill: '#fff', stroke: '#222', strokeThickness: 3, font: '8bit'}

o6PSByC.png

 

 

Why is it so small? I can't change the size.

If I remove the font attribute, it goes back to default font, and size works fine

X8WwbLj.png

 

If I break the font attribute, by putting in the value 'tfwtwftwftwf'

It goes to some stupid looking font, but still fontsize works fine

4ID1tQ8.png

So obviously it's recognizing my custom font. Why is the fontsize broken?

I've tried multiple .ttf fonts, they all do this

Link to comment
Share on other sites

So get this; I had to rename the font. Apparently "8bit" and the other name I tried "retro" both don't work in Phaser.

Which is super retarded because they work in the browser fine. Apparently you need to start the font name with an uppercase letter?

Anyway, font works now, but only after a bit, it's first Ariel, then changes to my font later.
I guess my font isn't loaded yet?
I've tried using window.onload before starting Phaser

And even setTimeout with a delay of 2 seconds. Still starts with Ariel font

Link to comment
Share on other sites

Weird!

 

So, check out this example: http://phaser.io/examples/v2/text/google-webfonts Specifically, these comments on lines 7-8:

    //  We set a 1 second delay before calling 'createText'.    //  For some reason if we don't the browser cannot render the text the first time it's created.

I bet you're getting bit by the same thing, which sucks. onload doesn't seem to work for web fonts, which is dumb. Might be stuck using something like this https://github.com/typekit/webfontloader to be sure?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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