Jump to content

Fonts not working properly


yebudar
 Share

Recommended Posts

Hi guys,

 

Started using phaser recently for a game I am making. The only thing is, I'm trying to use a different (custom) font, something like this: 

https://www.google.com/fonts/specimen/Press+Start+2P

 

Unfortunately I cannot get the font to work. I have two font files - a .png file and a .xml file (xml with config) generated by the 'littera' font generator from a .ttf file. Here is a demo I threw together to demonstrate my issue. 

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create , preload: preload});function preload() {    // Load the font    game.load.bitmapFont('Pixel','assets/pixel.png', 'assets/pixel.xml');}function create() {    // Add a one second delay so that the font can load properly    game.time.events.add(Phaser.Timer.SECOND, doSomething, this);}function doSomething() {    // Render the text    var text = "- phaser -\n with a sprinkle of \n pixi dust.";    var style = { font: "65px Pixel", fill: "#ff0044", align: "center" };    var t = game.add.text(game.world.centerX-300, 0, text, style);}

Any help appreciated, I'm sure I'm being really stupid but it's quite important to have the right font. I have attached the font files so that you can test the font with your solution if you want.

 

Thanks,

Matthew

post-11994-0-54242200-1417799022.png

pixel.xml

Link to comment
Share on other sites

  • 6 years later...
 Share

  • Recently Browsing   0 members

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