How to use of downloaded ttf font by loader.load?

How to use of downloaded ttf font by loader.load?
0

Hi every body,

I try to download my fonts by this code:

As you can see, the result is a string data.

How do I use this string? And how do I replace the previous font?

try this code

      cc.loader.load({url: url, type: cc.Font}, (err, res) => {
        this.label.font = res;
      })

Thanks for the reply, but I also tested this code and it was the same as before.

I found a solution, but I do not know if it’s the right solution. But it works.
The download result is the name of the font. In fact, this font has been downloaded and configured as font face style.
You can see the code in the font-loader.js file.

I used it in fontFamily to set up a new font.

this.myLabel.fontFamily = “newFontName”;
this.myLabel.font._fontFamily = “newFontName”; // this is native property

1 Like