Extracting font data

I am aware that when a font gets uploaded to playcanvas you can download a zip file that includes the json file and a png that can be used to make a font at runtime that can be used in playcanvas.

I am creating a game that we need to allow a user to upload their own font, and I need to be able to do this process on our side so the client can upload a font into the running exported game and see it at runtime. Is there anyone that knows where this library for extracting this data can be found?

Our font importer is closed source unfortunately. There is a runtime option though called canvas font that could be used? http://playcanvas.github.io/#user-interface/text-canvas-font.html

We need to be able to use the font for in game objects and in game UI. Is there a way for playcanvas to access that from the text canvas?

Canvas font will allow you to use that

Okay, I’m assuming I just need to set the canvas font url to the directory of the needed font? It doesn’t seem like the example pulls from an external font. I’m looking into figuring it out. Thank you for the quick feedback yaustar!

It’s a bit tricky. It uses the font name defined in the CSS of the page: https://github.com/playcanvas/playcanvas.github.io/blob/master/examples/user-interface/text-canvas-font.html#L45

So you would have to add the font file as CSS.

Here’s a project example for the Editor: https://playcanvas.com/project/702920/overview/canvas-font-example

This is how I add the font at runtime (L65) https://playcanvas.com/editor/code/702920?tabs=37962901&line=65

1 Like

I will look further into these examples you have posted. Thank you!