farzher Posted June 17, 2015 Report Share Posted June 17, 2015 @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'} 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 If I break the font attribute, by putting in the value 'tfwtwftwftwf'It goes to some stupid looking font, but still fontsize works fineSo obviously it's recognizing my custom font. Why is the fontsize broken?I've tried multiple .ttf fonts, they all do this Quote Link to comment Share on other sites More sharing options...
drhayes Posted June 17, 2015 Report Share Posted June 17, 2015 Try setting "fontFamily" instead of "font". Or, put more info in the "font" property: "32px 8bit". Quote Link to comment Share on other sites More sharing options...
farzher Posted June 18, 2015 Author Report Share Posted June 18, 2015 fontFamily is not a real thing in PhaserAnd I've tried font as "100px 8bit" "100pt 8bit"It doesn't affect the fontsize Quote Link to comment Share on other sites More sharing options...
MichaelD Posted June 19, 2015 Report Share Posted June 19, 2015 Specifying fontSize on its own never worked for me. This is how it usually works: game.add.text(0, 0, "Hello Font!", { font: '32px myFont', fill: '#000000' }); Quote Link to comment Share on other sites More sharing options...
drhayes Posted June 19, 2015 Report Share Posted June 19, 2015 Not sure what to tell you, but: https://github.com/photonstorm/phaser/blob/63c9d2e88082cef5b702260d463647e1e348f4e3/src/gameobjects/Text.js#L619 Quote Link to comment Share on other sites More sharing options...
farzher Posted June 19, 2015 Author Report Share Posted June 19, 2015 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 PhaserAnd even setTimeout with a delay of 2 seconds. Still starts with Ariel font Quote Link to comment Share on other sites More sharing options...
drhayes Posted June 19, 2015 Report Share Posted June 19, 2015 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.