Search code examples
cocos2d-androidcustom-font

Cocos2d-Android Custom font not working


I am trying to use custom font in Cocos2d-Android with CClabel, I have added my font file into the assets and trying to use it by name "Faraco_Hand.ttf" and "Faraco_Hand" but its not working, I have googled around but haven't found any solution. this is how my code looks a like:

currentVideoLabel = CCLabel.makeLabel(VideosLabels[currentSelected], "Faraco_Hand.ttf", winSize.width/41);
        currentVideoLabel.setPosition(CGPoint.make(winSize.width/2, 20));
        addChild(currentVideoLabel);

If someone know this please help me.


Solution

  • Hi i use this way to add font in my game here i am sharing you my code check it hope it's helpful for you here i am setting my font on label this is the only way to set fonts...all the best

    Example:1

     CCLabel labelcontinue = CCLabel.makeLabel("continue", "fonts/JimboStd-Black.otf", 14);
                    labelcontinue.setPosition(CGPoint.ccp(272, 95));
                    labelcontinue.setColor(ccColor3B.ccc3(165, 42, 42));
                    mainPaperNode.addChild(labelcontinue, 25);
    

    Example2:

      CCLabel labelWelcome = CCLabel.makeLabel("Welcome", "fonts/JimboStdBlack.otf",20);
            labelWelcome.setColor(ccColor3B.ccc3(139, 69, 19));
            labelWelcome.setPosition(CGPoint.ccp(innerArea.getContentSize().getWidth() / 2, (innerArea.getContentSize().getHeight() / 2) + 138));
            innerArea.addChild(labelWelcome);