MrBill Posted August 8, 2020 Share Posted August 8, 2020 Working on a minimal gui layer for my project. Text displays fine currently, but I was wondering how to load a custom font for PIXI.Text / PIXI.TextStyle? I looked around and saw webfont loader (link) being recommended for this problem. This looks fine, and I'm willing to use it if it's too inconvenient otherwise, but I was wondering if there was an alternative (more manual) way of doing this? I was thinking of having the fonts stored on the website locally, or retrieve them before the game starts using google fonts. The loader seems somewhat overkill for what I want and I've made it a minor challenge to use as much vanilla javaScript as possible for the project. Appreciate any input. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 8, 2020 Share Posted August 8, 2020 That one: https://fontfaceobserver.com/ It just waits when font is actually loaded. setInterval somewhere inside Quote Link to comment Share on other sites More sharing options...
themoonrat Posted August 9, 2020 Share Posted August 9, 2020 fontfaceobserver is the one. PixiJS wise, either wait until the successful callback function from ffo has completed and then create text using the custom font, or do a force refresh of all the text using updateText function on the successful callback. Basically, don't try to render text with a custom font before ffo has done its thing pedro_rcs 1 Quote Link to comment Share on other sites More sharing options...
MrBill Posted August 10, 2020 Author Share Posted August 10, 2020 Got fontfaceobserver to work pretty easily. Appreciate the help. 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.