How to change label font?

I make node and addComponent cc.label.
and want change font by ttf font file.
how change font?
font file is exist in ‘resources/font/fontFile.ttf’

1 Like

take the font resource in your project (assets file),then you can take it down “Font”
image

on your left window. but you should make sure Font property in your Node.

oh, not in creator tool.
in js script code.

1 Like

you can search cocos-JS interface ,you will find the API for change the font.

Can I use the cocos-js’ function in cocos creator’s code?

creator’s label is component of the node, but in cocos-js is itself the node itself, right?

new question is here with code

hi @temsini,
the problem with your code is simply that you need to do :

var urlFont = “resources/font/ExtraBold.ttf”;
LabelComp.font = urlFont;

it is just that when you did :

var urlFont = cc.url.raw(‘resources/font/ExtraBold.ttf’);

you are saying that your font file is in the folder /resources/raw/resources/font which is clearly not what you meant.

thanks!