Enigmafan Posted September 8, 2013 Share Posted September 8, 2013 Hi all, another question (still working on the sprite stuff from another question, but in the meanwhile); how can I include a ttf file for Pixi to use. It seems that every example I see does not work for me. It is a ttf file that is not available standard in browser, it needs to be included. If anyone can provide me with a an example, just the basics, I'd be very happy :-) Thanx. Quote Link to comment Share on other sites More sharing options...
powerfear Posted September 8, 2013 Share Posted September 8, 2013 Pixi use the canvas to draw text, so the same requirement for using external font are needed, I found this post on stackoverflow which explain how you can use css @font-face to make a font available for the canvas to use. http://stackoverflow.com/questions/2608022/how-can-i-use-custom-fonts-in-an-html5-canvas-element If your font doesn't work make sure it has been preloaded: http://stackoverflow.com/questions/2756575/drawing-text-to-canvas-with-font-face-does-not-work-at-the-first-time Quote Link to comment Share on other sites More sharing options...
rich Posted September 8, 2013 Share Posted September 8, 2013 Alternatively you could load the TTF into a program like bmGlyph and then use Pixi's BitmapText feature. If you need to distribute your game outside of your own site this is probably a better solution in the longer term. Quote Link to comment Share on other sites More sharing options...
Qqwy Posted September 8, 2013 Share Posted September 8, 2013 Of course, a font is only useful as a bitmap font if you use it in one or two fixed sizes, and if the font does not have too many glyphs (i.e. unicode). For other cases, there are multiple great online tools that generate font files for the different browsers and a nice piece of CSS code you can put in your site to load them. I've had good experiences with FontSquirrel myself. Quote Link to comment Share on other sites More sharing options...
Enigmafan Posted September 10, 2013 Author Share Posted September 10, 2013 Thanx everyone for your replies. I went for the bmGlyph option :-) 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.