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

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...