CCLabelTTF text invisible

Hi,
As mentioned the CCLabelTTF text problem is closed, that will work fine on individual ios project, but when i use this in marmalade the label invisible. What’s the problem i don’t know. If some one have any solution then Plz give me. Thanks in advance.

I have the same problem. Any solutions?

Here is modified source of HelloWorld::init() function

{
    if ( !CCLayer::init() )
    {
        return false;
    }

    CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback) );


    ////CCMenuItemLabel *item = CCMenuItemLabel::itemWithLabel()

    pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 1);

    // add "HelloWorld" splash screen"
    CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");

    // position the sprite on the center of the screen
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    pSprite->setPosition( ccp(size.width/2, size.height/2) );

    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);

*
//// *LABEL CREATION**
    CCLabelTTF* title = CCLabelTTF::labelWithString("asdasd", "Thonburi", 32 );
    addChild(title);
    title->setColor( ccc3(255,32,32) );
    title->setPosition(CCPointMake(200, 200));  

    return true;
}

CCLabelTTF class is not implemented in Cocos2d-x for marmalade engine. You must choose one of the:

  1. CCLabelBMFont instead CCLabelTTF
  2. Use freetype library (https://github.com/marmalade/Freetype)
  3. Use cairo library (https://github.com/marmalade/cairo)

Hello again!
Thanks for your reply.
It seem that CCLabelBMFont does not supports Unicode characters :frowning: So, i can’t realize multilanguage support within using of Cocos2d-x application (in my case, i have to place the text inside of Cocos2d-scenes)

Is there a reason for this?

I read the marmalade documentation and it does support TTF, they have examples using it :frowning:

Maybe somehow we could use internally by Marmalade. But I do not know how to display text bitmap in a device context (as in windows).

Guys, is there any updates on this? I have looked into Freetype and it’s really good lib but implementing CCLabelTTF using Freetype is not a trivial at all :slight_smile: Using Freetype “as is” is not good, becasue cocos has his own marmelade main loop.

I was use the class “BitmapDC” and method “bool CCImage::initWithString” from CCImage_Linux.cpp without changes. I can use CCLabelTTF in marmalade port applications now with Unicode support !

Alex Builder, you are the man! Thanks alot for info. Is it working ok for you? Can you please commit changes into github? It seems that marmalade cocos2d-x port become more and more viable every day! :slight_smile:

Alex Builder, THANKS!

I have checked it and it worked. But, well, it draws black pixels for some reason. Am I doing something wrong?

// add a label shows “Hello World”
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::labelWithString(“Hello World”, “Arial”, 24);
// ask director the window size
CCSize size = CCDirector::sharedDirector()>getWinSize;
// position the label on the center of the screen
pLabel
>setPosition( ccp(size.width / 2, size.height - 50) );

// add the label as a child to this layer
this->addChild(pLabel, 3);

Try this:
pLabel->setColor(ccRED);

pLabel->setColor(ccRED) did not help unfortunately :frowning: As for me, it’s something wrong with transparent pixels, for some reason it assumes that background is black.

hello

Think I fixed it. I changed the code that copies freetype bitmap pixels into m_pData in BitmapDC::getBitmap(const char text, int nWidth, int nHeight, CCImage::ETextAlign eAlignMask, const char pFontName, float fontSize) function.
Here is changed code:

m_pData[(iY * iMaxLineWidth + iX) * 4 + 1] = bitmap.buffer[i \* bitmap.width + j];//R
m_pData[(iY * iMaxLineWidth + iX) * 4 + 2] = bitmap.buffer[i \* bitmap.width + j];//G
m_pData[(iY * iMaxLineWidth + iX) * 4 + 0] = bitmap.buffer[i \* bitmap.width + j];//B
m_pData[(iY * iMaxLineWidth + iX) * 4 + 3] = bitmap.buffer[i \* bitmap.width + j];//alpha
So, it’s working for me now. :smiley:

Great work! Thank you guys!

I did modification for return string in multi-line text correctly, because end words breaking to next line of text.

Great!

But your CCImage_airplay.cpp still has issues with alpha. Just create TTF label on non-black background and you will see. Also there is FPS label issue.

Please, take a look at mine CCImage_airplay.cpp. I got yours CCImage_airplay.cpp and fixed alpha and FPS label issues. For FPS ‘Arial.ttf’ should be in ‘data’ folder.

Small update. If I’m using CCLabelTTF after closing simulator I’m getting error:

IwAssert failure:
Channel: IW_GL
File: IwGL.cpp
Line: 319
Expression: eglGetCurrentContext()
Message: Called function without valid context: glDeleteTextures(1, 0x66e5a74)

It fails on CCTexture2D\ CCSprite::CCSprite(void) ~CCLabelTTF). There is no any errors on real device and if I’m quiting with s3eDeviceRequestQuit(). Any thoughts, guys?

Hi,

this was a known issue that was already fixed.
You can find the patch at http://www.cocos2d-x.org/projects/cocos2d-x/repository.