Cocos2d-js: Custom TTF font won't display in Android -
Cocos2d-js: Custom TTF font won't display in Android -
i define font resources with
var res = { indieflower_ttf: {type:"font", name:"indieflower", srcs:["res/fonts/indieflower.ttf"]}, }
and create ttf label with:
var text = cc.labelttf.create(text, "indieflower", bubble.fontsize, cc.size(60,0),cc.text_alignment_left, cc.vertical_text_alignment_top);
and display ok in firefox , chrome, show default font (arial) on android.
what else do? checked thread cocos2d-js: how utilize custom ttf font on android devices?, doesn't help.
the problem is, native platforms need total path of ttf font, while html platform needs font name. got 2 solutions cocos2d-x forum:
use bitmap fonts. (yes ... wanted have ttf)
code it:
in resource file have now:
var res = { indieflower_ttf: {type:"font", name:"indieflower", srcs:["res/fonts/indieflower.ttf"]}, }
then helper function:
var _b_getfontname = function(resource) { if (cc.sys.isnative) { homecoming resource.srcs[0]; } else { homecoming resource.name; } }
and create label:
var text = cc.labelttf.create("text", _b_getfontname(res.indieflower_ttf), 48, cc.size(300,0),cc.text_alignment_center, cc.vertical_text_alignment_top);
true-type-fonts cocos2d-js
Comments
Post a Comment