Jump to content

How would one load a custom font to be used with PIXI.Text? [SOLVED]


MrBill
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • MrBill changed the title to How would one load a custom font to be used with PIXI.Text? [SOLVED]

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