Cocos2d-js ttf font Summary (the most detailed tutorial in history ).
The online tutorials on the use of cocos2d engine fonts can be said to be around the sky. This article mainly explains how to use third-party. ttf fonts.
Cocos2d-js divided web and jsb version, first explains how to use the web version of third-party xxxx. ttf font library, need to load the font in the resource, the format is as follows:
Var g_resource = [
... Skip other here
{
Type: "font ",
Name: "Arial Bold ",
Srcs: ["resource/font/arialbd. eot", "resource/font/arialbd. ttf"]
// The name arialbd. eot, arialbd. ttf is irrelevant (this is relative to the web version, // but the name must be the name of the Library)
}
];
Then you can use the "Arial Bold" font name directly for use,
For example: var labTest = new cc. LabelTTF ("12345", "Arial Bold", 25 );
Now let's talk about how to use jsb: It doesn't need to be so troublesome in jsb. You can use it directly: for example:
Var labTest = new cc. LabelTTF ("12345", "resource/font/Arial Bold. ttf", 25 );
Note that the name of the Arial Bold. ttf font must be the name of the library. Special and web version
Arialbd. ttf is differentiated.