I’m having problems with labels with .ttf files. I’m trying to use a label on cocos2d-html5 v2.1.4 with a custom ttf, and the label always use the same default font.
And creating the label with
var label = cc.LabelTTF.create(“TEST”, “CalvinItal”, 30 ,cc.SizeZero(),cc.TEXT_ALIGNMENT_CENTER);
@
tested with code example, and doesn’t work either
@
{fontName:“Thonburi”,
src:[
{src:“res/fonts/Thonburi.eot”, type:“embedded-opentype”},
{src:“res/fonts/Thonburi.ttf”,type:“truetype”}]}
@
same problem over here, have you guys found another solution or submitted an issue ticket?
also, I notice in the console I’m getting the following:
“downloadable font: no supported format found (font-family:”FedraSansStd Normal" style:normal weight:normal stretch:normal src index:23)
source: (end of source list)"
Aha! I’ve been struggling with this for a while, and testing a bit after seeing your comment I’ve found that the problem is in how I was preloading the fonts, you see:
Writing this doesn’t work: {fontName:"My Font", src:"my_font.ttf", type:"truetype"}
However, this works just fine: {fontName:"My Font", src:[{src:"my_font.ttf", type:"truetype"}]}
So in the case of fonts you have to pass an array of sources rather than a single source (even if the array only contains one reference)?
I tried following code @font-face {
font-family: ‘BradBunR’;
font-style: normal;
src: url(‘res/font/BradBunR.ttf’) format(‘ttf’);
}
in style tag
and
new cc.LabelTTF(“blabla”, “BradBunR”, 32);
It’s neither working in my computer broswer nor in android broswer.
I am new to cococ2d-x js . Please guide me how to use custom font.